| 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.diet_listener; | 5 library fasta.diet_listener; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/kernel/kernel_ast_factory.dart' | 7 import 'package:front_end/src/fasta/kernel/kernel_ast_factory.dart' |
| 8 show KernelAstFactory; | 8 show KernelAstFactory; |
| 9 | 9 |
| 10 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart' | 10 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart' |
| 11 show TypeInferenceEngine; | 11 show TypeInferenceEngine; |
| 12 | 12 |
| 13 import 'package:kernel/ast.dart' show AsyncMarker; | 13 import 'package:kernel/ast.dart' show AsyncMarker; |
| 14 | 14 |
| 15 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 15 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
| 16 | 16 |
| 17 import 'package:kernel/core_types.dart' show CoreTypes; | 17 import 'package:kernel/core_types.dart' show CoreTypes; |
| 18 | 18 |
| 19 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip; | 19 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip; |
| 20 | 20 |
| 21 import '../parser/parser.dart' show Parser, optional; | 21 import '../parser/parser.dart' show Parser, optional; |
| 22 | 22 |
| 23 import '../scanner/token.dart' show BeginGroupToken, Token; | 23 import '../scanner/token.dart' show BeginGroupToken, Token; |
| 24 | 24 |
| 25 import '../parser/dart_vm_native.dart' | 25 import '../parser/dart_vm_native.dart' show removeNativeClause; |
| 26 show removeNativeClause, skipNativeClause; | |
| 27 | 26 |
| 28 import '../util/link.dart' show Link; | 27 import '../util/link.dart' show Link; |
| 29 | 28 |
| 30 import '../errors.dart' show Crash, InputError, inputError, internalError; | 29 import '../errors.dart' show Crash, InputError, inputError, internalError; |
| 31 | 30 |
| 32 import 'stack_listener.dart' show StackListener; | 31 import 'stack_listener.dart' show StackListener; |
| 33 | 32 |
| 34 import '../kernel/body_builder.dart' show BodyBuilder; | 33 import '../kernel/body_builder.dart' show BodyBuilder; |
| 35 | 34 |
| 36 import '../builder/builder.dart'; | 35 import '../builder/builder.dart'; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 void endNamedMixinApplication(Token beginToken, Token classKeyword, | 475 void endNamedMixinApplication(Token beginToken, Token classKeyword, |
| 477 Token equals, Token implementsKeyword, Token endToken) { | 476 Token equals, Token implementsKeyword, Token endToken) { |
| 478 debugEvent("NamedMixinApplication"); | 477 debugEvent("NamedMixinApplication"); |
| 479 pop(); // Name. | 478 pop(); // Name. |
| 480 checkEmpty(beginToken.charOffset); | 479 checkEmpty(beginToken.charOffset); |
| 481 } | 480 } |
| 482 | 481 |
| 483 @override | 482 @override |
| 484 Token handleUnrecoverableError(Token token, FastaMessage message) { | 483 Token handleUnrecoverableError(Token token, FastaMessage message) { |
| 485 if (isDartLibrary && message.code == codeExpectedBlockToSkip) { | 484 if (isDartLibrary && message.code == codeExpectedBlockToSkip) { |
| 486 Token recover = skipNativeClause(token); | 485 Token recover = library.loader.target.skipNativeClause(token); |
| 487 if (recover != null) { | 486 if (recover != null) return recover; |
| 488 assert(isTargetingDartVm); | |
| 489 return recover; | |
| 490 } | |
| 491 } | 487 } |
| 492 return super.handleUnrecoverableError(token, message); | 488 return super.handleUnrecoverableError(token, message); |
| 493 } | 489 } |
| 494 | 490 |
| 495 @override | 491 @override |
| 496 Link<Token> handleMemberName(Link<Token> identifiers) { | 492 Link<Token> handleMemberName(Link<Token> identifiers) { |
| 497 if (!isDartLibrary || identifiers.isEmpty) return identifiers; | 493 if (!isDartLibrary || identifiers.isEmpty) return identifiers; |
| 498 return removeNativeClause(identifiers); | 494 return removeNativeClause(identifiers); |
| 499 } | 495 } |
| 500 | 496 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 } | 558 } |
| 563 if (builder == null) { | 559 if (builder == null) { |
| 564 return internalError("Builder not found: $name", uri, token.charOffset); | 560 return internalError("Builder not found: $name", uri, token.charOffset); |
| 565 } | 561 } |
| 566 if (builder.next != null) { | 562 if (builder.next != null) { |
| 567 return inputError(uri, token.charOffset, "Duplicated name: $name"); | 563 return inputError(uri, token.charOffset, "Duplicated name: $name"); |
| 568 } | 564 } |
| 569 return builder; | 565 return builder; |
| 570 } | 566 } |
| 571 | 567 |
| 572 bool get isTargetingDartVm { | |
| 573 // TODO(ahe): Find a more reliable way to check if this is the Dart VM. | |
| 574 return !coreTypes.containsLibrary("dart:_js_helper"); | |
| 575 } | |
| 576 | |
| 577 @override | 568 @override |
| 578 void debugEvent(String name) { | 569 void debugEvent(String name) { |
| 579 // printEvent(name); | 570 // printEvent(name); |
| 580 } | 571 } |
| 581 } | 572 } |
| OLD | NEW |