| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 /// [ResolutionRegistry] collects all resolution information. It stores node | 7 /// [ResolutionRegistry] collects all resolution information. It stores node |
| 8 /// related information in a [TreeElements] mapping and registers calls with | 8 /// related information in a [TreeElements] mapping and registers calls with |
| 9 /// [Backend], [World] and [Enqueuer]. | 9 /// [Backend], [World] and [Enqueuer]. |
| 10 // TODO(johnniwinther): Split this into an interface and implementation class. | 10 // TODO(johnniwinther): Split this into an interface and implementation class. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ResolutionEnqueuer get world => compiler.enqueuer.resolution; | 24 ResolutionEnqueuer get world => compiler.enqueuer.resolution; |
| 25 | 25 |
| 26 World get universe => compiler.world; | 26 World get universe => compiler.world; |
| 27 | 27 |
| 28 Backend get backend => compiler.backend; | 28 Backend get backend => compiler.backend; |
| 29 | 29 |
| 30 ////////////////////////////////////////////////////////////////////////////// | 30 ////////////////////////////////////////////////////////////////////////////// |
| 31 // Node-to-Element mapping functionality. | 31 // Node-to-Element mapping functionality. |
| 32 ////////////////////////////////////////////////////////////////////////////// | 32 ////////////////////////////////////////////////////////////////////////////// |
| 33 | 33 |
| 34 /// Register [node] as the declaration of [element]. |
| 35 void defineFunction(FunctionExpression node, FunctionElement element) { |
| 36 mapping[node] = element; |
| 37 } |
| 38 |
| 34 /// Register [node] as a reference to [element]. | 39 /// Register [node] as a reference to [element]. |
| 35 Element useElement(Node node, Element element) { | 40 Element useElement(Node node, Element element) { |
| 36 if (element == null) return null; | 41 if (element == null) return null; |
| 37 return mapping[node] = element; | 42 return mapping[node] = element; |
| 38 } | 43 } |
| 39 | 44 |
| 40 /// Register [node] as a declaration of [element]. | 45 /// Register [node] as the declaration of [element]. |
| 41 void defineElement(Node node, Element element) { | 46 void defineElement(Node node, Element element) { |
| 42 mapping[node] = element; | 47 mapping[node] = element; |
| 43 } | 48 } |
| 44 | 49 |
| 45 /// Returns the [Element] defined by [node]. | 50 /// Returns the [Element] defined by [node]. |
| 46 Element getDefinition(Node node) { | 51 Element getDefinition(Node node) { |
| 47 return mapping[node]; | 52 return mapping[node]; |
| 48 } | 53 } |
| 49 | 54 |
| 55 /// Sets the loop variable of the for-in [node] to be [element]. |
| 56 void setForInVariable(ForIn node, Element element) { |
| 57 mapping[node] = element; |
| 58 } |
| 59 |
| 60 /// Sets the target constructor [node] to be [element]. |
| 61 void setRedirectingTargetConstructor(RedirectingFactoryBody node, |
| 62 ConstructorElement element) { |
| 63 useElement(node, element); |
| 64 } |
| 65 |
| 50 ////////////////////////////////////////////////////////////////////////////// | 66 ////////////////////////////////////////////////////////////////////////////// |
| 51 // Node-to-Selector mapping functionality. | 67 // Node-to-Selector mapping functionality. |
| 52 ////////////////////////////////////////////////////////////////////////////// | 68 ////////////////////////////////////////////////////////////////////////////// |
| 53 | 69 |
| 54 void setSelector(Node node, Selector selector) { | 70 void setSelector(Node node, Selector selector) { |
| 55 mapping.setSelector(node, selector); | 71 mapping.setSelector(node, selector); |
| 56 } | 72 } |
| 57 | 73 |
| 58 Selector getSelector(Node node) => mapping.getSelector(node); | 74 Selector getSelector(Node node) => mapping.getSelector(node); |
| 59 | 75 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 mapping.setCurrentSelector(node, selector); | 93 mapping.setCurrentSelector(node, selector); |
| 78 } | 94 } |
| 79 | 95 |
| 80 ////////////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////////////// |
| 81 // Node-to-Type mapping functionality. | 97 // Node-to-Type mapping functionality. |
| 82 ////////////////////////////////////////////////////////////////////////////// | 98 ////////////////////////////////////////////////////////////////////////////// |
| 83 | 99 |
| 84 DartType useType(Node annotation, DartType type) { | 100 DartType useType(Node annotation, DartType type) { |
| 85 if (type != null) { | 101 if (type != null) { |
| 86 mapping.setType(annotation, type); | 102 mapping.setType(annotation, type); |
| 87 useElement(annotation, type.element); | |
| 88 } | 103 } |
| 89 return type; | 104 return type; |
| 90 } | 105 } |
| 91 | 106 |
| 92 void setType(Node node, DartType type) => mapping.setType(node, type); | 107 void setType(Node node, DartType type) => mapping.setType(node, type); |
| 93 | 108 |
| 94 DartType getType(Node node) => mapping.getType(node); | 109 DartType getType(Node node) => mapping.getType(node); |
| 95 | 110 |
| 96 ////////////////////////////////////////////////////////////////////////////// | 111 ////////////////////////////////////////////////////////////////////////////// |
| 97 // Node-to-Constant mapping functionality. | 112 // Node-to-Constant mapping functionality. |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 357 |
| 343 void registerAssert(Send node) { | 358 void registerAssert(Send node) { |
| 344 mapping.setAssert(node); | 359 mapping.setAssert(node); |
| 345 backend.resolutionCallbacks.onAssert(node, this); | 360 backend.resolutionCallbacks.onAssert(node, this); |
| 346 } | 361 } |
| 347 | 362 |
| 348 bool isAssert(Send node) { | 363 bool isAssert(Send node) { |
| 349 return mapping.isAssert(node); | 364 return mapping.isAssert(node); |
| 350 } | 365 } |
| 351 } | 366 } |
| OLD | NEW |