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

Side by Side Diff: dart/frog/leg/resolver.dart

Issue 9417031: Mock up all remaining core library implementation classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/frog/leg/lib/mockimpl.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 } 8 }
9 9
10 class TreeElementMapping implements TreeElements { 10 class TreeElementMapping implements TreeElements {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 name = name.replaceFirst(cls.name.toString(), 116 name = name.replaceFirst(cls.name.toString(),
117 defaultClass.name.toString()); 117 defaultClass.name.toString());
118 constructor.implementation = 118 constructor.implementation =
119 defaultClass.lookupConstructor(new SourceString(name)); 119 defaultClass.lookupConstructor(new SourceString(name));
120 120
121 if (constructor.implementation === null 121 if (constructor.implementation === null
122 && new SourceString(name) == defaultClass.name 122 && new SourceString(name) == defaultClass.name
123 && constructor.functionParameters.parameterCount === 0) { 123 && constructor.functionParameters.parameterCount === 0) {
124 constructor.implementation = defaultClass.getSynthesizedConstructor(); 124 constructor.implementation = defaultClass.getSynthesizedConstructor();
125 } 125 }
126 }
127 if (constructor === null) {
128 error(node.send, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node.send]);
129 return null;
130 }
131 126
132 if (constructor.implementation === null) { 127 if (constructor.implementation === null) {
133 error(node, MessageKind.CANNOT_FIND_CONSTRUCTOR, [name]); 128 error(node, MessageKind.CANNOT_FIND_CONSTRUCTOR, [name]);
129 }
134 } 130 }
135 } 131 }
136 132
137 TreeElements resolveVariableElement(Element element) { 133 TreeElements resolveVariableElement(Element element) {
138 Node tree = element.parseNode(compiler); 134 Node tree = element.parseNode(compiler);
139 ResolverVisitor visitor = new ResolverVisitor(compiler, element); 135 ResolverVisitor visitor = new ResolverVisitor(compiler, element);
140 if (tree is SendSet) { 136 if (tree is SendSet) {
141 SendSet send = tree; 137 SendSet send = tree;
142 visitor.visit(send.arguments.head); 138 visitor.visit(send.arguments.head);
143 } 139 }
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 Element target = null; 650 Element target = null;
655 if (node.selector.asIdentifier() === null) { 651 if (node.selector.asIdentifier() === null) {
656 // We are calling a closure returned from an expression. 652 // We are calling a closure returned from an expression.
657 assert(node.selector.asExpression() !== null); 653 assert(node.selector.asExpression() !== null);
658 assert(resolvedReceiver === null); 654 assert(resolvedReceiver === null);
659 visit(node.selector); 655 visit(node.selector);
660 } else { 656 } else {
661 SourceString name = node.selector.asIdentifier().source; 657 SourceString name = node.selector.asIdentifier().source;
662 if (node.receiver === null) { 658 if (node.receiver === null) {
663 target = lookup(node, name); 659 target = lookup(node, name);
664 if (target === null && !enclosingElement.isInstanceMember()) { 660 if (target === null && !inInstanceContext) {
665 error(node, MessageKind.CANNOT_RESOLVE, [name]); 661 error(node, MessageKind.CANNOT_RESOLVE, [name]);
666 } 662 }
667 } else if (node.isSuperCall) { 663 } else if (node.isSuperCall) {
668 if (currentClass !== null) { 664 if (currentClass !== null) {
669 ClassElement superElement = currentClass.superclass; 665 ClassElement superElement = currentClass.superclass;
670 if (superElement !== null) { 666 if (superElement !== null) {
671 // TODO(ngeoffray): The lookup should continue on super 667 // TODO(ngeoffray): The lookup should continue on super
672 // classes. 668 // classes.
673 target = superElement.lookupLocalMember(name); 669 target = superElement.lookupLocalMember(name);
674 } 670 }
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 element = new VariableElement(node.selector.asIdentifier().source, 1223 element = new VariableElement(node.selector.asIdentifier().source,
1228 variables, ElementKind.PARAMETER, enclosingElement, node: node); 1224 variables, ElementKind.PARAMETER, enclosingElement, node: node);
1229 } 1225 }
1230 // Visit the value. The compile time constant handler will 1226 // Visit the value. The compile time constant handler will
1231 // make sure it's a compile time constant. 1227 // make sure it's a compile time constant.
1232 resolveExpression(node.arguments.head); 1228 resolveExpression(node.arguments.head);
1233 compiler.enqueue(new WorkItem.toCompile(element)); 1229 compiler.enqueue(new WorkItem.toCompile(element));
1234 return element; 1230 return element;
1235 } 1231 }
1236 1232
1233 Element visitFunctionExpression(FunctionExpression node) {
1234 // This is a function typed parameter.
1235 // TODO(ahe): Resolve the function type.
1236 return visit(node.name);
1237 }
1238
1237 LinkBuilder<Element> analyzeNodes(Link<Node> link) { 1239 LinkBuilder<Element> analyzeNodes(Link<Node> link) {
1238 LinkBuilder<Element> elements = new LinkBuilder<Element>(); 1240 LinkBuilder<Element> elements = new LinkBuilder<Element>();
1239 for (; !link.isEmpty(); link = link.tail) { 1241 for (; !link.isEmpty(); link = link.tail) {
1240 Element element = link.head.accept(this); 1242 Element element = link.head.accept(this);
1241 if (element != null) { 1243 if (element != null) {
1242 elements.addLast(element); 1244 elements.addLast(element);
1243 } else { 1245 } else {
1244 // If parameter is null, the current node should be the last, 1246 // If parameter is null, the current node should be the last,
1245 // and a list of optional named parameters. 1247 // and a list of optional named parameters.
1246 if (!link.tail.isEmpty() || (link.head is !NodeList)) { 1248 if (!link.tail.isEmpty() || (link.head is !NodeList)) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 class TopScope extends Scope { 1338 class TopScope extends Scope {
1337 LibraryElement get library() => element; 1339 LibraryElement get library() => element;
1338 1340
1339 TopScope(LibraryElement library) : super(null, library); 1341 TopScope(LibraryElement library) : super(null, library);
1340 Element lookup(SourceString name) => library.find(name); 1342 Element lookup(SourceString name) => library.find(name);
1341 1343
1342 Element add(Element element) { 1344 Element add(Element element) {
1343 throw "Cannot add an element in the top scope"; 1345 throw "Cannot add an element in the top scope";
1344 } 1346 }
1345 } 1347 }
OLDNEW
« no previous file with comments | « dart/frog/leg/lib/mockimpl.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698