| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  447         '${unusedClasses.length} native classes omitted.'); |  447         '${unusedClasses.length} native classes omitted.'); | 
|  448   } |  448   } | 
|  449 } |  449 } | 
|  450  |  450  | 
|  451 void maybeEnableNative(Compiler compiler, |  451 void maybeEnableNative(Compiler compiler, | 
|  452                        LibraryElement library, |  452                        LibraryElement library, | 
|  453                        Uri uri) { |  453                        Uri uri) { | 
|  454   String libraryName = uri.toString(); |  454   String libraryName = uri.toString(); | 
|  455   if (library.entryCompilationUnit.script.name.contains( |  455   if (library.entryCompilationUnit.script.name.contains( | 
|  456           'dart/tests/compiler/dart2js_native') |  456           'dart/tests/compiler/dart2js_native') | 
|  457       || libraryName == 'dart:isolate' |  | 
|  458       || libraryName == 'dart:html' |  457       || libraryName == 'dart:html' | 
|  459       || libraryName == 'dart:html_common' |  458       || libraryName == 'dart:html_common' | 
|  460       || libraryName == 'dart:indexed_db' |  459       || libraryName == 'dart:indexed_db' | 
|  461       || libraryName == 'dart:svg' |  460       || libraryName == 'dart:svg' | 
|  462       || libraryName == 'dart:web_audio') { |  461       || libraryName == 'dart:web_audio') { | 
|  463     library.canUseNative = true; |  462     library.canUseNative = true; | 
|  464   } |  463   } | 
|  465 } |  464 } | 
|  466  |  465  | 
|  467 /** |  466 /** | 
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  890         builder.add(new HForeign( |  889         builder.add(new HForeign( | 
|  891             new DartString.literal('${parameter.name.slowToString()} = #'), |  890             new DartString.literal('${parameter.name.slowToString()} = #'), | 
|  892             const LiteralDartString('void'), |  891             const LiteralDartString('void'), | 
|  893             <HInstruction>[jsClosure])); |  892             <HInstruction>[jsClosure])); | 
|  894       } |  893       } | 
|  895     }); |  894     }); | 
|  896     LiteralString jsCode = nativeBody.asLiteralString(); |  895     LiteralString jsCode = nativeBody.asLiteralString(); | 
|  897     builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |  896     builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 
|  898   } |  897   } | 
|  899 } |  898 } | 
| OLD | NEW |