| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 DartType type = member.computeType(compiler); | 531 DartType type = member.computeType(compiler); |
| 532 if (type.element.isTypeVariable() | 532 if (type.element.isTypeVariable() |
| 533 || type.element == compiler.dynamicClass | 533 || type.element == compiler.dynamicClass |
| 534 || type.element == compiler.objectClass) { | 534 || type.element == compiler.objectClass) { |
| 535 // TODO(ngeoffray): Support type checks on type parameters. | 535 // TODO(ngeoffray): Support type checks on type parameters. |
| 536 return null; | 536 return null; |
| 537 } else { | 537 } else { |
| 538 SourceString helper = compiler.backend.getCheckedModeHelper(type); | 538 SourceString helper = compiler.backend.getCheckedModeHelper(type); |
| 539 Element helperElement = compiler.findHelper(helper); | 539 Element helperElement = compiler.findHelper(helper); |
| 540 String helperName = namer.isolateAccess(helperElement); | 540 String helperName = namer.isolateAccess(helperElement); |
| 541 String additionalArgument = namer.operatorIs(type.element); | 541 String additionalArgument = ''; |
| 542 if (helperElement.computeSignature(compiler).parameterCount != 1) { |
| 543 additionalArgument = ", '${namer.operatorIs(type.element)}'"; |
| 544 } |
| 542 return " set\$$fieldName: function(v) { " | 545 return " set\$$fieldName: function(v) { " |
| 543 "this.$fieldName = $helperName(v, '$additionalArgument'); }"; | 546 "this.$fieldName = $helperName(v$additionalArgument); }"; |
| 544 } | 547 } |
| 545 } | 548 } |
| 546 | 549 |
| 547 List<String> emitClassFields(ClassElement classElement, CodeBuffer buffer) { | 550 List<String> emitClassFields(ClassElement classElement, CodeBuffer buffer) { |
| 548 // If the class is never instantiated we still need to set it up for | 551 // If the class is never instantiated we still need to set it up for |
| 549 // inheritance purposes, but we can simplify its JavaScript constructor. | 552 // inheritance purposes, but we can simplify its JavaScript constructor. |
| 550 bool isInstantiated = | 553 bool isInstantiated = |
| 551 compiler.codegenWorld.instantiatedClasses.contains(classElement); | 554 compiler.codegenWorld.instantiatedClasses.contains(classElement); |
| 552 List<String> checkedSetters = <String>[]; | 555 List<String> checkedSetters = <String>[]; |
| 553 | 556 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 const String HOOKS_API_USAGE = """ | 1380 const String HOOKS_API_USAGE = """ |
| 1378 // Generated by dart2js, the Dart to JavaScript compiler. | 1381 // Generated by dart2js, the Dart to JavaScript compiler. |
| 1379 // The code supports the following hooks: | 1382 // The code supports the following hooks: |
| 1380 // dartPrint(message) - if this function is defined it is called | 1383 // dartPrint(message) - if this function is defined it is called |
| 1381 // instead of the Dart [print] method. | 1384 // instead of the Dart [print] method. |
| 1382 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1385 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 1383 // method will not be invoked directly. | 1386 // method will not be invoked directly. |
| 1384 // Instead, a closure that will invoke [main] is | 1387 // Instead, a closure that will invoke [main] is |
| 1385 // passed to [dartMainRunner]. | 1388 // passed to [dartMainRunner]. |
| 1386 """; | 1389 """; |
| OLD | NEW |