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; |
11 | 11 |
12 import 'package:kernel/clone.dart' show CloneVisitor; | 12 import 'package:kernel/clone.dart' show CloneVisitor; |
13 | 13 |
14 import 'package:kernel/core_types.dart' show CoreTypes; | 14 import 'package:kernel/core_types.dart' show CoreTypes; |
15 | 15 |
16 import 'package:kernel/transformations/flags.dart' show TransformerFlag; | 16 import 'package:kernel/transformations/flags.dart' show TransformerFlag; |
17 | 17 |
18 import '../../scanner/token.dart' show BeginToken, Token; | 18 import '../../scanner/token.dart' show BeginToken, Token; |
19 | 19 |
20 import '../deprecated_problems.dart' show deprecated_formatUnexpected; | |
21 | |
22 import '../fasta_codes.dart' as fasta; | 20 import '../fasta_codes.dart' as fasta; |
23 | 21 |
24 import '../fasta_codes.dart' show LocatedMessage, Message; | 22 import '../fasta_codes.dart' show LocatedMessage, Message; |
25 | 23 |
26 import '../messages.dart' as messages show getLocationFromUri; | 24 import '../messages.dart' as messages show getLocationFromUri; |
27 | 25 |
28 import '../modifier.dart' show Modifier, constMask, finalMask; | 26 import '../modifier.dart' show Modifier, constMask, finalMask; |
29 | 27 |
30 import '../parser/identifier_context.dart' show IdentifierContext; | 28 import '../parser/identifier_context.dart' show IdentifierContext; |
31 | 29 |
(...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 handleRecoverableError(token, message); | 3073 handleRecoverableError(token, message); |
3076 return newSyntheticToken(token); | 3074 return newSyntheticToken(token); |
3077 } | 3075 } |
3078 } | 3076 } |
3079 return super.handleUnrecoverableError(token, message); | 3077 return super.handleUnrecoverableError(token, message); |
3080 } | 3078 } |
3081 | 3079 |
3082 @override | 3080 @override |
3083 Expression deprecated_buildCompileTimeError(String error, | 3081 Expression deprecated_buildCompileTimeError(String error, |
3084 [int charOffset = -1]) { | 3082 [int charOffset = -1]) { |
3085 // TODO(ahe): This method should be passed the erroneous expression, wrap | 3083 return buildCompileTimeError( |
3086 // it in a class (TBD) from which the erroneous expression can be easily | 3084 fasta.templateUnspecified.withArguments(error), charOffset); |
3087 // extracted. Similar for statements and initializers. See also [issue | |
3088 // 29717](https://github.com/dart-lang/sdk/issues/29717) | |
3089 deprecated_addCompileTimeError(charOffset, error, wasHandled: true); | |
3090 return new KernelSyntheticExpression(library.loader | |
3091 .throwCompileConstantError(library.loader | |
3092 .deprecated_buildCompileTimeError( | |
3093 deprecated_formatUnexpected(uri, charOffset, error), | |
3094 charOffset))); | |
3095 } | 3085 } |
3096 | 3086 |
3097 @override | 3087 @override |
3098 Expression buildCompileTimeError(Message message, int charOffset) { | 3088 Expression buildCompileTimeError(Message message, int charOffset) { |
3099 // TODO(ahe): This method should be passed the erroneous expression, wrap | 3089 // TODO(ahe): This method should be passed the erroneous expression, wrap |
3100 // it in a class (TBD) from which the erroneous expression can be easily | 3090 // it in a class (TBD) from which the erroneous expression can be easily |
3101 // extracted. Similar for statements and initializers. See also [issue | 3091 // extracted. Similar for statements and initializers. See also [issue |
3102 // 29717](https://github.com/dart-lang/sdk/issues/29717) | 3092 // 29717](https://github.com/dart-lang/sdk/issues/29717) |
3103 deprecated_addCompileTimeError(charOffset, message.message, | 3093 library.addCompileTimeError(message, charOffset, uri, wasHandled: true); |
3104 wasHandled: true); | |
3105 return new KernelSyntheticExpression(library.loader | 3094 return new KernelSyntheticExpression(library.loader |
3106 .throwCompileConstantError(library.loader | 3095 .throwCompileConstantError( |
3107 .deprecated_buildCompileTimeError( | 3096 library.loader.buildCompileTimeError(message, charOffset, uri))); |
3108 deprecated_formatUnexpected(uri, charOffset, message.message), | |
3109 charOffset))); | |
3110 } | 3097 } |
3111 | 3098 |
3112 Expression deprecated_wrapInCompileTimeError( | 3099 Expression deprecated_wrapInCompileTimeError( |
3113 Expression expression, String message) { | 3100 Expression expression, String message) { |
3114 return new Let( | 3101 return new Let( |
3115 new VariableDeclaration.forValue(expression) | 3102 new VariableDeclaration.forValue(expression) |
3116 ..fileOffset = expression.fileOffset, | 3103 ..fileOffset = expression.fileOffset, |
3117 deprecated_buildCompileTimeError(message, expression.fileOffset)) | 3104 deprecated_buildCompileTimeError(message, expression.fileOffset)) |
3118 ..fileOffset = expression.fileOffset; | 3105 ..fileOffset = expression.fileOffset; |
3119 } | 3106 } |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3813 return AsyncMarker.Async; | 3800 return AsyncMarker.Async; |
3814 } else { | 3801 } else { |
3815 assert(identical(starToken.stringValue, "*")); | 3802 assert(identical(starToken.stringValue, "*")); |
3816 return AsyncMarker.AsyncStar; | 3803 return AsyncMarker.AsyncStar; |
3817 } | 3804 } |
3818 } else { | 3805 } else { |
3819 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3806 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3820 asyncToken.charOffset, null); | 3807 asyncToken.charOffset, null); |
3821 } | 3808 } |
3822 } | 3809 } |
OLD | NEW |