| 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 '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 | 9 |
| 10 export 'behavior.dart'; | 10 export 'behavior.dart'; |
| 11 export 'enqueue.dart'; | 11 export 'enqueue.dart'; |
| 12 export 'js.dart'; | 12 export 'js.dart'; |
| 13 export 'scanner.dart'; | 13 export 'scanner.dart'; |
| 14 export 'ssa.dart'; | 14 export 'ssa.dart'; |
| 15 | 15 |
| 16 const Iterable<String> _allowedDartSchemePaths = const <String>[ |
| 17 'async', |
| 18 'html', |
| 19 'html_common', |
| 20 'indexed_db', |
| 21 'js', |
| 22 'svg', |
| 23 '_native_typed_data', |
| 24 'web_audio', |
| 25 'web_gl', |
| 26 'web_sql' |
| 27 ]; |
| 28 |
| 16 bool maybeEnableNative(Compiler compiler, LibraryElement library) { | 29 bool maybeEnableNative(Compiler compiler, LibraryElement library) { |
| 17 String libraryName = library.canonicalUri.toString(); | 30 bool allowedTestLibrary() { |
| 18 if (library.entryCompilationUnit.script.name | 31 String scriptName = library.entryCompilationUnit.script.name; |
| 19 .contains('sdk/tests/compiler/dart2js_native') || | 32 return scriptName.contains('sdk/tests/compiler/dart2js_native') || |
| 20 library.entryCompilationUnit.script.name | 33 scriptName.contains('sdk/tests/compiler/dart2js_extra'); |
| 21 .contains('sdk/tests/compiler/dart2js_extra') || | |
| 22 libraryName == 'dart:async' || | |
| 23 libraryName == 'dart:html' || | |
| 24 libraryName == 'dart:html_common' || | |
| 25 libraryName == 'dart:indexed_db' || | |
| 26 libraryName == 'dart:js' || | |
| 27 libraryName == 'dart:svg' || | |
| 28 libraryName == 'dart:_native_typed_data' || | |
| 29 libraryName == 'dart:web_audio' || | |
| 30 libraryName == 'dart:web_gl' || | |
| 31 libraryName == 'dart:web_sql' || | |
| 32 compiler.options.allowNativeExtensions) { | |
| 33 return true; | |
| 34 } | 34 } |
| 35 return false; | 35 bool allowedDartLibary() { |
| 36 Uri uri = library.canonicalUri; |
| 37 if (uri.scheme != 'dart') return false; |
| 38 return _allowedDartSchemePaths.contains(uri.path); |
| 39 } |
| 40 |
| 41 return allowedTestLibrary() || allowedDartLibary(); |
| 36 } | 42 } |
| OLD | NEW |