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, optional; | 10 import '../parser/parser.dart' show FormalParameterType, optional; |
(...skipping 21 matching lines...) Expand all Loading... |
32 import 'package:kernel/clone.dart' show CloneVisitor; | 32 import 'package:kernel/clone.dart' show CloneVisitor; |
33 | 33 |
34 import 'package:kernel/transformations/flags.dart' show TransformerFlag; | 34 import 'package:kernel/transformations/flags.dart' show TransformerFlag; |
35 | 35 |
36 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 36 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
37 | 37 |
38 import 'package:kernel/core_types.dart' show CoreTypes; | 38 import 'package:kernel/core_types.dart' show CoreTypes; |
39 | 39 |
40 import 'frontend_accessors.dart' show buildIsNull, makeBinary, makeLet; | 40 import 'frontend_accessors.dart' show buildIsNull, makeBinary, makeLet; |
41 | 41 |
| 42 import '../parser/dart_vm_native.dart' show skipNativeClause; |
| 43 |
42 import '../scanner/token.dart' | 44 import '../scanner/token.dart' |
43 show BeginGroupToken, Token, isBinaryOperator, isMinusOperator; | 45 show BeginGroupToken, Token, isBinaryOperator, isMinusOperator; |
44 | 46 |
45 import '../errors.dart' show formatUnexpected, internalError; | 47 import '../errors.dart' show formatUnexpected, internalError; |
46 | 48 |
47 import '../source/scope_listener.dart' | 49 import '../source/scope_listener.dart' |
48 show JumpTargetKind, NullValue, ScopeListener; | 50 show JumpTargetKind, NullValue, ScopeListener; |
49 | 51 |
50 import '../scope.dart' show ProblemBuilder; | 52 import '../scope.dart' show ProblemBuilder; |
51 | 53 |
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 @override | 2518 @override |
2517 void handleRecoverableError(Token token, FastaMessage message) { | 2519 void handleRecoverableError(Token token, FastaMessage message) { |
2518 bool silent = hasParserError; | 2520 bool silent = hasParserError; |
2519 super.handleRecoverableError(token, message); | 2521 super.handleRecoverableError(token, message); |
2520 addCompileTimeError(message.charOffset, message.message, silent: silent); | 2522 addCompileTimeError(message.charOffset, message.message, silent: silent); |
2521 } | 2523 } |
2522 | 2524 |
2523 @override | 2525 @override |
2524 Token handleUnrecoverableError(Token token, FastaMessage message) { | 2526 Token handleUnrecoverableError(Token token, FastaMessage message) { |
2525 if (isDartLibrary && message.code == codeExpectedFunctionBody) { | 2527 if (isDartLibrary && message.code == codeExpectedFunctionBody) { |
2526 Token recover = library.loader.target.skipNativeClause(token); | 2528 Token recover = skipNativeClause(token); |
2527 if (recover != null) return recover; | 2529 if (recover != null) return recover; |
2528 } else if (message.code == codeExpectedButGot) { | 2530 } else if (message.code == codeExpectedButGot) { |
2529 String expected = message.arguments["string"]; | 2531 String expected = message.arguments["string"]; |
2530 const List<String> trailing = const <String>[")", "}", ";", ","]; | 2532 const List<String> trailing = const <String>[")", "}", ";", ","]; |
2531 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { | 2533 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { |
2532 handleRecoverableError(token, message); | 2534 handleRecoverableError(token, message); |
2533 return newSyntheticToken(token); | 2535 return newSyntheticToken(token); |
2534 } | 2536 } |
2535 } | 2537 } |
2536 return super.handleUnrecoverableError(token, message); | 2538 return super.handleUnrecoverableError(token, message); |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 } else if (node is PrefixBuilder) { | 3129 } else if (node is PrefixBuilder) { |
3128 return node.name; | 3130 return node.name; |
3129 } else if (node is ThisAccessor) { | 3131 } else if (node is ThisAccessor) { |
3130 return node.isSuper ? "super" : "this"; | 3132 return node.isSuper ? "super" : "this"; |
3131 } else if (node is FastaAccessor) { | 3133 } else if (node is FastaAccessor) { |
3132 return node.plainNameForRead; | 3134 return node.plainNameForRead; |
3133 } else { | 3135 } else { |
3134 return internalError("Unhandled: ${node.runtimeType}"); | 3136 return internalError("Unhandled: ${node.runtimeType}"); |
3135 } | 3137 } |
3136 } | 3138 } |
OLD | NEW |