| 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('../../lib/uri/uri.dart'); | 6 #import('../../lib/uri/uri.dart'); |
| 7 #import('leg.dart'); | 7 #import('leg.dart'); |
| 8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
| 9 #import('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
| 10 #import('ssa/ssa.dart'); | 10 #import('ssa/ssa.dart'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 for (Type type in cls.allSupertypes) { | 23 for (Type type in cls.allSupertypes) { |
| 24 List<Element> subtypes = emitter.subtypes.putIfAbsent( | 24 List<Element> subtypes = emitter.subtypes.putIfAbsent( |
| 25 type.element, | 25 type.element, |
| 26 () => <ClassElement>[]); | 26 () => <ClassElement>[]); |
| 27 subtypes.add(cls); | 27 subtypes.add(cls); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 void processNativeClassesInLibrary(Compiler compiler, | 31 void processNativeClassesInLibrary(Compiler compiler, |
| 32 LibraryElement library) { | 32 LibraryElement library) { |
| 33 bool hasNativeClass = false; |
| 33 for (Link<Element> link = library.topLevelElements; | 34 for (Link<Element> link = library.topLevelElements; |
| 34 !link.isEmpty(); link = link.tail) { | 35 !link.isEmpty(); link = link.tail) { |
| 35 Element element = link.head; | 36 Element element = link.head; |
| 36 if (element.kind == ElementKind.CLASS) { | 37 if (element.kind == ElementKind.CLASS) { |
| 37 ClassElement classElement = element; | 38 ClassElement classElement = element; |
| 38 if (classElement.isNative()) { | 39 if (classElement.isNative()) { |
| 40 hasNativeClass = true; |
| 39 compiler.registerInstantiatedClass(classElement); | 41 compiler.registerInstantiatedClass(classElement); |
| 40 // Also parse the node to know all its methods because | 42 // Also parse the node to know all its methods because |
| 41 // otherwise it will only be parsed if there is a call to | 43 // otherwise it will only be parsed if there is a call to |
| 42 // one of its constructor. | 44 // one of its constructor. |
| 43 classElement.parseNode(compiler); | 45 classElement.parseNode(compiler); |
| 44 // Resolve to setup the inheritance. | 46 // Resolve to setup the inheritance. |
| 45 classElement.ensureResolved(compiler); | 47 classElement.ensureResolved(compiler); |
| 46 // Add the information that this class is a subtype of | 48 // Add the information that this class is a subtype of |
| 47 // its supertypes. The code emitter and the ssa builder use that | 49 // its supertypes. The code emitter and the ssa builder use that |
| 48 // information. | 50 // information. |
| 49 NativeEmitter emitter = compiler.emitter.nativeEmitter; | 51 NativeEmitter emitter = compiler.emitter.nativeEmitter; |
| 50 addSubtypes(classElement, emitter); | 52 addSubtypes(classElement, emitter); |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 } | 55 } |
| 56 if (hasNativeClass) { |
| 57 compiler.registerStaticUse(compiler.findHelper( |
| 58 const SourceString('dynamicFunction'))); |
| 59 compiler.registerStaticUse(compiler.findHelper( |
| 60 const SourceString('dynamicSetMetadata'))); |
| 61 compiler.registerStaticUse(compiler.findHelper( |
| 62 const SourceString('dynamicIsCheck'))); |
| 63 } |
| 54 } | 64 } |
| 55 | 65 |
| 56 void maybeEnableNative(Compiler compiler, | 66 void maybeEnableNative(Compiler compiler, |
| 57 LibraryElement library, | 67 LibraryElement library, |
| 58 Uri uri) { | 68 Uri uri) { |
| 59 String libraryName = uri.toString(); | 69 String libraryName = uri.toString(); |
| 60 if (library.script.name.contains('dart/frog/tests/native/src') | 70 if (library.script.name.contains('dart/frog/tests/native/src') |
| 61 || libraryName == 'dart:dom' | 71 || libraryName == 'dart:dom' |
| 62 || libraryName == 'dart:isolate' | 72 || libraryName == 'dart:isolate' |
| 63 || libraryName == 'dart:html') { | 73 || libraryName == 'dart:html') { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 const LiteralDartString('void'), | 340 const LiteralDartString('void'), |
| 331 <HInstruction>[jsClosure])); | 341 <HInstruction>[jsClosure])); |
| 332 } | 342 } |
| 333 }); | 343 }); |
| 334 LiteralString jsCode = node.arguments.head; | 344 LiteralString jsCode = node.arguments.head; |
| 335 builder.push(new HForeign(jsCode.dartString, | 345 builder.push(new HForeign(jsCode.dartString, |
| 336 const LiteralDartString('Object'), | 346 const LiteralDartString('Object'), |
| 337 <HInstruction>[])); | 347 <HInstruction>[])); |
| 338 } | 348 } |
| 339 } | 349 } |
| OLD | NEW |