| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.semantics_visitor; | 5 library dart2js.semantics_visitor; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../universe/call_structure.dart' show | 12 import '../universe/call_structure.dart' show |
| 13 CallStructure; | 13 CallStructure; |
| 14 import '../universe/selector.dart' show | 14 import '../universe/selector.dart' show |
| 15 Selector; | 15 Selector; |
| 16 | 16 |
| 17 import 'operators.dart'; | 17 import 'operators.dart'; |
| 18 import 'send_resolver.dart'; | 18 import 'send_resolver.dart'; |
| 19 import 'send_structure.dart'; | 19 import 'send_structure.dart'; |
| 20 import 'tree_elements.dart'; | 20 import 'tree_elements.dart'; |
| 21 | 21 |
| 22 part 'semantic_visitor_mixins.dart'; | 22 part 'semantic_visitor_mixins.dart'; |
| 23 | 23 |
| 24 /// Mixin that couples a [SendResolverMixin] to a [SemanticSendVisitor] in a | 24 /// Mixin that couples a [SendResolverMixin] to a [SemanticSendVisitor] in a |
| 25 /// [Visitor]. | 25 /// [Visitor]. |
| 26 abstract class SemanticSendResolvedMixin<R, A> | 26 abstract class SemanticSendResolvedMixin<R, A> implements Visitor<R> { |
| 27 implements Visitor<R>, SendResolverMixin { | 27 TreeElements get elements; |
| 28 |
| 29 internalError(Spannable spannable, String message); |
| 28 | 30 |
| 29 SemanticSendVisitor<R, A> get sendVisitor; | 31 SemanticSendVisitor<R, A> get sendVisitor; |
| 30 | 32 |
| 31 @override | 33 @override |
| 32 R visitIdentifier(Identifier node) { | 34 R visitIdentifier(Identifier node) { |
| 33 // TODO(johnniwinther): Support argument. | 35 // TODO(johnniwinther): Support argument. |
| 34 A arg = null; | 36 A arg = null; |
| 35 if (node.isThis()) { | 37 if (node.isThis()) { |
| 36 // TODO(johnniwinther): Parse `this` as a [Send] whose selector is `this` | 38 // TODO(johnniwinther): Parse `this` as a [Send] whose selector is `this` |
| 37 // to normalize with `this(...)`. | 39 // to normalize with `this(...)`. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 @override | 58 @override |
| 57 R visitSendSet(SendSet node) { | 59 R visitSendSet(SendSet node) { |
| 58 return visitSend(node); | 60 return visitSend(node); |
| 59 } | 61 } |
| 60 | 62 |
| 61 @override | 63 @override |
| 62 R visitNewExpression(NewExpression node) { | 64 R visitNewExpression(NewExpression node) { |
| 63 // TODO(johnniwinther): Support argument. | 65 // TODO(johnniwinther): Support argument. |
| 64 A arg = null; | 66 A arg = null; |
| 65 | 67 |
| 66 NewStructure structure = computeNewStructure(node); | 68 NewStructure structure = elements.getNewStructure(node); |
| 67 if (structure == null) { | 69 if (structure == null) { |
| 68 return internalError(node, 'No structure for $node'); | 70 return internalError(node, 'No structure for $node'); |
| 69 } else { | 71 } else { |
| 70 return structure.dispatch(sendVisitor, node, arg); | 72 return structure.dispatch(sendVisitor, node, arg); |
| 71 } | 73 } |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| 75 /// Mixin that couples a [DeclarationResolverMixin] to a | 77 /// Mixin that couples a [DeclarationResolverMixin] to a |
| 76 /// [SemanticDeclarationVisitor] in a [Visitor]. | 78 /// [SemanticDeclarationVisitor] in a [Visitor]. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } else { | 122 } else { |
| 121 return structure.dispatch(declVisitor, node, arg); | 123 return structure.dispatch(declVisitor, node, arg); |
| 122 } | 124 } |
| 123 }); | 125 }); |
| 124 return null; | 126 return null; |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 abstract class SemanticVisitor<R, A> extends Visitor<R> | 130 abstract class SemanticVisitor<R, A> extends Visitor<R> |
| 129 with SemanticSendResolvedMixin<R, A>, | 131 with SemanticSendResolvedMixin<R, A>, |
| 130 SendResolverMixin, | |
| 131 SemanticDeclarationResolvedMixin<R, A>, | 132 SemanticDeclarationResolvedMixin<R, A>, |
| 132 DeclarationResolverMixin { | 133 DeclarationResolverMixin { |
| 133 TreeElements elements; | 134 TreeElements elements; |
| 134 | 135 |
| 135 SemanticVisitor(this.elements); | 136 SemanticVisitor(this.elements); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // TODO(johnniwinther): Add visits for [visitLocalConstantGet], | 139 // TODO(johnniwinther): Add visits for [visitLocalConstantGet], |
| 139 // [visitLocalConstantInvoke], [visitStaticConstantGet], etc. | 140 // [visitLocalConstantInvoke], [visitStaticConstantGet], etc. |
| 140 abstract class SemanticSendVisitor<R, A> { | 141 abstract class SemanticSendVisitor<R, A> { |
| (...skipping 5679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5820 /// C() : this._(42); | 5821 /// C() : this._(42); |
| 5821 /// } | 5822 /// } |
| 5822 /// | 5823 /// |
| 5823 R errorUnresolvedThisConstructorInvoke( | 5824 R errorUnresolvedThisConstructorInvoke( |
| 5824 Send node, | 5825 Send node, |
| 5825 Element element, | 5826 Element element, |
| 5826 NodeList arguments, | 5827 NodeList arguments, |
| 5827 Selector selector, | 5828 Selector selector, |
| 5828 A arg); | 5829 A arg); |
| 5829 } | 5830 } |
| OLD | NEW |