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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // }}`. In this case, we want two errors, the `x` in `print(x)` and the | 338 // }}`. In this case, we want two errors, the `x` in `print(x)` and the |
339 // second (or innermost declaration) of `x`. | 339 // second (or innermost declaration) of `x`. |
340 discardedStatement = pop(); // TODO(ahe): Issue 29717. | 340 discardedStatement = pop(); // TODO(ahe): Issue 29717. |
341 | 341 |
342 // Reports the error on the last declaration of `x`. | 342 // Reports the error on the last declaration of `x`. |
343 push(deprecated_buildCompileTimeErrorStatement( | 343 push(deprecated_buildCompileTimeErrorStatement( |
344 "Can't declare '$name' because it was already used in this scope.", | 344 "Can't declare '$name' because it was already used in this scope.", |
345 offset)); | 345 offset)); |
346 | 346 |
347 // Reports the error on `print(x)`. | 347 // Reports the error on `print(x)`. |
348 library.deprecated_addCompileTimeError(error.charOffset, error.error, | 348 library.addCompileTimeError( |
349 fileUri: error.uri); | 349 fasta.templateUnspecified.withArguments(error.error), |
| 350 error.charOffset, |
| 351 error.uri); |
350 } | 352 } |
351 } | 353 } |
352 | 354 |
353 @override | 355 @override |
354 JumpTarget createJumpTarget(JumpTargetKind kind, int charOffset) { | 356 JumpTarget createJumpTarget(JumpTargetKind kind, int charOffset) { |
355 return new JumpTarget(kind, functionNestingLevel, member, charOffset); | 357 return new JumpTarget(kind, functionNestingLevel, member, charOffset); |
356 } | 358 } |
357 | 359 |
358 @override | 360 @override |
359 void beginMetadata(Token token) { | 361 void beginMetadata(Token token) { |
(...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 void handleSymbolVoid(Token token) { | 3249 void handleSymbolVoid(Token token) { |
3248 debugEvent("SymbolVoid"); | 3250 debugEvent("SymbolVoid"); |
3249 push(new Identifier(token)); | 3251 push(new Identifier(token)); |
3250 } | 3252 } |
3251 | 3253 |
3252 @override | 3254 @override |
3253 dynamic deprecated_addCompileTimeError(int charOffset, String message, | 3255 dynamic deprecated_addCompileTimeError(int charOffset, String message, |
3254 {bool silent: false, bool wasHandled: false}) { | 3256 {bool silent: false, bool wasHandled: false}) { |
3255 // TODO(ahe): If constantExpressionRequired is set, set it to false to | 3257 // TODO(ahe): If constantExpressionRequired is set, set it to false to |
3256 // avoid a long list of errors. | 3258 // avoid a long list of errors. |
3257 return library.deprecated_addCompileTimeError(charOffset, message, | 3259 return library.addCompileTimeError( |
3258 fileUri: uri, silent: silent, wasHandled: wasHandled); | 3260 fasta.templateUnspecified.withArguments(message), charOffset, uri, |
| 3261 silent: silent, wasHandled: wasHandled); |
3259 } | 3262 } |
3260 | 3263 |
3261 @override | 3264 @override |
3262 void handleInvalidFunctionBody(Token token) { | 3265 void handleInvalidFunctionBody(Token token) { |
3263 if (member.isNative) { | 3266 if (member.isNative) { |
3264 push(NullValue.FunctionBody); | 3267 push(NullValue.FunctionBody); |
3265 } else { | 3268 } else { |
3266 push(new Block(<Statement>[ | 3269 push(new Block(<Statement>[ |
3267 deprecated_buildCompileTimeErrorStatement( | 3270 deprecated_buildCompileTimeErrorStatement( |
3268 "Expected '{'.", token.charOffset) | 3271 "Expected '{'.", token.charOffset) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3350 ..fileOffset = offset; | 3353 ..fileOffset = offset; |
3351 } else { | 3354 } else { |
3352 return new KernelMethodInvocation(receiver, name, arguments, | 3355 return new KernelMethodInvocation(receiver, name, arguments, |
3353 isImplicitCall: isImplicitCall) | 3356 isImplicitCall: isImplicitCall) |
3354 ..fileOffset = offset; | 3357 ..fileOffset = offset; |
3355 } | 3358 } |
3356 } | 3359 } |
3357 | 3360 |
3358 @override | 3361 @override |
3359 void addCompileTimeError(Message message, int charOffset) { | 3362 void addCompileTimeError(Message message, int charOffset) { |
3360 library.deprecated_addCompileTimeError(charOffset, message.message, | 3363 library.addCompileTimeError(message, charOffset, uri); |
3361 fileUri: uri); | |
3362 } | 3364 } |
3363 | 3365 |
3364 @override | 3366 @override |
3365 void debugEvent(String name) { | 3367 void debugEvent(String name) { |
3366 // printEvent(name); | 3368 // printEvent(name); |
3367 } | 3369 } |
3368 | 3370 |
3369 @override | 3371 @override |
3370 StaticGet makeStaticGet(Member readTarget, Token token) { | 3372 StaticGet makeStaticGet(Member readTarget, Token token) { |
3371 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); | 3373 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 return AsyncMarker.Async; | 3829 return AsyncMarker.Async; |
3828 } else { | 3830 } else { |
3829 assert(identical(starToken.stringValue, "*")); | 3831 assert(identical(starToken.stringValue, "*")); |
3830 return AsyncMarker.AsyncStar; | 3832 return AsyncMarker.AsyncStar; |
3831 } | 3833 } |
3832 } else { | 3834 } else { |
3833 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3835 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3834 asyncToken.charOffset, null); | 3836 asyncToken.charOffset, null); |
3835 } | 3837 } |
3836 } | 3838 } |
OLD | NEW |