Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2717673002: Use printUnexpected and add location information. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:front_end/src/fasta/parser/parser.dart' show 7 import 'package:front_end/src/fasta/parser/parser.dart' show
8 FormalParameterType, 8 FormalParameterType,
9 optional; 9 optional;
10 10
(...skipping 19 matching lines...) Expand all
30 import '../parser/dart_vm_native.dart' show 30 import '../parser/dart_vm_native.dart' show
31 skipNativeClause; 31 skipNativeClause;
32 32
33 import 'package:front_end/src/fasta/scanner/token.dart' show 33 import 'package:front_end/src/fasta/scanner/token.dart' show
34 BeginGroupToken, 34 BeginGroupToken,
35 Token, 35 Token,
36 isBinaryOperator, 36 isBinaryOperator,
37 isMinusOperator; 37 isMinusOperator;
38 38
39 import '../errors.dart' show 39 import '../errors.dart' show
40 InputError,
41 internalError, 40 internalError,
42 printUnexpected; 41 printUnexpected;
43 42
44 import '../source/scope_listener.dart' show 43 import '../source/scope_listener.dart' show
45 JumpTargetKind, 44 JumpTargetKind,
46 NullValue, 45 NullValue,
47 ScopeListener; 46 ScopeListener;
48 47
49 import '../builder/scope.dart' show 48 import '../builder/scope.dart' show
50 AccessErrorBuilder, 49 AccessErrorBuilder,
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 } else { 1569 } else {
1571 name = ""; 1570 name = "";
1572 } 1571 }
1573 push(type); 1572 push(type);
1574 push(typeArguments ?? NullValue.TypeArguments); 1573 push(typeArguments ?? NullValue.TypeArguments);
1575 push(name); 1574 push(name);
1576 } 1575 }
1577 1576
1578 @override 1577 @override
1579 Expression buildStaticInvocation(Member target, Arguments arguments, 1578 Expression buildStaticInvocation(Member target, Arguments arguments,
1580 {bool isConst: false}) { 1579 {bool isConst: false, int charOffset: -1}) {
1581 List<TypeParameter> typeParameters = target.function.typeParameters; 1580 List<TypeParameter> typeParameters = target.function.typeParameters;
1582 if (target is Constructor) { 1581 if (target is Constructor) {
1583 typeParameters = target.enclosingClass.typeParameters; 1582 typeParameters = target.enclosingClass.typeParameters;
1584 } 1583 }
1585 if (!addDefaultArguments(target.function, arguments, typeParameters)) { 1584 if (!addDefaultArguments(target.function, arguments, typeParameters)) {
1586 return throwNoSuchMethodError(target.name.name, arguments, -1); 1585 return throwNoSuchMethodError(target.name.name, arguments, charOffset);
1587 } 1586 }
1588 if (target is Constructor) { 1587 if (target is Constructor) {
1589 return new ConstructorInvocation(target, arguments) 1588 return new ConstructorInvocation(target, arguments)
1590 ..isConst = isConst; 1589 ..isConst = isConst;
1591 } else { 1590 } else {
1592 return new StaticInvocation(target, arguments) 1591 return new StaticInvocation(target, arguments)
1593 ..isConst = isConst; 1592 ..isConst = isConst;
1594 } 1593 }
1595 } 1594 }
1596 1595
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (target == null) { 1686 if (target == null) {
1688 push(buildCompileTimeError( 1687 push(buildCompileTimeError(
1689 "Cyclic definition of factory '${name}'.", 1688 "Cyclic definition of factory '${name}'.",
1690 token.charOffset)); 1689 token.charOffset));
1691 return; 1690 return;
1692 } 1691 }
1693 } 1692 }
1694 if (target is Constructor || 1693 if (target is Constructor ||
1695 (target is Procedure && target.kind == ProcedureKind.Factory)) { 1694 (target is Procedure && target.kind == ProcedureKind.Factory)) {
1696 push(buildStaticInvocation( 1695 push(buildStaticInvocation(
1697 target, arguments, isConst: optional("const", token))); 1696 target, arguments, isConst: optional("const", token),
1697 charOffset: token.charOffset));
1698 return; 1698 return;
1699 } else { 1699 } else {
1700 errorName = debugName(type.name, name); 1700 errorName = debugName(type.name, name);
1701 } 1701 }
1702 } else { 1702 } else {
1703 errorName = debugName(getNodeName(type), name); 1703 errorName = debugName(getNodeName(type), name);
1704 } 1704 }
1705 errorName ??= name; 1705 errorName ??= name;
1706 push(throwNoSuchMethodError(errorName, arguments, token.charOffset)); 1706 push(throwNoSuchMethodError(errorName, arguments, token.charOffset));
1707 } 1707 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 void handleModifiers(int count) { 2188 void handleModifiers(int count) {
2189 debugEvent("Modifiers"); 2189 debugEvent("Modifiers");
2190 // TODO(ahe): Copied from outline_builder.dart. 2190 // TODO(ahe): Copied from outline_builder.dart.
2191 push(popList(count) ?? NullValue.Modifiers); 2191 push(popList(count) ?? NullValue.Modifiers);
2192 } 2192 }
2193 2193
2194 @override 2194 @override
2195 void handleRecoverableError(Token token, ErrorKind kind, Map arguments) { 2195 void handleRecoverableError(Token token, ErrorKind kind, Map arguments) {
2196 super.handleRecoverableError(token, kind, arguments); 2196 super.handleRecoverableError(token, kind, arguments);
2197 if (!hasParserError) { 2197 if (!hasParserError) {
2198 print(new InputError(uri, recoverableErrors.last.beginOffset, 2198 printUnexpected(uri, recoverableErrors.last.beginOffset,
2199 recoverableErrors.last.kind).format()); 2199 '${recoverableErrors.last.kind}');
2200 } 2200 }
2201 hasParserError = true; 2201 hasParserError = true;
2202 } 2202 }
2203 2203
2204 @override 2204 @override
2205 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) { 2205 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) {
2206 if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) { 2206 if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) {
2207 Token recover = skipNativeClause(token); 2207 Token recover = skipNativeClause(token);
2208 if (recover != null) return recover; 2208 if (recover != null) return recover;
2209 } else if (kind == ErrorKind.UnexpectedToken) { 2209 } else if (kind == ErrorKind.UnexpectedToken) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 } else if (node is TypeDeclarationBuilder) { 2703 } else if (node is TypeDeclarationBuilder) {
2704 return node.name; 2704 return node.name;
2705 } else if (node is PrefixBuilder) { 2705 } else if (node is PrefixBuilder) {
2706 return node.name; 2706 return node.name;
2707 } else if (node is ThisPropertyAccessor) { 2707 } else if (node is ThisPropertyAccessor) {
2708 return node.name.name; 2708 return node.name.name;
2709 } else { 2709 } else {
2710 return internalError("Unhandled: ${node.runtimeType}"); 2710 return internalError("Unhandled: ${node.runtimeType}");
2711 } 2711 }
2712 } 2712 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/errors.dart ('k') | pkg/front_end/lib/src/fasta/kernel/builder_accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698