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

Unified Diff: pkg/front_end/lib/src/fasta/source/diet_listener.dart

Issue 2676823002: Add option --compile-sdk to fasta compile and run. (Closed)
Patch Set: Address comments. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/outline.dart ('k') | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/source/diet_listener.dart
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
index dd5a19da04cac42d274837a21f397c4dd8b4e230..366f1c11c9ff01d5c10d77eef9393278a1545615 100644
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart
@@ -13,14 +13,24 @@ import 'package:kernel/class_hierarchy.dart' show
import 'package:kernel/core_types.dart' show
CoreTypes;
-import 'package:front_end/src/fasta/parser/parser.dart' show
+import '../parser/parser.dart' show
Parser,
optional;
-import 'package:front_end/src/fasta/scanner/token.dart' show
+import '../scanner/token.dart' show
BeginGroupToken,
Token;
+import '../parser/dart_vm_native.dart' show
+ removeNativeClause,
+ skipNativeClause;
+
+import '../parser/error_kind.dart' show
+ ErrorKind;
+
+import '../util/link.dart' show
+ Link;
+
import '../errors.dart' show
Crash,
InputError,
@@ -60,6 +70,8 @@ class DietListener extends StackListener {
final AstKind astKind;
+ final bool isDartLibrary;
+
ClassBuilder currentClass;
/// For top-level declarations, this is the library scope. For class members,
@@ -69,7 +81,8 @@ class DietListener extends StackListener {
DietListener(SourceLibraryBuilder library, this.elementStore, this.hierarchy,
this.coreTypes, this.astKind)
: library = library,
- memberScope = library.scope;
+ memberScope = library.scope,
+ isDartLibrary = library.uri.scheme == "dart";
@override
Uri get uri => library.uri;
@@ -454,6 +467,24 @@ class DietListener extends StackListener {
checkEmpty();
}
+ @override
+ Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) {
+ if (isDartLibrary && kind == ErrorKind.ExpectedBlockToSkip) {
+ Token recover = skipNativeClause(token);
+ if (recover != null) {
+ assert(isTargetingDartVm);
+ return recover;
+ }
+ }
+ return super.handleUnrecoverableError(token, kind, arguments);
+ }
+
+ @override
+ Link<Token> handleMemberName(Link<Token> identifiers) {
+ if (!isDartLibrary || identifiers.isEmpty) return identifiers;
+ return removeNativeClause(identifiers);
+ }
+
void parseFunctionBody(StackListener listener, Token token) {
try {
Parser parser = new Parser(listener);
@@ -528,4 +559,9 @@ class DietListener extends StackListener {
// print(" ${stack.join('\n ')}");
// print(name);
}
+
+ bool get isTargetingDartVm {
+ // TODO(ahe): Find a more reliable way to check if this is the Dart VM.
+ return coreTypes.getCoreLibrary("dart:_js_helper") == null;
+ }
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/outline.dart ('k') | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698