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

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

Issue 2976543002: Reapply "Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service."" (Closed)
Patch Set: fix Created 3 years, 5 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.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show 8 show
9 FastaMessage, 9 FastaMessage,
10 codeConstFieldWithoutInitializer, 10 codeConstFieldWithoutInitializer,
11 codeExpectedButGot, 11 codeExpectedButGot,
12 codeExpectedFunctionBody, 12 codeExpectedFunctionBody,
13 codeFinalFieldWithoutInitializer; 13 codeFinalFieldWithoutInitializer;
14 14
15 import '../parser/parser.dart' 15 import '../parser/parser.dart'
16 show Assert, FormalParameterType, MemberKind, optional; 16 show Assert, FormalParameterType, MemberKind, optional;
17 17
18 import '../parser/identifier_context.dart' show IdentifierContext; 18 import '../parser/identifier_context.dart' show IdentifierContext;
19 19
20 import '../parser/native_support.dart' show skipNativeClause;
21
20 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; 22 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
21 23
22 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; 24 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
23 25
24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' 26 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'
25 show TypeInferrer; 27 show TypeInferrer;
26 28
27 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' 29 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'
28 show TypePromoter; 30 show TypePromoter;
29 31
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 final ClassHierarchy hierarchy; 89 final ClassHierarchy hierarchy;
88 90
89 final CoreTypes coreTypes; 91 final CoreTypes coreTypes;
90 92
91 final bool isInstanceMember; 93 final bool isInstanceMember;
92 94
93 final Scope enclosingScope; 95 final Scope enclosingScope;
94 96
95 final bool enableNative; 97 final bool enableNative;
98 final bool stringExpectedAfterNative;
96 99
97 /// Whether to ignore an unresolved reference to `main` within the body of 100 /// Whether to ignore an unresolved reference to `main` within the body of
98 /// `_getMainClosure` when compiling the current library. 101 /// `_getMainClosure` when compiling the current library.
99 /// 102 ///
100 /// This as a temporary workaround. The standalone VM and flutter have 103 /// This as a temporary workaround. The standalone VM and flutter have
101 /// special logic to resolve `main` in `_getMainClosure`, this flag is used to 104 /// special logic to resolve `main` in `_getMainClosure`, this flag is used to
102 /// ignore that reference to `main`, but only on libraries where we expect to 105 /// ignore that reference to `main`, but only on libraries where we expect to
103 /// see it (today that is dart:_builtin and dart:ui). 106 /// see it (today that is dart:_builtin and dart:ui).
104 /// 107 ///
105 // TODO(ahe,sigmund): remove when the VM gets rid of the special rule, see 108 // TODO(ahe,sigmund): remove when the VM gets rid of the special rule, see
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 Scope scope, 176 Scope scope,
174 this.formalParameterScope, 177 this.formalParameterScope,
175 this.hierarchy, 178 this.hierarchy,
176 this.coreTypes, 179 this.coreTypes,
177 this.classBuilder, 180 this.classBuilder,
178 this.isInstanceMember, 181 this.isInstanceMember,
179 this.uri, 182 this.uri,
180 this._typeInferrer) 183 this._typeInferrer)
181 : enclosingScope = scope, 184 : enclosingScope = scope,
182 library = library, 185 library = library,
183 enableNative = library.loader.target.enableNative(library), 186 enableNative =
187 library.loader.target.backendTarget.enableNative(library.uri),
188 stringExpectedAfterNative =
189 library.loader.target.backendTarget.nativeExtensionExpectsString,
184 ignoreMainInGetMainClosure = library.uri.scheme == 'dart' && 190 ignoreMainInGetMainClosure = library.uri.scheme == 'dart' &&
185 (library.uri.path == "_builtin" || library.uri.path == "ui"), 191 (library.uri.path == "_builtin" || library.uri.path == "ui"),
186 needsImplicitSuperInitializer = 192 needsImplicitSuperInitializer =
187 coreTypes.objectClass != classBuilder?.cls, 193 coreTypes.objectClass != classBuilder?.cls,
188 typePromoter = _typeInferrer.typePromoter, 194 typePromoter = _typeInferrer.typePromoter,
189 super(scope); 195 super(scope);
190 196
191 bool get hasParserError => recoverableErrors.isNotEmpty; 197 bool get hasParserError => recoverableErrors.isNotEmpty;
192 198
193 bool get inConstructor { 199 bool get inConstructor {
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 void handleRecoverableError(Token token, FastaMessage message) { 3000 void handleRecoverableError(Token token, FastaMessage message) {
2995 bool silent = hasParserError || 3001 bool silent = hasParserError ||
2996 message.code == codeFinalFieldWithoutInitializer || 3002 message.code == codeFinalFieldWithoutInitializer ||
2997 message.code == codeConstFieldWithoutInitializer; 3003 message.code == codeConstFieldWithoutInitializer;
2998 addCompileTimeError(message.charOffset, message.message, silent: silent); 3004 addCompileTimeError(message.charOffset, message.message, silent: silent);
2999 } 3005 }
3000 3006
3001 @override 3007 @override
3002 Token handleUnrecoverableError(Token token, FastaMessage message) { 3008 Token handleUnrecoverableError(Token token, FastaMessage message) {
3003 if (enableNative && message.code == codeExpectedFunctionBody) { 3009 if (enableNative && message.code == codeExpectedFunctionBody) {
3004 Token recover = library.loader.target.skipNativeClause(token); 3010 Token recover = skipNativeClause(token, stringExpectedAfterNative);
3005 if (recover != null) return recover; 3011 if (recover != null) return recover;
3006 } else if (message.code == codeExpectedButGot) { 3012 } else if (message.code == codeExpectedButGot) {
3007 String expected = message.arguments["string"]; 3013 String expected = message.arguments["string"];
3008 const List<String> trailing = const <String>[")", "}", ";", ","]; 3014 const List<String> trailing = const <String>[")", "}", ";", ","];
3009 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { 3015 if (trailing.contains(token.stringValue) && trailing.contains(expected)) {
3010 handleRecoverableError(token, message); 3016 handleRecoverableError(token, message);
3011 return newSyntheticToken(token); 3017 return newSyntheticToken(token);
3012 } 3018 }
3013 } 3019 }
3014 return super.handleUnrecoverableError(token, message); 3020 return super.handleUnrecoverableError(token, message);
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3722 if (starToken == null) { 3728 if (starToken == null) {
3723 return AsyncMarker.Async; 3729 return AsyncMarker.Async;
3724 } else { 3730 } else {
3725 assert(identical(starToken.stringValue, "*")); 3731 assert(identical(starToken.stringValue, "*"));
3726 return AsyncMarker.AsyncStar; 3732 return AsyncMarker.AsyncStar;
3727 } 3733 }
3728 } else { 3734 } else {
3729 return internalError("Unknown async modifier: $asyncToken"); 3735 return internalError("Unknown async modifier: $asyncToken");
3730 } 3736 }
3731 } 3737 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698