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

Unified Diff: compiler/java/com/google/dart/compiler/ast/DartMethodDefinition.java

Issue 10872087: Syntactic support for redirecting factory constructors (issue 3968) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/DartParser.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/ast/DartMethodDefinition.java
===================================================================
--- compiler/java/com/google/dart/compiler/ast/DartMethodDefinition.java (revision 11396)
+++ compiler/java/com/google/dart/compiler/ast/DartMethodDefinition.java (working copy)
@@ -30,6 +30,19 @@
}
}
+ public static DartMethodDefinition create(DartExpression name,
+ DartFunction function,
+ Modifiers modifiers,
+ DartTypeNode redirectedTypeName,
+ DartIdentifier redirectedConstructorName) {
+ if (redirectedTypeName == null) {
+ return new DartMethodDefinition(name, function, modifiers);
+ } else {
+ return new DartMethodWithRedirectionDefinition(name, function, modifiers, redirectedTypeName,
+ redirectedConstructorName);
+ }
+ }
+
private DartMethodDefinition(DartExpression name, DartFunction function, Modifiers modifiers) {
super(name, modifiers);
this.function = becomeParentOf(function);
@@ -53,6 +66,14 @@
return Collections.emptyList();
}
+ public DartTypeNode getRedirectedTypeName() {
+ return null;
+ }
+
+ public DartIdentifier getRedirectedConstructorName() {
+ return null;
+ }
+
@Override
public void visitChildren(ASTVisitor<?> visitor) {
super.visitChildren(visitor);
@@ -87,4 +108,35 @@
initializers.accept(visitor);
}
}
+
+ private static class DartMethodWithRedirectionDefinition extends DartMethodDefinition {
+ private DartTypeNode redirectedTypeName;
+ private DartIdentifier redirectedConstructorName;
+
+ DartMethodWithRedirectionDefinition(DartExpression name,
+ DartFunction function,
+ Modifiers modifiers,
+ DartTypeNode redirectedTypeName,
+ DartIdentifier redirectedConstructorName) {
+ super(name, function, modifiers);
+ this.redirectedTypeName = becomeParentOf(redirectedTypeName);
+ }
+
+ @Override
+ public DartTypeNode getRedirectedTypeName() {
+ return redirectedTypeName;
+ }
+
+ @Override
+ public DartIdentifier getRedirectedConstructorName() {
+ return redirectedConstructorName;
+ }
+
+ @Override
+ public void visitChildren(ASTVisitor<?> visitor) {
+ super.visitChildren(visitor);
+ safelyVisitChild(redirectedTypeName, visitor);
+ safelyVisitChild(redirectedConstructorName, visitor);
+ }
+ }
}
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/DartParser.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698