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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
| 88 |
87 @override | 89 @override |
88 final Uri uri; | 90 final Uri uri; |
89 | 91 |
90 final TypeInferrer _typeInferrer; | 92 final TypeInferrer _typeInferrer; |
91 | 93 |
92 @override | 94 @override |
93 final TypePromoter<Expression, VariableDeclaration> typePromoter; | 95 final TypePromoter<Expression, VariableDeclaration> typePromoter; |
94 | 96 |
95 /// 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 |
96 /// initializer is needed. | 98 /// initializer is needed. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 Scope scope, | 138 Scope scope, |
137 this.formalParameterScope, | 139 this.formalParameterScope, |
138 this.hierarchy, | 140 this.hierarchy, |
139 this.coreTypes, | 141 this.coreTypes, |
140 this.classBuilder, | 142 this.classBuilder, |
141 this.isInstanceMember, | 143 this.isInstanceMember, |
142 this.uri, | 144 this.uri, |
143 this._typeInferrer) | 145 this._typeInferrer) |
144 : enclosingScope = scope, | 146 : enclosingScope = scope, |
145 library = library, | 147 library = library, |
146 enableNative = (library.uri.scheme == "dart" || library.isPatch), | 148 enableNative = library.loader.target.enableNative(library), |
| 149 isPlatformLibrary = library.uri.scheme == 'dart', |
147 needsImplicitSuperInitializer = | 150 needsImplicitSuperInitializer = |
148 coreTypes.objectClass != classBuilder?.cls, | 151 coreTypes.objectClass != classBuilder?.cls, |
149 typePromoter = _typeInferrer.typePromoter, | 152 typePromoter = _typeInferrer.typePromoter, |
150 super(scope); | 153 super(scope); |
151 | 154 |
152 bool get hasParserError => recoverableErrors.isNotEmpty; | 155 bool get hasParserError => recoverableErrors.isNotEmpty; |
153 | 156 |
154 bool get inConstructor { | 157 bool get inConstructor { |
155 return functionNestingLevel == 0 && member is KernelConstructorBuilder; | 158 return functionNestingLevel == 0 && member is KernelConstructorBuilder; |
156 } | 159 } |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 "loadLibrary" == name) { | 901 "loadLibrary" == name) { |
899 return buildCompileTimeError( | 902 return buildCompileTimeError( |
900 "Deferred loading isn't implemented yet.", offsetForToken(token)); | 903 "Deferred loading isn't implemented yet.", offsetForToken(token)); |
901 } else if (!isQualified && isInstanceContext) { | 904 } else if (!isQualified && isInstanceContext) { |
902 assert(builder == null); | 905 assert(builder == null); |
903 if (constantExpressionRequired) { | 906 if (constantExpressionRequired) { |
904 return new UnresolvedAccessor(this, n, token); | 907 return new UnresolvedAccessor(this, n, token); |
905 } | 908 } |
906 return new ThisPropertyAccessor(this, token, n, null, null); | 909 return new ThisPropertyAccessor(this, token, n, null, null); |
907 } else if ( | 910 } else if ( |
908 // Optimization, if [enableNative] is false, this can't be | 911 // Optimization, if [isPlatformLibrary] is false, this can't be |
909 // dart:_builtin. | 912 // dart:_builtin. |
910 enableNative && | 913 isPlatformLibrary && |
911 name == "main" && | 914 name == "main" && |
912 library.uri.scheme == "dart" && | |
913 library.uri.path == "_builtin" && | 915 library.uri.path == "_builtin" && |
914 member?.name == "_getMainClosure") { | 916 member?.name == "_getMainClosure") { |
915 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 | 917 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28989 |
916 return new KernelNullLiteral()..fileOffset = offsetForToken(token); | 918 return new KernelNullLiteral()..fileOffset = offsetForToken(token); |
917 } else { | 919 } else { |
918 return new UnresolvedAccessor(this, n, token); | 920 return new UnresolvedAccessor(this, n, token); |
919 } | 921 } |
920 } else if (builder.isTypeDeclaration) { | 922 } else if (builder.isTypeDeclaration) { |
921 if (constantExpressionRequired && | 923 if (constantExpressionRequired && |
922 builder.isTypeVariable && | 924 builder.isTypeVariable && |
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 if (starToken == null) { | 3278 if (starToken == null) { |
3277 return AsyncMarker.Async; | 3279 return AsyncMarker.Async; |
3278 } else { | 3280 } else { |
3279 assert(identical(starToken.stringValue, "*")); | 3281 assert(identical(starToken.stringValue, "*")); |
3280 return AsyncMarker.AsyncStar; | 3282 return AsyncMarker.AsyncStar; |
3281 } | 3283 } |
3282 } else { | 3284 } else { |
3283 return internalError("Unknown async modifier: $asyncToken"); | 3285 return internalError("Unknown async modifier: $asyncToken"); |
3284 } | 3286 } |
3285 } | 3287 } |
OLD | NEW |