OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.target_implementation; | 5 library fasta.target_implementation; |
6 | 6 |
7 import 'package:kernel/target/targets.dart' as backend show Target; | 7 import 'package:kernel/target/targets.dart' as backend show Target; |
8 | 8 |
9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; | 9 import 'builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1); | 81 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1); |
82 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); | 82 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); |
83 } | 83 } |
84 | 84 |
85 void loadExtraRequiredLibraries(Loader loader) { | 85 void loadExtraRequiredLibraries(Loader loader) { |
86 for (String uri in backendTarget.extraRequiredLibraries) { | 86 for (String uri in backendTarget.extraRequiredLibraries) { |
87 loader.read(Uri.parse(uri), -1); | 87 loader.read(Uri.parse(uri), -1); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
| 91 /// Whether the `native` language extension is supported within [library]. |
| 92 /// |
| 93 /// The `native` language extension is not part of the language specification, |
| 94 /// means something else to each target, and is enabled differently for each |
| 95 /// target implementation. For example, the VM target enables it everywhere |
| 96 /// because of existing support for "dart-ext:" native extensions, but targets |
| 97 /// like dart2js only enable it on the core libraries. |
| 98 /// |
| 99 /// This default implementation assumes a VM target, but it can be overriden |
| 100 /// in subclasses to change the behavior. |
| 101 // TODO(sigmund,ahe): limit this to `dart-ext` libraries only (see |
| 102 // https://github.com/dart-lang/sdk/issues/29763). |
| 103 bool enableNative(LibraryBuilder library) => true; |
| 104 |
91 Token skipNativeClause(Token token) => vm.skipNativeClause(token); | 105 Token skipNativeClause(Token token) => vm.skipNativeClause(token); |
92 | 106 |
93 String extractNativeMethodName(Token token) => | 107 String extractNativeMethodName(Token token) => |
94 unescapeString(token.next.lexeme); | 108 unescapeString(token.next.lexeme); |
95 | 109 |
96 void addSourceInformation( | 110 void addSourceInformation( |
97 Uri uri, List<int> lineStarts, List<int> sourceCode); | 111 Uri uri, List<int> lineStarts, List<int> sourceCode); |
98 | 112 |
99 void readPatchFiles(LibraryBuilder library) { | 113 void readPatchFiles(LibraryBuilder library) { |
100 assert(library.uri.scheme == "dart"); | 114 assert(library.uri.scheme == "dart"); |
101 List<Uri> patches = uriTranslator.patches[library.uri.path]; | 115 List<Uri> patches = uriTranslator.patches[library.uri.path]; |
102 if (patches != null) { | 116 if (patches != null) { |
103 for (Uri patch in patches) { | 117 for (Uri patch in patches) { |
104 library.loader.read(patch, -1, fileUri: patch, isPatch: true); | 118 library.loader.read(patch, -1, fileUri: patch, isPatch: true); |
105 } | 119 } |
106 } | 120 } |
107 } | 121 } |
108 } | 122 } |
OLD | NEW |