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

Unified Diff: frog/leg/scanner/class_element_parser.dart

Issue 9027002: Support factory methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | « frog/leg/resolver.dart ('k') | frog/leg/scanner/listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/scanner/class_element_parser.dart
===================================================================
--- frog/leg/scanner/class_element_parser.dart (revision 2754)
+++ frog/leg/scanner/class_element_parser.dart (working copy)
@@ -48,7 +48,7 @@
pushNode(null);
Identifier name = method.name; // TODO(ahe): Named constructors.
ElementKind kind = isConstructor(name) ?
- ElementKind.CONSTRUCTOR :
+ ElementKind.GENERATIVE_CONSTRUCTOR :
ElementKind.FUNCTION;
Element memberElement =
new PartialFunctionElement(name.source, beginToken, endToken,
@@ -56,6 +56,23 @@
enclosingElement.addMember(memberElement);
}
+ void endFactoryMethod(Token factoryKeyword, Token periodBeforeName,
+ Token endToken) {
+ super.endFactoryMethod(factoryKeyword, periodBeforeName, endToken);
+ FunctionExpression method = popNode();
+ pushNode(null);
+ // TODO(ahe): Named constructors.
+ if (method.name.asIdentifier() == null) {
+ canceler.cancel('Qualified factory names not implemented', node: method);
+ }
+ Identifier name = method.name;
+ ElementKind kind = ElementKind.FUNCTION;
+ Element memberElement =
+ new PartialFunctionElement(name.source, factoryKeyword, endToken, kind,
+ method.modifiers, enclosingElement);
+ enclosingElement.addMember(memberElement);
+ }
+
void endFields(int count, Token beginToken, Token endToken) {
super.endFields(count, beginToken, endToken);
VariableDefinitions variableDefinitions = popNode();
« no previous file with comments | « frog/leg/resolver.dart ('k') | frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698