Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: pkg/front_end/lib/src/fasta/target_implementation.dart

Issue 2913013003: Move enableNative to target, turn it on by default (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 import 'source/source_library_builder.dart' show SourceLibraryBuilder;
12
11 import 'parser/dart_vm_native.dart' as vm show skipNativeClause; 13 import 'parser/dart_vm_native.dart' as vm show skipNativeClause;
12 14
13 import '../scanner/token.dart' show Token; 15 import '../scanner/token.dart' show Token;
14 16
15 import 'loader.dart' show Loader; 17 import 'loader.dart' show Loader;
16 18
17 import 'quote.dart' show unescapeString; 19 import 'quote.dart' show unescapeString;
18 20
19 import 'target.dart' show Target; 21 import 'target.dart' show Target;
20 22
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1); 83 LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1);
82 return cachedNativeAnnotation = internal.getConstructor("ExternalName"); 84 return cachedNativeAnnotation = internal.getConstructor("ExternalName");
83 } 85 }
84 86
85 void loadExtraRequiredLibraries(Loader loader) { 87 void loadExtraRequiredLibraries(Loader loader) {
86 for (String uri in backendTarget.extraRequiredLibraries) { 88 for (String uri in backendTarget.extraRequiredLibraries) {
87 loader.read(Uri.parse(uri), -1); 89 loader.read(Uri.parse(uri), -1);
88 } 90 }
89 } 91 }
90 92
93 /// Whether the `native` language extension is supported within [library].
94 ///
95 /// The `native` language extension is not part of the language specification,
96 /// means something else to each target, and is enabled differently for each
97 /// target implementation. For example, the VM target enables it everywhere
98 /// because of existing support for "dart-ext:" native extensions, but targets
ahe 2017/05/31 09:07:50 I would really like to get this only enabled for d
Siggi Cherem (dart-lang) 2017/05/31 20:26:15 Done.
99 /// like dart2js only enable it on the core libraries.
100 ///
101 /// This default implementation assumes a VM target, but it can be overriden
102 /// in subclasses to change the behavior.
103 bool enableNative(SourceLibraryBuilder library) => true;
Siggi Cherem (dart-lang) 2017/05/30 20:33:59 currently I use SourceLibraryBuilder because this
ahe 2017/05/31 09:07:50 I'm not sure the builder hierarchies make a lot of
Siggi Cherem (dart-lang) 2017/05/31 14:25:43 I was hesitant too. The main reason I thought Sour
ahe 2017/05/31 14:31:25 That's up to you. An alternative is to do a type t
Siggi Cherem (dart-lang) 2017/05/31 20:26:14 turns out that dart2js doesn't have any `native` i
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698