| 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 class NativeEmitter { | 5 class NativeEmitter { |
| 6 | 6 |
| 7 Compiler compiler; | 7 Compiler compiler; |
| 8 StringBuffer nativeBuffer; | 8 StringBuffer nativeBuffer; |
| 9 | 9 |
| 10 // Classes that participate in dynamic dispatch. These are the | 10 // Classes that participate in dynamic dispatch. These are the |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (hasUsedSelectors) classesWithDynamicDispatch.add(classElement); | 142 if (hasUsedSelectors) classesWithDynamicDispatch.add(classElement); |
| 143 } | 143 } |
| 144 | 144 |
| 145 List<ClassElement> getDirectSubclasses(ClassElement cls) { | 145 List<ClassElement> getDirectSubclasses(ClassElement cls) { |
| 146 List<ClassElement> result = directSubtypes[cls]; | 146 List<ClassElement> result = directSubtypes[cls]; |
| 147 return result === null ? const<ClassElement>[] : result; | 147 return result === null ? const<ClassElement>[] : result; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void potentiallyConvertDartClosuresToJs(StringBuffer code, | 150 void potentiallyConvertDartClosuresToJs(StringBuffer code, |
| 151 FunctionElement member) { | 151 FunctionElement member) { |
| 152 FunctionParameters parameters = member.computeParameters(compiler); | 152 FunctionSignature parameters = member.computeSignature(compiler); |
| 153 Element converter = | 153 Element converter = |
| 154 compiler.findHelper(const SourceString('convertDartClosureToJS')); | 154 compiler.findHelper(const SourceString('convertDartClosureToJS')); |
| 155 String closureConverter = compiler.namer.isolateAccess(converter); | 155 String closureConverter = compiler.namer.isolateAccess(converter); |
| 156 parameters.forEachParameter((Element parameter) { | 156 parameters.forEachParameter((Element parameter) { |
| 157 Type type = parameter.computeType(compiler); | 157 Type type = parameter.computeType(compiler); |
| 158 if (type is FunctionType) { | 158 if (type is FunctionType) { |
| 159 String name = parameter.name.slowToString(); | 159 String name = parameter.name.slowToString(); |
| 160 code.add(' $name = $closureConverter($name);\n'); | 160 code.add(' $name = $closureConverter($name);\n'); |
| 161 } | 161 } |
| 162 }); | 162 }); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 String toStringName = compiler.namer.instanceMethodName( | 371 String toStringName = compiler.namer.instanceMethodName( |
| 372 null, const SourceString('toString'), 0); | 372 null, const SourceString('toString'), 0); |
| 373 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); | 373 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); |
| 374 objectProperties.add( | 374 objectProperties.add( |
| 375 'function() { return $toStringHelperName(this); });\n'); | 375 'function() { return $toStringHelperName(this); });\n'); |
| 376 | 376 |
| 377 // Finally, emit the code in the main buffer. | 377 // Finally, emit the code in the main buffer. |
| 378 targetBuffer.add('(function() {\n$objectProperties$nativeBuffer\n})();\n'); | 378 targetBuffer.add('(function() {\n$objectProperties$nativeBuffer\n})();\n'); |
| 379 } | 379 } |
| 380 } | 380 } |
| OLD | NEW |