OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library native; | |
6 | |
7 import 'dart:collection' show Queue; | |
8 | |
9 import '../constants/values.dart'; | |
10 import '../dart2jslib.dart'; | |
11 import '../dart_types.dart'; | |
12 import '../elements/elements.dart'; | |
13 import '../elements/modelx.dart' show ClassElementX, FunctionElementX; | |
14 import '../js/js.dart' as js; | |
15 import '../js_backend/js_backend.dart'; | |
16 import '../js_emitter/js_emitter.dart' show CodeEmitterTask; | |
17 import '../resolution/resolution.dart' show ResolverVisitor; | |
18 import '../scanner/scannerlib.dart'; | |
19 import '../ssa/ssa.dart'; | |
20 import '../tree/tree.dart'; | |
21 import '../universe/universe.dart' show SideEffects; | |
22 import '../util/util.dart'; | |
23 | |
24 part 'behavior.dart'; | |
25 part 'enqueue.dart'; | |
26 part 'js.dart'; | |
27 part 'scanner.dart'; | |
28 part 'ssa.dart'; | |
29 | |
30 void maybeEnableNative(Compiler compiler, | |
31 LibraryElement library) { | |
32 String libraryName = library.canonicalUri.toString(); | |
33 if (library.entryCompilationUnit.script.name.contains( | |
34 'dart/tests/compiler/dart2js_native') | |
35 || libraryName == 'dart:async' | |
36 || libraryName == 'dart:html' | |
37 || libraryName == 'dart:html_common' | |
38 || libraryName == 'dart:indexed_db' | |
39 || libraryName == 'dart:js' | |
40 || libraryName == 'dart:svg' | |
41 || libraryName == 'dart:_native_typed_data' | |
42 || libraryName == 'dart:web_audio' | |
43 || libraryName == 'dart:web_gl' | |
44 || libraryName == 'dart:web_sql') { | |
45 library.canUseNative = true; | |
46 } | |
47 } | |
48 | |
49 // The tags string contains comma-separated 'words' which are either dispatch | |
50 // tags (having JavaScript identifier syntax) and directives that begin with | |
51 // `!`. | |
52 List<String> nativeTagsOfClassRaw(ClassElement cls) { | |
53 String quotedName = cls.nativeTagInfo; | |
54 return quotedName.substring(1, quotedName.length - 1).split(','); | |
55 } | |
56 | |
57 List<String> nativeTagsOfClass(ClassElement cls) { | |
58 return nativeTagsOfClassRaw(cls).where((s) => !s.startsWith('!')).toList(); | |
59 } | |
60 | |
61 bool nativeTagsForcedNonLeaf(ClassElement cls) => | |
62 nativeTagsOfClassRaw(cls).contains('!nonleaf'); | |
OLD | NEW |