Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class TreeElements { | 5 class TreeElements { |
| 6 Map<Node, Element> map; | 6 Map<Node, Element> map; |
| 7 TreeElements() : map = new LinkedHashMap<Node, Element>(); | 7 TreeElements() : map = new LinkedHashMap<Node, Element>(); |
| 8 operator []=(Node node, Element element) => map[node] = element; | 8 operator []=(Node node, Element element) => map[node] = element; |
| 9 operator [](Node node) => map[node]; | 9 operator [](Node node) => map[node]; |
| 10 } | 10 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 target = compiler.universe.find(opName); | 301 target = compiler.universe.find(opName); |
| 302 } else if (node.receiver === null) { | 302 } else if (node.receiver === null) { |
| 303 target = context.lookup(name); | 303 target = context.lookup(name); |
| 304 if (target == null && !enclosingElement.isInstanceMember()) { | 304 if (target == null && !enclosingElement.isInstanceMember()) { |
| 305 error(node, MessageKind.CANNOT_RESOLVE, [name]); | 305 error(node, MessageKind.CANNOT_RESOLVE, [name]); |
| 306 } | 306 } |
| 307 } else if (receiver === null) { | 307 } else if (receiver === null) { |
| 308 return null; | 308 return null; |
| 309 } else if (receiver.kind === ElementKind.CLASS) { | 309 } else if (receiver.kind === ElementKind.CLASS) { |
| 310 ClassElement receiverClass = receiver; | 310 ClassElement receiverClass = receiver; |
| 311 target = receiverClass.lookupLocalElement(name); | 311 target = receiverClass.resolve(compiler).lookupLocalElement(name); |
|
ngeoffray
2011/12/21 13:17:06
I will deal with lookupLocalElement -> lookupEleme
| |
| 312 if (target == null) { | 312 if (target == null) { |
| 313 error(node, MessageKind.METHOD_NOT_FOUND, [receiver, name]); | 313 error(node, MessageKind.METHOD_NOT_FOUND, [receiver, name]); |
| 314 } else if (target.isInstanceMember()) { | 314 } else if (target.isInstanceMember()) { |
| 315 error(node, MessageKind.MEMBER_NOT_STATIC, [receiver, name]); | 315 error(node, MessageKind.MEMBER_NOT_STATIC, [receiver, name]); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 return target; | 318 return target; |
| 319 } | 319 } |
| 320 | 320 |
| 321 visitSend(Send node) { | 321 visitSend(Send node) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 } | 405 } |
| 406 | 406 |
| 407 visitNewExpression(NewExpression node) { | 407 visitNewExpression(NewExpression node) { |
| 408 visit(node.send.argumentsNode); | 408 visit(node.send.argumentsNode); |
| 409 | 409 |
| 410 ClassElement cls = visit(node.send.selector); | 410 ClassElement cls = visit(node.send.selector); |
| 411 Element constructor = null; | 411 Element constructor = null; |
| 412 if (cls !== null) { | 412 if (cls !== null) { |
| 413 // TODO(ngeoffray): set constructor-name correctly. | 413 // TODO(ngeoffray): set constructor-name correctly. |
| 414 SourceString name = cls.name; | 414 SourceString name = cls.name; |
| 415 // TODO(ngeoffray): define what isResolved means. Also, pass the | 415 constructor = cls.resolve(compiler).lookupLocalElement(name); |
| 416 // needed element to resolve? | |
| 417 if (!cls.isResolved) compiler.resolveType(cls); | |
| 418 constructor = cls.lookupLocalElement(name); | |
| 419 if (name == cls.name | 416 if (name == cls.name |
| 420 && constructor === null | 417 && constructor === null |
| 421 && node.send.argumentsNode.isEmpty()) { | 418 && node.send.argumentsNode.isEmpty()) { |
| 422 constructor = cls.getSynthesizedConstructor(); | 419 constructor = cls.getSynthesizedConstructor(); |
| 423 } | 420 } |
| 424 if (constructor === null) { | 421 if (constructor === null) { |
| 425 error(node, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node]); | 422 error(node, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node]); |
| 426 } | 423 } |
| 427 } | 424 } |
| 428 | 425 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 class TopScope extends Scope { | 613 class TopScope extends Scope { |
| 617 Universe universe; | 614 Universe universe; |
| 618 | 615 |
| 619 TopScope(Universe this.universe) : super(null, null); | 616 TopScope(Universe this.universe) : super(null, null); |
| 620 Element lookup(SourceString name) => universe.find(name); | 617 Element lookup(SourceString name) => universe.find(name); |
| 621 | 618 |
| 622 Element add(Element element) { | 619 Element add(Element element) { |
| 623 throw "Cannot add an element in the top scope"; | 620 throw "Cannot add an element in the top scope"; |
| 624 } | 621 } |
| 625 } | 622 } |
| OLD | NEW |