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

Unified Diff: sdk/lib/_internal/compiler/implementation/tree/nodes.dart

Issue 155703004: Support parameter metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/tree/nodes.dart
diff --git a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
index e64cbf6fee77e55f1d8871bd38abe1c20b792c94..80f0b13095b56604e9e676143fa33dc795e97de0 100644
--- a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
@@ -48,6 +48,7 @@ abstract class Visitor<R> {
R visitLiteralString(LiteralString node) => visitStringNode(node);
R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node);
R visitLoop(Loop node) => visitStatement(node);
+ R visitMetadata(Metadata node) => visitNode(node);
R visitMixinApplication(MixinApplication node) => visitNode(node);
R visitModifiers(Modifiers node) => visitNode(node);
R visitNamedArgument(NamedArgument node) => visitExpression(node);
@@ -173,6 +174,7 @@ abstract class Node extends TreeElementMixin implements Spannable {
LiteralNull asLiteralNull() => null;
LiteralString asLiteralString() => null;
LiteralSymbol asLiteralSymbol() => null;
+ Metadata asMetadata() => null;
MixinApplication asMixinApplication() => null;
Modifiers asModifiers() => null;
NamedArgument asNamedArgument() => null;
@@ -479,7 +481,7 @@ class SendSet extends Send {
}
class NewExpression extends Expression {
- /** The token NEW or CONST */
+ /** The token NEW or CONST or `null` for metadata */
final Token newToken;
// Note: we expect that send.receiver is null.
@@ -496,11 +498,10 @@ class NewExpression extends Expression {
}
bool isConst() {
- return identical(newToken.stringValue, 'const')
- || identical(newToken.stringValue, '@');
+ return newToken == null || identical(newToken.stringValue, 'const');
}
- Token getBeginToken() => newToken;
+ Token getBeginToken() => newToken != null ? newToken : send.getBeginToken();
Token getEndToken() => send.getEndToken();
}
@@ -1136,10 +1137,23 @@ class TypeVariable extends Node {
}
class VariableDefinitions extends Statement {
+ final NodeList metadata;
final TypeAnnotation type;
final Modifiers modifiers;
final NodeList definitions;
- VariableDefinitions(this.type, this.modifiers, this.definitions) {
+
+ VariableDefinitions(this.type,
+ this.modifiers,
+ this.definitions)
+ : this.metadata = null {
+ assert(modifiers != null);
+ }
+
+ // TODO(johnniwinther): Make this its own node type.
+ VariableDefinitions.forParameter(this.metadata,
+ this.type,
+ this.modifiers,
+ this.definitions) {
assert(modifiers != null);
}
@@ -2048,6 +2062,25 @@ class CatchBlock extends Node {
Token getEndToken() => block.getEndToken();
}
+class Metadata extends Node {
+ final Token token;
+ final Expression expression;
+
+ Metadata(this.token, this.expression);
+
+ Metadata asMetadata() => this;
+
+ accept(Visitor visitor) => visitor.visitMetadata(this);
+
+ visitChildren(Visitor visitor) {
+ expression.accept(visitor);
+ }
+
+ Token getBeginToken() => token;
+
+ Token getEndToken() => expression.getEndToken();
+}
+
class Initializers {
static bool isSuperConstructorCall(Send node) {
return (node.receiver == null && node.selector.isSuper()) ||

Powered by Google App Engine
This is Rietveld 408576698