| 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 #library('native'); | 5 #library('native'); |
| 6 #import('dart:uri'); | 6 #import('dart:uri'); |
| 7 #import('leg.dart'); | 7 #import('leg.dart'); |
| 8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
| 9 #import('js_backend/js_backend.dart'); | 9 #import('js_backend/js_backend.dart'); |
| 10 #import('scanner/scannerlib.dart'); | 10 #import('scanner/scannerlib.dart'); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 cls.superclass, | 33 cls.superclass, |
| 34 () => <ClassElement>[]); | 34 () => <ClassElement>[]); |
| 35 directSubtypes.add(cls); | 35 directSubtypes.add(cls); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void processNativeClassesInLibrary(Enqueuer world, | 38 void processNativeClassesInLibrary(Enqueuer world, |
| 39 CodeEmitterTask emitter, | 39 CodeEmitterTask emitter, |
| 40 LibraryElement library) { | 40 LibraryElement library) { |
| 41 bool hasNativeClass = false; | 41 bool hasNativeClass = false; |
| 42 final compiler = emitter.compiler; | 42 final compiler = emitter.compiler; |
| 43 for (Link<Element> link = library.localMembers; | 43 library.forEachLocalMember((Element element) { |
| 44 !link.isEmpty(); link = link.tail) { | |
| 45 Element element = link.head; | |
| 46 if (element.kind == ElementKind.CLASS) { | 44 if (element.kind == ElementKind.CLASS) { |
| 47 ClassElement classElement = element; | 45 ClassElement classElement = element; |
| 48 if (classElement.isNative()) { | 46 if (classElement.isNative()) { |
| 49 hasNativeClass = true; | 47 hasNativeClass = true; |
| 50 world.registerInstantiatedClass(classElement); | 48 world.registerInstantiatedClass(classElement); |
| 51 // Also parse the node to know all its methods because | 49 // Also parse the node to know all its methods because |
| 52 // otherwise it will only be parsed if there is a call to | 50 // otherwise it will only be parsed if there is a call to |
| 53 // one of its constructor. | 51 // one of its constructor. |
| 54 classElement.parseNode(compiler); | 52 classElement.parseNode(compiler); |
| 55 // Resolve to setup the inheritance. | 53 // Resolve to setup the inheritance. |
| 56 classElement.ensureResolved(compiler); | 54 classElement.ensureResolved(compiler); |
| 57 // Add the information that this class is a subtype of | 55 // Add the information that this class is a subtype of |
| 58 // its supertypes. The code emitter and the ssa builder use that | 56 // its supertypes. The code emitter and the ssa builder use that |
| 59 // information. | 57 // information. |
| 60 addSubtypes(classElement, emitter.nativeEmitter); | 58 addSubtypes(classElement, emitter.nativeEmitter); |
| 61 } | 59 } |
| 62 } | 60 } |
| 63 } | 61 }, includeInjectedMembers: true); |
| 64 if (hasNativeClass) { | 62 if (hasNativeClass) { |
| 65 world.registerStaticUse(compiler.findHelper( | 63 world.registerStaticUse(compiler.findHelper( |
| 66 const SourceString('dynamicFunction'))); | 64 const SourceString('dynamicFunction'))); |
| 67 world.registerStaticUse(compiler.findHelper( | 65 world.registerStaticUse(compiler.findHelper( |
| 68 const SourceString('dynamicSetMetadata'))); | 66 const SourceString('dynamicSetMetadata'))); |
| 69 world.registerStaticUse(compiler.findHelper( | 67 world.registerStaticUse(compiler.findHelper( |
| 70 const SourceString('defineProperty'))); | 68 const SourceString('defineProperty'))); |
| 71 world.registerStaticUse(compiler.findHelper( | 69 world.registerStaticUse(compiler.findHelper( |
| 72 const SourceString('toStringForNativeObject'))); | 70 const SourceString('toStringForNativeObject'))); |
| 73 world.registerStaticUse(compiler.findHelper( | 71 world.registerStaticUse(compiler.findHelper( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 String parameters) { | 329 String parameters) { |
| 332 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 333 buffer.add("('$methodName')) {\n"); | 331 buffer.add("('$methodName')) {\n"); |
| 334 buffer.add(" $code"); | 332 buffer.add(" $code"); |
| 335 buffer.add(" } else {\n"); | 333 buffer.add(" } else {\n"); |
| 336 buffer.add(" return Object.prototype.$methodName.call(this"); | 334 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 337 buffer.add(parameters == '' ? '' : ', $parameters'); | 335 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 338 buffer.add(");\n"); | 336 buffer.add(");\n"); |
| 339 buffer.add(" }\n"); | 337 buffer.add(" }\n"); |
| 340 } | 338 } |
| OLD | NEW |