| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 String generateCheckedSetter(Element member, String fieldName) { | 546 String generateCheckedSetter(Element member, String fieldName) { |
| 547 DartType type = member.computeType(compiler); | 547 DartType type = member.computeType(compiler); |
| 548 if (type.element.isTypeVariable() | 548 if (type.element.isTypeVariable() |
| 549 || type.element == compiler.dynamicClass | 549 || type.element == compiler.dynamicClass |
| 550 || type.element == compiler.objectClass) { | 550 || type.element == compiler.objectClass) { |
| 551 // TODO(ngeoffray): Support type checks on type parameters. | 551 // TODO(ngeoffray): Support type checks on type parameters. |
| 552 return null; | 552 return null; |
| 553 } else { | 553 } else { |
| 554 SourceString helper = compiler.backend.getCheckedModeHelper(type); | 554 SourceString helper = compiler.backend.getCheckedModeHelper(type); |
| 555 Element helperElement = compiler.findHelper(helper); | 555 FunctionElement helperElement = compiler.findHelper(helper); |
| 556 String helperName = namer.isolateAccess(helperElement); | 556 String helperName = namer.isolateAccess(helperElement); |
| 557 String additionalArgument = ''; | 557 String additionalArgument = ''; |
| 558 if (helperElement.computeSignature(compiler).parameterCount != 1) { | 558 if (helperElement.computeSignature(compiler).parameterCount != 1) { |
| 559 additionalArgument = ", '${namer.operatorIs(type.element)}'"; | 559 additionalArgument = ", '${namer.operatorIs(type.element)}'"; |
| 560 } | 560 } |
| 561 return " set\$$fieldName: function(v) { " | 561 return " set\$$fieldName: function(v) { " |
| 562 "this.$fieldName = $helperName(v$additionalArgument); }"; | 562 "this.$fieldName = $helperName(v$additionalArgument); }"; |
| 563 } | 563 } |
| 564 } | 564 } |
| 565 | 565 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 663 } |
| 664 | 664 |
| 665 classElement.implementation.forEachMember(includeBackendMembers: true, | 665 classElement.implementation.forEachMember(includeBackendMembers: true, |
| 666 f: (ClassElement enclosing, Element member) { | 666 f: (ClassElement enclosing, Element member) { |
| 667 assert(invariant(classElement, member.isDeclaration)); | 667 assert(invariant(classElement, member.isDeclaration)); |
| 668 if (member.isInstanceMember()) { | 668 if (member.isInstanceMember()) { |
| 669 addInstanceMember(member, defineInstanceMember); | 669 addInstanceMember(member, defineInstanceMember); |
| 670 } | 670 } |
| 671 }); | 671 }); |
| 672 | 672 |
| 673 generateIsTestsOn(classElement, (Element other) { | 673 generateIsTestsOn(classElement, (ClassElement other) { |
| 674 String code; | 674 String code; |
| 675 if (other.isObject(compiler)) return; | 675 if (other.isObject(compiler)) return; |
| 676 if (nativeEmitter.requiresNativeIsCheck(other)) { | 676 if (nativeEmitter.requiresNativeIsCheck(other)) { |
| 677 code = 'function() { return true; }'; | 677 code = 'function() { return true; }'; |
| 678 } else { | 678 } else { |
| 679 code = 'true'; | 679 code = 'true'; |
| 680 } | 680 } |
| 681 CodeBuffer typeTestBuffer = new CodeBuffer(); | 681 CodeBuffer typeTestBuffer = new CodeBuffer(); |
| 682 typeTestBuffer.add(code); | 682 typeTestBuffer.add(code); |
| 683 defineInstanceMember(namer.operatorIs(other), typeTestBuffer); | 683 defineInstanceMember(namer.operatorIs(other), typeTestBuffer); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 const String HOOKS_API_USAGE = """ | 1435 const String HOOKS_API_USAGE = """ |
| 1436 // Generated by dart2js, the Dart to JavaScript compiler. | 1436 // Generated by dart2js, the Dart to JavaScript compiler. |
| 1437 // The code supports the following hooks: | 1437 // The code supports the following hooks: |
| 1438 // dartPrint(message) - if this function is defined it is called | 1438 // dartPrint(message) - if this function is defined it is called |
| 1439 // instead of the Dart [print] method. | 1439 // instead of the Dart [print] method. |
| 1440 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1440 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 1441 // method will not be invoked directly. | 1441 // method will not be invoked directly. |
| 1442 // Instead, a closure that will invoke [main] is | 1442 // Instead, a closure that will invoke [main] is |
| 1443 // passed to [dartMainRunner]. | 1443 // passed to [dartMainRunner]. |
| 1444 """; | 1444 """; |
| OLD | NEW |