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

Unified Diff: dart/frog/leg/resolver.dart

Issue 9315028: Support default values for optional parameters. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 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 | « dart/frog/leg/emitter.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/resolver.dart
===================================================================
--- dart/frog/leg/resolver.dart (revision 3790)
+++ dart/frog/leg/resolver.dart (working copy)
@@ -42,7 +42,8 @@
return resolveMethodElement(element);
case ElementKind.FIELD:
- return resolveFieldElement(element);
+ case ElementKind.PARAMETER:
+ return resolveVariableElement(element);
default:
compiler.unimplemented(
@@ -75,7 +76,7 @@
return visitor.mapping;
}
- TreeElements resolveFieldElement(Element element) {
+ TreeElements resolveVariableElement(Element element) {
Node tree = element.parseNode(compiler);
ResolverVisitor visitor = new FullResolverVisitor(compiler, element);
if (tree is SendSet) {
@@ -346,6 +347,14 @@
: new TopScope(compiler.universe),
this.currentClass = element.isMember() ? element.enclosingElement : null;
+ ResolverVisitor.from(ResolverVisitor other)
+ : this.compiler = other.compiler,
+ this.mapping = other.mapping,
+ this.enclosingElement = other.enclosingElement,
+ this.inInstanceContext = other.inInstanceContext,
+ this.context = other.context,
+ this.currentClass = other.currentClass;
+
void error(Node node, MessageKind kind, [arguments = const []]) {
ResolutionError error = new ResolutionError(kind, arguments);
compiler.reportError(node, error);
@@ -475,6 +484,8 @@
FullResolverVisitor(Compiler compiler, Element element)
: super(compiler, element);
+ FullResolverVisitor.from(ResolverVisitor other) : super.from(other);
+
Element visitClassNode(ClassNode node) {
cancel(node, "shouldn't be called");
}
@@ -1034,9 +1045,6 @@
}
Element visitSend(Send node) {
- if (node.receiver === null) {
- cancel(node, 'internal error: no receiver on a parameter send');
- }
Element element;
if (node.receiver.asIdentifier() === null ||
!node.receiver.asIdentifier().isThis()) {
@@ -1056,9 +1064,30 @@
error(node, MessageKind.NOT_INSTANCE_FIELD, [name]);
}
}
+ // TODO(ngeoffray): it's not right to put the field element in
+ // the parameters element. Create another element instead.
return element;
}
+ Element visitSendSet(SendSet node) {
+ Element element;
+ if (node.receiver != null) {
+ // TODO(ngeoffray): it's not right to put the field element in
+ // the parameters element. Create another element instead.
+ element = visitSend(node);
+ } else if (node.selector.asIdentifier() != null) {
+ Element variables = new VariableListElement.node(currentDefinitions,
+ ElementKind.VARIABLE_LIST, enclosingElement);
+ element = new VariableElement(node.selector.asIdentifier().source,
+ variables, ElementKind.PARAMETER, enclosingElement, node: node);
+ }
+ // Visit the value. The compile time constant handler will
+ // make sure it's a compile time constant.
+ new FullResolverVisitor.from(this).visit(node.arguments.head);
+ compiler.enqueue(new WorkItem.toCompile(element));
+ return element;
+ }
+
Element visit(Node node) {
if (node == null) return null;
return node.accept(this);
« no previous file with comments | « dart/frog/leg/emitter.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698