OLD | NEW |
---|---|
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 this.formalParameterScope, | 144 this.formalParameterScope, |
145 this.hierarchy, | 145 this.hierarchy, |
146 this.coreTypes, | 146 this.coreTypes, |
147 this.classBuilder, | 147 this.classBuilder, |
148 this.isInstanceMember, | 148 this.isInstanceMember, |
149 this.uri, | 149 this.uri, |
150 this._typeInferrer, | 150 this._typeInferrer, |
151 {this.fieldDependencies}) | 151 {this.fieldDependencies}) |
152 : enclosingScope = scope, | 152 : enclosingScope = scope, |
153 library = library, | 153 library = library, |
154 enableNative = (library.uri.scheme == "dart" || library.isPatch), | 154 enableNative = library.loader.target.enableNative(library), |
155 needsImplicitSuperInitializer = | 155 needsImplicitSuperInitializer = |
156 coreTypes.objectClass != classBuilder?.cls, | 156 coreTypes.objectClass != classBuilder?.cls, |
157 typePromoter = _typeInferrer.typePromoter, | 157 typePromoter = _typeInferrer.typePromoter, |
158 super(scope); | 158 super(scope); |
159 | 159 |
160 bool get hasParserError => recoverableErrors.isNotEmpty; | 160 bool get hasParserError => recoverableErrors.isNotEmpty; |
161 | 161 |
162 bool get inConstructor { | 162 bool get inConstructor { |
163 return functionNestingLevel == 0 && member is KernelConstructorBuilder; | 163 return functionNestingLevel == 0 && member is KernelConstructorBuilder; |
164 } | 164 } |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 "Deferred loading isn't implemented yet.", offsetForToken(token)); | 904 "Deferred loading isn't implemented yet.", offsetForToken(token)); |
905 } else if (!isQualified && isInstanceContext) { | 905 } else if (!isQualified && isInstanceContext) { |
906 assert(builder == null); | 906 assert(builder == null); |
907 if (constantExpressionRequired) { | 907 if (constantExpressionRequired) { |
908 return new UnresolvedAccessor(this, n, token); | 908 return new UnresolvedAccessor(this, n, token); |
909 } | 909 } |
910 return new ThisPropertyAccessor(this, token, n, null, null); | 910 return new ThisPropertyAccessor(this, token, n, null, null); |
911 } else if ( | 911 } else if ( |
912 // Optimization, if [enableNative] is false, this can't be | 912 // Optimization, if [enableNative] is false, this can't be |
913 // dart:_builtin. | 913 // dart:_builtin. |
914 enableNative && | 914 enableNative && |
Siggi Cherem (dart-lang)
2017/05/30 20:33:59
let me know if you want to drop this optimization
ahe
2017/05/31 09:07:50
It's not an optimization anymore. I think we shoul
Siggi Cherem (dart-lang)
2017/05/31 20:26:14
done. Any reason why not take it a step further an
ahe
2017/06/01 12:20:51
That's a good idea.
| |
915 name == "main" && | 915 name == "main" && |
916 library.uri.scheme == "dart" && | 916 library.uri.scheme == "dart" && |
917 library.uri.path == "_builtin" && | 917 library.uri.path == "_builtin" && |
918 member?.name == "_getMainClosure") { | 918 member?.name == "_getMainClosure") { |
919 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 | 919 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 |
920 return new KernelNullLiteral()..fileOffset = offsetForToken(token); | 920 return new KernelNullLiteral()..fileOffset = offsetForToken(token); |
921 } else { | 921 } else { |
922 return new UnresolvedAccessor(this, n, token); | 922 return new UnresolvedAccessor(this, n, token); |
923 } | 923 } |
924 } else if (builder.isTypeDeclaration) { | 924 } else if (builder.isTypeDeclaration) { |
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3241 if (starToken == null) { | 3241 if (starToken == null) { |
3242 return AsyncMarker.Async; | 3242 return AsyncMarker.Async; |
3243 } else { | 3243 } else { |
3244 assert(identical(starToken.stringValue, "*")); | 3244 assert(identical(starToken.stringValue, "*")); |
3245 return AsyncMarker.AsyncStar; | 3245 return AsyncMarker.AsyncStar; |
3246 } | 3246 } |
3247 } else { | 3247 } else { |
3248 return internalError("Unknown async modifier: $asyncToken"); | 3248 return internalError("Unknown async modifier: $asyncToken"); |
3249 } | 3249 } |
3250 } | 3250 } |
OLD | NEW |