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, Emitter; | 7 import '../js_emitter.dart' show computeMixinClass, Emitter; |
8 import '../model.dart'; | 8 import '../model.dart'; |
9 | 9 |
10 import '../../common.dart'; | 10 import '../../common.dart'; |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 552 |
553 DartMethod _buildMethod(MethodElement element) { | 553 DartMethod _buildMethod(MethodElement element) { |
554 js.Name name = namer.methodPropertyName(element); | 554 js.Name name = namer.methodPropertyName(element); |
555 js.Expression code = backend.generatedCode[element]; | 555 js.Expression code = backend.generatedCode[element]; |
556 | 556 |
557 // TODO(kasperl): Figure out under which conditions code is null. | 557 // TODO(kasperl): Figure out under which conditions code is null. |
558 if (code == null) return null; | 558 if (code == null) return null; |
559 | 559 |
560 bool canTearOff = false; | 560 bool canTearOff = false; |
561 js.Name tearOffName; | 561 js.Name tearOffName; |
562 bool isClosure = false; | 562 bool isClosureCallMethod = false; |
563 bool isNotApplyTarget = !element.isFunction || element.isAccessor; | 563 bool isNotApplyTarget = !element.isFunction || element.isAccessor; |
564 | 564 |
565 bool canBeReflected = _methodCanBeReflected(element); | 565 bool canBeReflected = _methodCanBeReflected(element); |
566 bool canBeApplied = _methodCanBeApplied(element); | 566 bool canBeApplied = _methodCanBeApplied(element); |
567 | 567 |
568 js.Name aliasName = backend.isAliasedSuperMember(element) | 568 js.Name aliasName = backend.isAliasedSuperMember(element) |
569 ? namer.aliasedSuperMemberPropertyName(element) | 569 ? namer.aliasedSuperMemberPropertyName(element) |
570 : null; | 570 : null; |
571 | 571 |
572 if (isNotApplyTarget) { | 572 if (isNotApplyTarget) { |
573 canTearOff = false; | 573 canTearOff = false; |
574 } else { | 574 } else { |
575 if (element.enclosingClass.isClosure) { | 575 if (element.enclosingClass.isClosure) { |
576 canTearOff = false; | 576 canTearOff = false; |
577 isClosure = true; | 577 isClosureCallMethod = true; |
578 } else { | 578 } else { |
579 // Careful with operators. | 579 // Careful with operators. |
580 canTearOff = universe.hasInvokedGetter(element, _compiler.world) || | 580 canTearOff = universe.hasInvokedGetter(element, _compiler.world) || |
581 (canBeReflected && !element.isOperator); | 581 (canBeReflected && !element.isOperator); |
582 assert(canTearOff || | 582 assert(canTearOff || |
583 !universe.methodsNeedingSuperGetter.contains(element)); | 583 !universe.methodsNeedingSuperGetter.contains(element)); |
584 tearOffName = namer.getterForElement(element); | 584 tearOffName = namer.getterForElement(element); |
585 } | 585 } |
586 } | 586 } |
587 | 587 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 if (canBeApplied || canBeReflected) { | 621 if (canBeApplied || canBeReflected) { |
622 FunctionSignature signature = element.functionSignature; | 622 FunctionSignature signature = element.functionSignature; |
623 requiredParameterCount = signature.requiredParameterCount; | 623 requiredParameterCount = signature.requiredParameterCount; |
624 optionalParameterDefaultValues = | 624 optionalParameterDefaultValues = |
625 _computeParameterDefaultValues(signature); | 625 _computeParameterDefaultValues(signature); |
626 } | 626 } |
627 | 627 |
628 return new InstanceMethod(element, name, code, | 628 return new InstanceMethod(element, name, code, |
629 _generateParameterStubs(element, canTearOff), callName, | 629 _generateParameterStubs(element, canTearOff), callName, |
630 needsTearOff: canTearOff, tearOffName: tearOffName, | 630 needsTearOff: canTearOff, tearOffName: tearOffName, |
631 isClosure: isClosure, aliasName: aliasName, | 631 isClosureCallMethod: isClosureCallMethod, aliasName: aliasName, |
632 canBeApplied: canBeApplied, canBeReflected: canBeReflected, | 632 canBeApplied: canBeApplied, canBeReflected: canBeReflected, |
633 requiredParameterCount: requiredParameterCount, | 633 requiredParameterCount: requiredParameterCount, |
634 optionalParameterDefaultValues: optionalParameterDefaultValues, | 634 optionalParameterDefaultValues: optionalParameterDefaultValues, |
635 functionType: functionType); | 635 functionType: functionType); |
636 } | 636 } |
637 | 637 |
638 js.Expression _generateFunctionType(DartType type, OutputUnit outputUnit) { | 638 js.Expression _generateFunctionType(DartType type, OutputUnit outputUnit) { |
639 if (type.containsTypeVariables) { | 639 if (type.containsTypeVariables) { |
640 js.Expression thisAccess = js.js(r'this.$receiver'); | 640 js.Expression thisAccess = js.js(r'this.$receiver'); |
641 return backend.rti.getSignatureEncoding(type, thisAccess); | 641 return backend.rti.getSignatureEncoding(type, thisAccess); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 Constant constant = new Constant(name, holder, constantValue); | 829 Constant constant = new Constant(name, holder, constantValue); |
830 _constants[constantValue] = constant; | 830 _constants[constantValue] = constant; |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 Holder _registerStaticStateHolder() { | 834 Holder _registerStaticStateHolder() { |
835 return _registry.registerHolder( | 835 return _registry.registerHolder( |
836 namer.staticStateHolder, isStaticStateHolder: true); | 836 namer.staticStateHolder, isStaticStateHolder: true); |
837 } | 837 } |
838 } | 838 } |
OLD | NEW |