| 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:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/backend_api.dart' show | 10 import '../common/backend_api.dart' show |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 import '../universe/side_effects.dart' show | 49 import '../universe/side_effects.dart' show |
| 50 SideEffects; | 50 SideEffects; |
| 51 import '../util/util.dart'; | 51 import '../util/util.dart'; |
| 52 | 52 |
| 53 part 'behavior.dart'; | 53 part 'behavior.dart'; |
| 54 part 'enqueue.dart'; | 54 part 'enqueue.dart'; |
| 55 part 'js.dart'; | 55 part 'js.dart'; |
| 56 part 'scanner.dart'; | 56 part 'scanner.dart'; |
| 57 part 'ssa.dart'; | 57 part 'ssa.dart'; |
| 58 | 58 |
| 59 void maybeEnableNative(Compiler compiler, | 59 bool maybeEnableNative(Compiler compiler, |
| 60 LibraryElementX library) { | 60 LibraryElement library) { |
| 61 String libraryName = library.canonicalUri.toString(); | 61 String libraryName = library.canonicalUri.toString(); |
| 62 if (library.entryCompilationUnit.script.name.contains( | 62 if (library.entryCompilationUnit.script.name.contains( |
| 63 'sdk/tests/compiler/dart2js_native') | 63 'sdk/tests/compiler/dart2js_native') |
| 64 || libraryName == 'dart:async' | 64 || libraryName == 'dart:async' |
| 65 || libraryName == 'dart:html' | 65 || libraryName == 'dart:html' |
| 66 || libraryName == 'dart:html_common' | 66 || libraryName == 'dart:html_common' |
| 67 || libraryName == 'dart:indexed_db' | 67 || libraryName == 'dart:indexed_db' |
| 68 || libraryName == 'dart:js' | 68 || libraryName == 'dart:js' |
| 69 || libraryName == 'dart:svg' | 69 || libraryName == 'dart:svg' |
| 70 || libraryName == 'dart:_native_typed_data' | 70 || libraryName == 'dart:_native_typed_data' |
| 71 || libraryName == 'dart:web_audio' | 71 || libraryName == 'dart:web_audio' |
| 72 || libraryName == 'dart:web_gl' | 72 || libraryName == 'dart:web_gl' |
| 73 || libraryName == 'dart:web_sql' | 73 || libraryName == 'dart:web_sql' |
| 74 || compiler.allowNativeExtensions) { | 74 || compiler.allowNativeExtensions) { |
| 75 library.canUseNative = true; | 75 return true; |
| 76 } | 76 } |
| 77 return false; |
| 77 } | 78 } |
| 78 | |
| 79 // The tags string contains comma-separated 'words' which are either dispatch | |
| 80 // tags (having JavaScript identifier syntax) and directives that begin with | |
| 81 // `!`. | |
| 82 List<String> nativeTagsOfClassRaw(ClassElement cls) { | |
| 83 String quotedName = cls.nativeTagInfo; | |
| 84 return quotedName.substring(1, quotedName.length - 1).split(','); | |
| 85 } | |
| 86 | |
| 87 List<String> nativeTagsOfClass(ClassElement cls) { | |
| 88 return nativeTagsOfClassRaw(cls).where((s) => !s.startsWith('!')).toList(); | |
| 89 } | |
| 90 | |
| 91 bool nativeTagsForcedNonLeaf(ClassElement cls) => | |
| 92 nativeTagsOfClassRaw(cls).contains('!nonleaf'); | |
| OLD | NEW |