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

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: Make a single begin/endRedirectingFactoryBody method in listener. 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..2f9b67a284bae52c00e8042f49be8f9430d1c0ea 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -250,6 +250,12 @@ class Listener {
Token beginToken, Token endToken) {
}
+ void beginRedirectingFactoryBody(Token token) {
+ }
+
+ void endRedirectingFactoryBody(Token start, Token dot, Token end) {
ahe 2012/09/26 14:51:09 Not sure this is "dot". You're using a different n
Lasse Reichstein Nielsen 2012/09/27 11:50:59 Switched to periodBeforeName everywhere.
+ }
+
void beginReturnStatement(Token token) {
}
@@ -1157,6 +1163,23 @@ class NodeListener extends ElementListener {
pushNode(null);
}
+ void endRedirectingFactoryBody(Token start, Token namePartStart, Token end) {
ahe 2012/09/26 14:51:09 What is namePartStart? Should it be periodBeforeNa
Lasse Reichstein Nielsen 2012/09/27 11:50:59 Done.
+ // This generates code for '= Type<T>.foo' that is similar to
ahe 2012/09/26 14:51:09 code -> nodes
Lasse Reichstein Nielsen 2012/09/27 11:50:59 Done.
+ // '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 (namePartStart != null) {
+ Identifier name = target;
+ TypeAnnotation type = popNode();
+ target = new Send(type, name);
+ }
+ NewExpression newExpression =
+ new NewExpression(start, new Send(null, target, noArguments));
+ 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