Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart b/dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| index bd96b3c213f3c1645620a7fd7953ddbff3774b02..ab67af2877756055cd87bdb058d8b1415be3563d 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart |
| @@ -208,6 +208,8 @@ abstract class Node extends TreeElementMixin implements Spannable { |
| bool isValidContinueTarget() => false; |
| bool isThis() => false; |
| bool isSuper() => false; |
| + |
| + bool get isErroneous => false; |
| } |
| class ClassNode extends Node { |
| @@ -325,6 +327,8 @@ class ErrorExpression extends LiteralNull { |
| : super(token); |
| ErrorExpression asErrorExpression() => this; |
| + |
| + bool get isErroneous => true; |
| } |
| /** |
| @@ -415,10 +419,11 @@ class Send extends Expression { |
| return null; |
| } |
| if (!isPostfix && argumentsNode != null) { |
| - return argumentsNode.getEndToken(); |
| + Token token = argumentsNode.getEndToken(); |
| + if (token != null) return token; |
| } |
| if (selector != null) return selector.getEndToken(); |
| - return receiver.getBeginToken(); |
| + return getBeginToken(); |
| } |
| Send copyWithReceiver(Node newReceiver) { |
| @@ -558,8 +563,10 @@ class NodeList extends Node { |
| Link<Node> link = nodes; |
| if (link.isEmpty) return beginToken; |
| while (!link.tail.isEmpty) link = link.tail; |
| - if (link.head.getEndToken() != null) return link.head.getEndToken(); |
| - if (link.head.getBeginToken() != null) return link.head.getBeginToken(); |
| + if (link.head != null) { |
|
Johnni Winther
2014/06/17 06:13:18
Add a variable for `link.head`.
ahe
2014/06/18 06:52:53
Done.
|
| + if (link.head.getEndToken() != null) return link.head.getEndToken(); |
| + if (link.head.getBeginToken() != null) return link.head.getBeginToken(); |
| + } |
| } |
| return beginToken; |
| } |
| @@ -2114,3 +2121,56 @@ class IsInterpolationVisitor extends Visitor<bool> { |
| => node.isInterpolation; |
| } |
| +/// Errorneous node used to recover from parser errors. Implements various |
|
Johnni Winther
2014/06/17 06:13:18
'Errorneous' -> 'Erroneous'
ahe
2014/06/18 06:52:52
Done.
|
| +/// interfaces and provides bare minimum of implementation to avoid unnecessary |
| +/// messages. |
| +class ErrorNode |
| + extends Node |
| + implements FunctionExpression, VariableDefinitions, Typedef { |
| + final Token token; |
| + final String reason; |
| + final Identifier name; |
| + final NodeList definitions; |
| + |
| + ErrorNode.internal(this.token, this.reason, this.name, this.definitions); |
| + |
| + factory ErrorNode(Token token, String reason) { |
| + Identifier name = new Identifier(token); |
| + NodeList definitions = new NodeList( |
| + null, const Link<Node>().prepend(name), null, null); |
| + return new ErrorNode.internal(token, reason, name, definitions); |
| + } |
| + |
| + Token get beginToken => token; |
| + Token get endToken => token; |
| + |
| + Token getBeginToken() => token; |
| + |
| + Token getEndToken() => token; |
| + |
| + accept(Visitor visitor) {} |
| + |
| + visitChildren(Visitor visitor) {} |
| + |
| + bool get isErroneous => true; |
| + |
| + // FunctionExpression. |
| + get parameters => null; |
| + get body => null; |
| + get returnType => null; |
| + get modifiers => Modifiers.EMPTY; |
| + get initializers => null; |
| + get getOrSet => null; |
| + get isRedirectingFactory => false; |
| + bool hasBody() => false; |
| + bool hasEmptyBody() => false; |
| + |
| + // VariableDefinitions. |
| + get metadata => null; |
| + get type => null; |
| + |
| + // Typedef. |
| + get typeParameters => null; |
| + get formals => null; |
| + get typedefKeyword => null; |
| +} |