Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.js_emitter.program_builder; | 5 library dart2js.js_emitter.program_builder; |
| 6 | 6 |
| 7 import 'js_emitter.dart' show computeMixinClass; | 7 import 'js_emitter.dart' show computeMixinClass; |
| 8 import 'model.dart'; | 8 import 'model.dart'; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 assert(invariant(element, !element.isConstructor)); | 455 assert(invariant(element, !element.isConstructor)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 String callName = null; | 458 String callName = null; |
| 459 if (canTearOff) { | 459 if (canTearOff) { |
| 460 Selector callSelector = | 460 Selector callSelector = |
| 461 new Selector.fromElement(element).toCallSelector(); | 461 new Selector.fromElement(element).toCallSelector(); |
| 462 callName = namer.invocationName(callSelector); | 462 callName = namer.invocationName(callSelector); |
| 463 } | 463 } |
| 464 | 464 |
| 465 DartType memberType; | |
| 466 if (element.isGenerativeConstructorBody) { | |
| 467 // TODO(herhut): Why does this need to be normalized away? We never need | |
| 468 // this information anyway as they cannot be torn off or | |
| 469 // reflected. | |
|
floitsch
2015/02/03 14:14:15
probably for reflection.
| |
| 470 var body = element; | |
| 471 memberType = body.constructor.type; | |
| 472 } else { | |
| 473 memberType = element.type; | |
| 474 } | |
| 475 | |
| 465 return new InstanceMethod(element, name, code, | 476 return new InstanceMethod(element, name, code, |
| 466 _generateParameterStubs(element, canTearOff), callName, | 477 _generateParameterStubs(element, canTearOff), callName, memberType, |
| 467 needsTearOff: canTearOff, tearOffName: tearOffName, | 478 needsTearOff: canTearOff, tearOffName: tearOffName, |
| 468 isClosure: isClosure, aliasName: aliasName, | 479 isClosure: isClosure, aliasName: aliasName, |
| 469 canBeApplied: canBeApplied, canBeReflected: canBeReflected); | 480 canBeApplied: canBeApplied, canBeReflected: canBeReflected); |
| 470 } | 481 } |
| 471 | 482 |
| 472 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element, | 483 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element, |
| 473 bool canTearOff) { | 484 bool canTearOff) { |
| 474 | 485 |
| 475 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[]; | 486 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[]; |
| 476 | 487 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 String callName = null; | 609 String callName = null; |
| 599 if (needsTearOff) { | 610 if (needsTearOff) { |
| 600 Selector callSelector = | 611 Selector callSelector = |
| 601 new Selector.fromElement(element).toCallSelector(); | 612 new Selector.fromElement(element).toCallSelector(); |
| 602 callName = namer.invocationName(callSelector); | 613 callName = namer.invocationName(callSelector); |
| 603 } | 614 } |
| 604 | 615 |
| 605 return new StaticDartMethod(element, | 616 return new StaticDartMethod(element, |
| 606 name, _registry.registerHolder(holder), code, | 617 name, _registry.registerHolder(holder), code, |
| 607 _generateParameterStubs(element, needsTearOff), | 618 _generateParameterStubs(element, needsTearOff), |
| 608 callName, | 619 callName, element.type, |
| 609 needsTearOff: needsTearOff, | 620 needsTearOff: needsTearOff, |
| 610 tearOffName: tearOffName, | 621 tearOffName: tearOffName, |
| 611 canBeApplied: canBeApplied, | 622 canBeApplied: canBeApplied, |
| 612 canBeReflected: canBeReflected); | 623 canBeReflected: canBeReflected); |
| 613 } | 624 } |
| 614 | 625 |
| 615 void _registerConstants(OutputUnit outputUnit, | 626 void _registerConstants(OutputUnit outputUnit, |
| 616 Iterable<ConstantValue> constantValues) { | 627 Iterable<ConstantValue> constantValues) { |
| 617 // `constantValues` is null if an outputUnit doesn't contain any constants. | 628 // `constantValues` is null if an outputUnit doesn't contain any constants. |
| 618 if (constantValues == null) return; | 629 if (constantValues == null) return; |
| 619 for (ConstantValue constantValue in constantValues) { | 630 for (ConstantValue constantValue in constantValues) { |
| 620 _registry.registerConstant(outputUnit, constantValue); | 631 _registry.registerConstant(outputUnit, constantValue); |
| 621 assert(!_constants.containsKey(constantValue)); | 632 assert(!_constants.containsKey(constantValue)); |
| 622 String name = namer.constantName(constantValue); | 633 String name = namer.constantName(constantValue); |
| 623 String constantObject = namer.globalObjectForConstant(constantValue); | 634 String constantObject = namer.globalObjectForConstant(constantValue); |
| 624 Holder holder = _registry.registerHolder(constantObject); | 635 Holder holder = _registry.registerHolder(constantObject); |
| 625 Constant constant = new Constant(name, holder, constantValue); | 636 Constant constant = new Constant(name, holder, constantValue); |
| 626 _constants[constantValue] = constant; | 637 _constants[constantValue] = constant; |
| 627 } | 638 } |
| 628 } | 639 } |
| 629 } | 640 } |
| OLD | NEW |