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

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

Issue 2915153002: Follow up improvement for checking dart:_builtin (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 final bool isInstanceMember; 78 final bool isInstanceMember;
79 79
80 final Map<String, FieldInitializer> fieldInitializers = 80 final Map<String, FieldInitializer> fieldInitializers =
81 <String, FieldInitializer>{}; 81 <String, FieldInitializer>{};
82 82
83 final Scope enclosingScope; 83 final Scope enclosingScope;
84 84
85 final bool enableNative; 85 final bool enableNative;
86 86
87 final bool isPlatformLibrary; 87 final bool isBuiltinLibrary;
88 88
89 @override 89 @override
90 final Uri uri; 90 final Uri uri;
91 91
92 final TypeInferrer _typeInferrer; 92 final TypeInferrer _typeInferrer;
93 93
94 @override 94 @override
95 final TypePromoter<Expression, VariableDeclaration> typePromoter; 95 final TypePromoter<Expression, VariableDeclaration> typePromoter;
96 96
97 /// Only used when [member] is a constructor. It tracks if an implicit super 97 /// Only used when [member] is a constructor. It tracks if an implicit super
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 this.formalParameterScope, 139 this.formalParameterScope,
140 this.hierarchy, 140 this.hierarchy,
141 this.coreTypes, 141 this.coreTypes,
142 this.classBuilder, 142 this.classBuilder,
143 this.isInstanceMember, 143 this.isInstanceMember,
144 this.uri, 144 this.uri,
145 this._typeInferrer) 145 this._typeInferrer)
146 : enclosingScope = scope, 146 : enclosingScope = scope,
147 library = library, 147 library = library,
148 enableNative = library.loader.target.enableNative(library), 148 enableNative = library.loader.target.enableNative(library),
149 isPlatformLibrary = library.uri.scheme == 'dart', 149 isBuiltinLibrary =
150 library.uri.scheme == 'dart' && library.uri.path == "_builtin",
150 needsImplicitSuperInitializer = 151 needsImplicitSuperInitializer =
151 coreTypes.objectClass != classBuilder?.cls, 152 coreTypes.objectClass != classBuilder?.cls,
152 typePromoter = _typeInferrer.typePromoter, 153 typePromoter = _typeInferrer.typePromoter,
153 super(scope); 154 super(scope);
154 155
155 bool get hasParserError => recoverableErrors.isNotEmpty; 156 bool get hasParserError => recoverableErrors.isNotEmpty;
156 157
157 bool get inConstructor { 158 bool get inConstructor {
158 return functionNestingLevel == 0 && member is KernelConstructorBuilder; 159 return functionNestingLevel == 0 && member is KernelConstructorBuilder;
159 } 160 }
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 builder == null && 898 builder == null &&
898 "loadLibrary" == name) { 899 "loadLibrary" == name) {
899 return buildCompileTimeError( 900 return buildCompileTimeError(
900 "Deferred loading isn't implemented yet.", offsetForToken(token)); 901 "Deferred loading isn't implemented yet.", offsetForToken(token));
901 } else if (!isQualified && isInstanceContext) { 902 } else if (!isQualified && isInstanceContext) {
902 assert(builder == null); 903 assert(builder == null);
903 if (constantExpressionRequired) { 904 if (constantExpressionRequired) {
904 return new UnresolvedAccessor(this, n, token); 905 return new UnresolvedAccessor(this, n, token);
905 } 906 }
906 return new ThisPropertyAccessor(this, token, n, null, null); 907 return new ThisPropertyAccessor(this, token, n, null, null);
907 } else if ( 908 } else if (isBuiltinLibrary &&
908 // Optimization, if [isPlatformLibrary] is false, this can't be 909 name == "main" &&
909 // dart:_builtin. 910 member?.name == "_getMainClosure") {
910 isPlatformLibrary &&
911 name == "main" &&
912 library.uri.path == "_builtin" &&
913 member?.name == "_getMainClosure") {
914 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 911 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989
915 return new KernelNullLiteral()..fileOffset = offsetForToken(token); 912 return new KernelNullLiteral()..fileOffset = offsetForToken(token);
916 } else { 913 } else {
917 return new UnresolvedAccessor(this, n, token); 914 return new UnresolvedAccessor(this, n, token);
918 } 915 }
919 } else if (builder.isTypeDeclaration) { 916 } else if (builder.isTypeDeclaration) {
920 if (constantExpressionRequired && 917 if (constantExpressionRequired &&
921 builder.isTypeVariable && 918 builder.isTypeVariable &&
922 !member.isConstructor) { 919 !member.isConstructor) {
923 addCompileTimeError( 920 addCompileTimeError(
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 if (starToken == null) { 3272 if (starToken == null) {
3276 return AsyncMarker.Async; 3273 return AsyncMarker.Async;
3277 } else { 3274 } else {
3278 assert(identical(starToken.stringValue, "*")); 3275 assert(identical(starToken.stringValue, "*"));
3279 return AsyncMarker.AsyncStar; 3276 return AsyncMarker.AsyncStar;
3280 } 3277 }
3281 } else { 3278 } else {
3282 return internalError("Unknown async modifier: $asyncToken"); 3279 return internalError("Unknown async modifier: $asyncToken");
3283 } 3280 }
3284 } 3281 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698