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 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
9 | 9 |
10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 /// Look up [name] in [scope] using [token] as location information (both to | 1056 /// Look up [name] in [scope] using [token] as location information (both to |
1057 /// report problems and as the file offset in the generated kernel code). | 1057 /// report problems and as the file offset in the generated kernel code). |
1058 /// [isQualified] should be true if [name] is a qualified access | 1058 /// [isQualified] should be true if [name] is a qualified access |
1059 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] | 1059 /// (which implies that it shouldn't be turned into a [ThisPropertyAccessor] |
1060 /// if the name doesn't resolve in the scope). | 1060 /// if the name doesn't resolve in the scope). |
1061 @override | 1061 @override |
1062 scopeLookup(Scope scope, String name, Token token, | 1062 scopeLookup(Scope scope, String name, Token token, |
1063 {bool isQualified: false, PrefixBuilder prefix}) { | 1063 {bool isQualified: false, PrefixBuilder prefix}) { |
1064 Builder builder = scope.lookup(name, offsetForToken(token), uri); | 1064 Builder builder = scope.lookup(name, offsetForToken(token), uri); |
1065 if (builder != null && member.isField && builder.isInstanceMember) { | 1065 if (builder != null && member.isField && builder.isInstanceMember) { |
1066 return new deprecated_IncompleteError(this, token, | 1066 return new IncompleteError(this, token, |
1067 "Can't access 'this' in a field initializer to read '$name'."); | 1067 fasta.templateThisAccessInFieldInitializer.withArguments(name)); |
1068 } | 1068 } |
1069 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { | 1069 if (builder == null || (!isInstanceContext && builder.isInstanceMember)) { |
1070 Name n = new Name(name, library.library); | 1070 Name n = new Name(name, library.library); |
1071 if (prefix != null && | 1071 if (prefix != null && |
1072 prefix.deferred && | 1072 prefix.deferred && |
1073 builder == null && | 1073 builder == null && |
1074 "loadLibrary" == name) { | 1074 "loadLibrary" == name) { |
1075 int offset = offsetForToken(token); | 1075 int offset = offsetForToken(token); |
1076 const String message = "Deferred loading isn't implemented yet."; | 1076 const String message = "Deferred loading isn't implemented yet."; |
1077 // We report the error twice, the first time silently and marking it as | 1077 // We report the error twice, the first time silently and marking it as |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 debugEvent("TypeArguments"); | 2368 debugEvent("TypeArguments"); |
2369 push(popList(count)); | 2369 push(popList(count)); |
2370 } | 2370 } |
2371 | 2371 |
2372 @override | 2372 @override |
2373 void handleThisExpression(Token token, IdentifierContext context) { | 2373 void handleThisExpression(Token token, IdentifierContext context) { |
2374 debugEvent("ThisExpression"); | 2374 debugEvent("ThisExpression"); |
2375 if (context.isScopeReference && isInstanceContext) { | 2375 if (context.isScopeReference && isInstanceContext) { |
2376 push(new ThisAccessor(this, token, inInitializer)); | 2376 push(new ThisAccessor(this, token, inInitializer)); |
2377 } else { | 2377 } else { |
2378 push(new deprecated_IncompleteError( | 2378 push(new IncompleteError(this, token, fasta.messageThisAsIdentifier)); |
2379 this, token, "Expected identifier, but got 'this'.")); | |
2380 } | 2379 } |
2381 } | 2380 } |
2382 | 2381 |
2383 @override | 2382 @override |
2384 void handleSuperExpression(Token token, IdentifierContext context) { | 2383 void handleSuperExpression(Token token, IdentifierContext context) { |
2385 debugEvent("SuperExpression"); | 2384 debugEvent("SuperExpression"); |
2386 if (context.isScopeReference && isInstanceContext) { | 2385 if (context.isScopeReference && isInstanceContext) { |
2387 Member member = this.member.target; | 2386 Member member = this.member.target; |
2388 member.transformerFlags |= TransformerFlag.superCalls; | 2387 member.transformerFlags |= TransformerFlag.superCalls; |
2389 push(new ThisAccessor(this, token, inInitializer, isSuper: true)); | 2388 push(new ThisAccessor(this, token, inInitializer, isSuper: true)); |
2390 } else { | 2389 } else { |
2391 push(new deprecated_IncompleteError( | 2390 push(new IncompleteError(this, token, fasta.messageSuperAsIdentifier)); |
2392 this, token, "Expected identifier, but got 'super'.")); | |
2393 } | 2391 } |
2394 } | 2392 } |
2395 | 2393 |
2396 @override | 2394 @override |
2397 void handleNamedArgument(Token colon) { | 2395 void handleNamedArgument(Token colon) { |
2398 debugEvent("NamedArgument"); | 2396 debugEvent("NamedArgument"); |
2399 Expression value = popForValue(); | 2397 Expression value = popForValue(); |
2400 Identifier identifier = pop(); | 2398 Identifier identifier = pop(); |
2401 push(new NamedExpression(identifier.name, value) | 2399 push(new NamedExpression(identifier.name, value) |
2402 ..fileOffset = offsetForToken(identifier.token)); | 2400 ..fileOffset = offsetForToken(identifier.token)); |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 return AsyncMarker.Async; | 3827 return AsyncMarker.Async; |
3830 } else { | 3828 } else { |
3831 assert(identical(starToken.stringValue, "*")); | 3829 assert(identical(starToken.stringValue, "*")); |
3832 return AsyncMarker.AsyncStar; | 3830 return AsyncMarker.AsyncStar; |
3833 } | 3831 } |
3834 } else { | 3832 } else { |
3835 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3833 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3836 asyncToken.charOffset, null); | 3834 asyncToken.charOffset, null); |
3837 } | 3835 } |
3838 } | 3836 } |
OLD | NEW |