| 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 bool addedDynamicFunction = false; | 8 bool addedDynamicFunction = false; |
| 9 | 9 |
| 10 NativeEmitter(this.compiler); | 10 NativeEmitter(this.compiler); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 buffer.add('$dynamicName = '); | 123 buffer.add('$dynamicName = '); |
| 124 buffer.add(buildDynamicFunctionCode()); | 124 buffer.add(buildDynamicFunctionCode()); |
| 125 buffer.add('\n'); | 125 buffer.add('\n'); |
| 126 buffer.add(buildDynamicMetadataCode()); | 126 buffer.add(buildDynamicMetadataCode()); |
| 127 buffer.add('\n'); | 127 buffer.add('\n'); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void generateNativeClass(ClassElement classElement, StringBuffer buffer) { | 130 void generateNativeClass(ClassElement classElement, StringBuffer buffer) { |
| 131 addDynamicFunctionIfNecessary(buffer); | 131 addDynamicFunctionIfNecessary(buffer); |
| 132 assert(classElement.backendMembers.isEmpty()); | 132 assert(classElement.backendMembers.isEmpty()); |
| 133 String nativeName = classElement.nativeName.stringValue; | 133 String nativeName = classElement.nativeName.slowToString(); |
| 134 nativeName = nativeName.substring(2, nativeName.length - 1); | 134 nativeName = nativeName.substring(2, nativeName.length - 1); |
| 135 for (Element member in classElement.members) { | 135 for (Element member in classElement.members) { |
| 136 if (member.isInstanceMember()) { | 136 if (member.isInstanceMember()) { |
| 137 String memberName = compiler.namer.getName(member); | 137 String memberName = compiler.namer.getName(member); |
| 138 if (member.kind === ElementKind.FUNCTION | 138 if (member.kind === ElementKind.FUNCTION |
| 139 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY | 139 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY |
| 140 || member.kind === ElementKind.GETTER | 140 || member.kind === ElementKind.GETTER |
| 141 || member.kind === ElementKind.SETTER) { | 141 || member.kind === ElementKind.SETTER) { |
| 142 String codeBlock = compiler.universe.generatedCode[member]; | 142 String codeBlock = compiler.universe.generatedCode[member]; |
| 143 if (codeBlock == null) continue; | 143 if (codeBlock == null) continue; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // method does not have subclasses. | 190 // method does not have subclasses. |
| 191 buffer.add(' if (Object.getPrototypeOf(this).hasOwnProperty('); | 191 buffer.add(' if (Object.getPrototypeOf(this).hasOwnProperty('); |
| 192 buffer.add("'$invocationName')) {\n"); | 192 buffer.add("'$invocationName')) {\n"); |
| 193 buffer.add(' return this.${compiler.namer.getName(member)}($arguments)'); | 193 buffer.add(' return this.${compiler.namer.getName(member)}($arguments)'); |
| 194 buffer.add('\n }\n'); | 194 buffer.add('\n }\n'); |
| 195 buffer.add(' return Object.prototype.$invocationName.call(this'); | 195 buffer.add(' return Object.prototype.$invocationName.call(this'); |
| 196 buffer.add(arguments == '' ? '' : ', $arguments'); | 196 buffer.add(arguments == '' ? '' : ', $arguments'); |
| 197 buffer.add(');'); | 197 buffer.add(');'); |
| 198 } | 198 } |
| 199 } | 199 } |
| OLD | NEW |