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

Unified Diff: frog/leg/tree/nodes.dart

Issue 9616058: Implement parsing and resolving of type-variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/tree/nodes.dart
diff --git a/frog/leg/tree/nodes.dart b/frog/leg/tree/nodes.dart
index 7d066ff42172178f0c4c45ced9f9033107d32497..00d335c1633a922a1789c3cd7e96d8a007ad32b2 100644
--- a/frog/leg/tree/nodes.dart
+++ b/frog/leg/tree/nodes.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -46,6 +46,7 @@ interface Visitor<R> {
R visitTryStatement(TryStatement node);
R visitTypeAnnotation(TypeAnnotation node);
R visitTypedef(Typedef node);
+ R visitTypeVariable(TypeVariable node);
R visitVariableDefinitions(VariableDefinitions node);
R visitWhile(While node);
}
@@ -142,6 +143,7 @@ class Node implements Hashable {
TryStatement asTryStatement() => null;
TypeAnnotation asTypeAnnotation() => null;
Typedef asTypedef() => null;
+ TypeVariable asTypeVariable() => null;
VariableDefinitions asVariableDefinitions() => null;
While asWhile() => null;
@@ -153,6 +155,7 @@ class ClassNode extends Node {
final Identifier name;
final TypeAnnotation superclass;
final NodeList interfaces;
+ final NodeList typeParameters;
// Using a NodeList to record the keyword "default".
// TODO(ahe): Consider if there is a better way to represent this.
@@ -162,8 +165,9 @@ class ClassNode extends Node {
final Token extendsKeyword;
final Token endToken;
- ClassNode(this.name, this.superclass, this.interfaces, this.defaultClause,
- this.beginToken, this.extendsKeyword, this.endToken);
+ ClassNode(this.name, this.typeParameters, this.superclass, this.interfaces,
+ this.defaultClause, this.beginToken, this.extendsKeyword,
+ this.endToken);
ClassNode asClassNode() => this;
@@ -1070,6 +1074,29 @@ class TypeAnnotation extends Node {
Token getEndToken() => typeName.getEndToken();
}
+class TypeVariable extends Node {
+ final Identifier name;
+ final TypeAnnotation bound;
+ TypeVariable(Identifier this.name, TypeAnnotation this.bound);
+
+ accept(Visitor visitor) => visitor.visitTypeVariable(this);
+
+ visitChildren(Visitor visitor) {
+ name.accept(visitor);
+ if (bound !== null) {
+ bound.accept(visitor);
+ }
+ }
+
+ TypeVariable asTypeVariable() => this;
+
+ Token getBeginToken() => name.getBeginToken();
+
+ Token getEndToken() {
+ return (bound !== null) ? bound.getEndToken() : name.getEndToken();
+ }
+}
+
class VariableDefinitions extends Statement {
final Token endToken;
final TypeAnnotation type;

Powered by Google App Engine
This is Rietveld 408576698