| 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 | 6 |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'dart2jslib.dart' hide SourceString; | 8 import 'dart2jslib.dart' hide SourceString; |
| 9 import 'elements/elements.dart'; | 9 import 'elements/elements.dart'; |
| 10 import 'js_backend/js_backend.dart'; | 10 import 'js_backend/js_backend.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 static const JsArray = const SpecialType._('=List'); | 27 static const JsArray = const SpecialType._('=List'); |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * This could be an abstract class but we use it as a stub for the dart_backend. | 32 * This could be an abstract class but we use it as a stub for the dart_backend. |
| 33 */ | 33 */ |
| 34 class NativeEnqueuer { | 34 class NativeEnqueuer { |
| 35 /// Initial entry point to native enqueuer. | 35 /// Initial entry point to native enqueuer. |
| 36 void processNativeClasses(Collection<LibraryElement> libraries) {} | 36 void processNativeClasses(Collection<LibraryElement> libraries) {} |
| 37 void processNativeClassesInLibrary(LibraryElement library) {} | |
| 38 | 37 |
| 39 /// Notification of a main Enqueuer worklist element. For methods, adds | 38 /// Notification of a main Enqueuer worklist element. For methods, adds |
| 40 /// information from metadata attributes, and computes types instantiated due | 39 /// information from metadata attributes, and computes types instantiated due |
| 41 /// to calling the method. | 40 /// to calling the method. |
| 42 void registerElement(Element element) {} | 41 void registerElement(Element element) {} |
| 43 | 42 |
| 44 /// Notification of native field. Adds information from metadata attributes. | 43 /// Notification of native field. Adds information from metadata attributes. |
| 45 void handleFieldAnnotations(Element field) {} | 44 void handleFieldAnnotations(Element field) {} |
| 46 | 45 |
| 47 /// Computes types instantiated due to getting a native field. | 46 /// Computes types instantiated due to getting a native field. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 96 |
| 98 ClassElement _annotationCreatesClass; | 97 ClassElement _annotationCreatesClass; |
| 99 ClassElement _annotationReturnsClass; | 98 ClassElement _annotationReturnsClass; |
| 100 ClassElement _annotationJsNameClass; | 99 ClassElement _annotationJsNameClass; |
| 101 | 100 |
| 102 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. | 101 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. |
| 103 NativeEnqueuerBase(this.world, this.compiler, this.enableLiveTypeAnalysis); | 102 NativeEnqueuerBase(this.world, this.compiler, this.enableLiveTypeAnalysis); |
| 104 | 103 |
| 105 void processNativeClasses(Collection<LibraryElement> libraries) { | 104 void processNativeClasses(Collection<LibraryElement> libraries) { |
| 106 libraries.forEach(processNativeClassesInLibrary); | 105 libraries.forEach(processNativeClassesInLibrary); |
| 106 processNativeClassesInLibrary(compiler.isolateHelperLibrary); |
| 107 if (!enableLiveTypeAnalysis) { | 107 if (!enableLiveTypeAnalysis) { |
| 108 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); | 108 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); |
| 109 flushQueue(); | 109 flushQueue(); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void processNativeClassesInLibrary(LibraryElement library) { | 113 void processNativeClassesInLibrary(LibraryElement library) { |
| 114 // Use implementation to ensure the inclusion of injected members. | 114 // Use implementation to ensure the inclusion of injected members. |
| 115 library.implementation.forEachLocalMember((Element element) { | 115 library.implementation.forEachLocalMember((Element element) { |
| 116 if (element.isClass() && element.isNative()) { | 116 if (element.isClass() && element.isNative()) { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 builder.add(new HForeign( | 889 builder.add(new HForeign( |
| 890 new DartString.literal('${parameter.name.slowToString()} = #'), | 890 new DartString.literal('${parameter.name.slowToString()} = #'), |
| 891 const LiteralDartString('void'), | 891 const LiteralDartString('void'), |
| 892 <HInstruction>[jsClosure])); | 892 <HInstruction>[jsClosure])); |
| 893 } | 893 } |
| 894 }); | 894 }); |
| 895 LiteralString jsCode = nativeBody.asLiteralString(); | 895 LiteralString jsCode = nativeBody.asLiteralString(); |
| 896 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 896 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
| 897 } | 897 } |
| 898 } | 898 } |
| OLD | NEW |