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

Unified Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10957060: First stab at parsing redirecting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 3 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: lib/compiler/implementation/scanner/listener.dart
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 3298428766a661c10ad6f2cbe62d4ec997f1dd80..8bb34c604a4e37a260194cc19cefa1f3587862e9 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -250,6 +250,14 @@ class Listener {
Token beginToken, Token endToken) {
}
+ void beginRedirectingFactoryBody(Token token) {
+ }
+
+ void endRedirectingFactoryBody(Token start,
+ Token periodBeforeName,
+ Token end) {
+ }
+
void beginReturnStatement(Token token) {
}
@@ -1157,6 +1165,25 @@ class NodeListener extends ElementListener {
pushNode(null);
}
+ void endRedirectingFactoryBody(Token start,
+ Token periodBeforeName,
+ Token end) {
+ // This generates nodes for '= Type<T>.foo' that are similar to
+ // 'return new Type<T>.foo()'. It is recognizable by having
+ // the '=' token as starting token for both the Return and
+ // the NewExpression objects.
+ NodeList noArguments = new NodeList.empty();
+ Node target = popNode();
+ if (periodBeforeName != null) {
+ Identifier name = target;
+ TypeAnnotation type = popNode();
+ target = new Send(type, name);
+ }
+ NewExpression newExpression =
+ new NewExpression(start, new Send(null, target, noArguments));
ahe 2012/10/05 08:23:20 We can't have the same token in two AST node. I t
Lasse Reichstein Nielsen 2012/10/09 09:46:54 That's ... problematic. We might need a new AST no
+ pushNode(new Return(start, end, newExpression));
+ }
+
void endReturnStatement(bool hasExpression,
Token beginToken, Token endToken) {
Expression expression = hasExpression ? popNode() : null;

Powered by Google App Engine
This is Rietveld 408576698