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

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

Issue 2895983002: Read SDK and patches from a JSON file. (Closed)
Patch Set: Created 3 years, 7 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 FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9 9
10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 final CoreTypes coreTypes; 86 final CoreTypes coreTypes;
87 87
88 final bool isInstanceMember; 88 final bool isInstanceMember;
89 89
90 final Map<String, FieldInitializer> fieldInitializers = 90 final Map<String, FieldInitializer> fieldInitializers =
91 <String, FieldInitializer>{}; 91 <String, FieldInitializer>{};
92 92
93 final Scope enclosingScope; 93 final Scope enclosingScope;
94 94
95 final bool isDartLibrary; 95 final bool enableNative;
96 96
97 @override 97 @override
98 final Uri uri; 98 final Uri uri;
99 99
100 final TypeInferrer _typeInferrer; 100 final TypeInferrer _typeInferrer;
101 101
102 @override 102 @override
103 final AstFactory astFactory; 103 final AstFactory astFactory;
104 104
105 @override 105 @override
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 this.hierarchy, 156 this.hierarchy,
157 this.coreTypes, 157 this.coreTypes,
158 this.classBuilder, 158 this.classBuilder,
159 this.isInstanceMember, 159 this.isInstanceMember,
160 this.uri, 160 this.uri,
161 this._typeInferrer, 161 this._typeInferrer,
162 this.astFactory, 162 this.astFactory,
163 {this.fieldDependencies}) 163 {this.fieldDependencies})
164 : enclosingScope = scope, 164 : enclosingScope = scope,
165 library = library, 165 library = library,
166 isDartLibrary = library.uri.scheme == "dart", 166 enableNative = (library.uri.scheme == "dart" || library.isPatch),
167 needsImplicitSuperInitializer = 167 needsImplicitSuperInitializer =
168 coreTypes.objectClass != classBuilder?.cls, 168 coreTypes.objectClass != classBuilder?.cls,
169 typePromoter = _typeInferrer.typePromoter, 169 typePromoter = _typeInferrer.typePromoter,
170 super(scope); 170 super(scope);
171 171
172 bool get hasParserError => recoverableErrors.isNotEmpty; 172 bool get hasParserError => recoverableErrors.isNotEmpty;
173 173
174 bool get inConstructor { 174 bool get inConstructor {
175 return functionNestingLevel == 0 && member is KernelConstructorBuilder; 175 return functionNestingLevel == 0 && member is KernelConstructorBuilder;
176 } 176 }
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 builder == null && 863 builder == null &&
864 "loadLibrary" == name) { 864 "loadLibrary" == name) {
865 return buildCompileTimeError( 865 return buildCompileTimeError(
866 "Deferred loading isn't implemented yet.", offsetForToken(token)); 866 "Deferred loading isn't implemented yet.", offsetForToken(token));
867 } else if (!isQualified && isInstanceContext) { 867 } else if (!isQualified && isInstanceContext) {
868 assert(builder == null); 868 assert(builder == null);
869 if (constantExpressionRequired) { 869 if (constantExpressionRequired) {
870 return new UnresolvedAccessor(this, n, token); 870 return new UnresolvedAccessor(this, n, token);
871 } 871 }
872 return new ThisPropertyAccessor(this, token, n, null, null); 872 return new ThisPropertyAccessor(this, token, n, null, null);
873 } else if (isDartLibrary && 873 } else if (enableNative &&
Siggi Cherem (dart-lang) 2017/05/22 16:21:15 you probably don't need this one here
ahe 2017/05/22 16:26:47 It's an optimization.
874 name == "main" && 874 name == "main" &&
875 library.uri.scheme == "dart" &&
875 library.uri.path == "_builtin" && 876 library.uri.path == "_builtin" &&
876 member?.name == "_getMainClosure") { 877 member?.name == "_getMainClosure") {
Siggi Cherem (dart-lang) 2017/05/22 16:21:15 actually - can this be deleted now that we no long
ahe 2017/05/22 16:26:47 I'll investigate.
ahe 2017/05/24 16:09:46 No. The method still exists and refers to main (wh
877 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 878 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989
878 return astFactory.nullLiteral(token); 879 return astFactory.nullLiteral(token);
879 } else { 880 } else {
880 return new UnresolvedAccessor(this, n, token); 881 return new UnresolvedAccessor(this, n, token);
881 } 882 }
882 } else if (builder.isTypeDeclaration) { 883 } else if (builder.isTypeDeclaration) {
883 if (constantExpressionRequired && 884 if (constantExpressionRequired &&
884 builder.isTypeVariable && 885 builder.isTypeVariable &&
885 !member.isConstructor) { 886 !member.isConstructor) {
886 addCompileTimeError( 887 addCompileTimeError(
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2534 } 2535 }
2535 2536
2536 @override 2537 @override
2537 void handleRecoverableError(Token token, FastaMessage message) { 2538 void handleRecoverableError(Token token, FastaMessage message) {
2538 bool silent = hasParserError; 2539 bool silent = hasParserError;
2539 addCompileTimeError(message.charOffset, message.message, silent: silent); 2540 addCompileTimeError(message.charOffset, message.message, silent: silent);
2540 } 2541 }
2541 2542
2542 @override 2543 @override
2543 Token handleUnrecoverableError(Token token, FastaMessage message) { 2544 Token handleUnrecoverableError(Token token, FastaMessage message) {
2544 if (isDartLibrary && message.code == codeExpectedFunctionBody) { 2545 if (enableNative && message.code == codeExpectedFunctionBody) {
2545 Token recover = library.loader.target.skipNativeClause(token); 2546 Token recover = library.loader.target.skipNativeClause(token);
2546 if (recover != null) return recover; 2547 if (recover != null) return recover;
2547 } else if (message.code == codeExpectedButGot) { 2548 } else if (message.code == codeExpectedButGot) {
2548 String expected = message.arguments["string"]; 2549 String expected = message.arguments["string"];
2549 const List<String> trailing = const <String>[")", "}", ";", ","]; 2550 const List<String> trailing = const <String>[")", "}", ";", ","];
2550 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { 2551 if (trailing.contains(token.stringValue) && trailing.contains(expected)) {
2551 handleRecoverableError(token, message); 2552 handleRecoverableError(token, message);
2552 return newSyntheticToken(token); 2553 return newSyntheticToken(token);
2553 } 2554 }
2554 } 2555 }
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 if (starToken == null) { 3167 if (starToken == null) {
3167 return AsyncMarker.Async; 3168 return AsyncMarker.Async;
3168 } else { 3169 } else {
3169 assert(identical(starToken.stringValue, "*")); 3170 assert(identical(starToken.stringValue, "*"));
3170 return AsyncMarker.AsyncStar; 3171 return AsyncMarker.AsyncStar;
3171 } 3172 }
3172 } else { 3173 } else {
3173 return internalError("Unknown async modifier: $asyncToken"); 3174 return internalError("Unknown async modifier: $asyncToken");
3174 } 3175 }
3175 } 3176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698