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 library dart2js.ir_nodes_sexpr; | 5 library dart2js.ir_nodes_sexpr; |
6 | 6 |
7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
8 import '../util/util.dart'; | 8 import '../util/util.dart'; |
9 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
10 import '../universe/call_structure.dart' show | 10 import '../universe/call_structure.dart' show |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 String visitInvokeMethodDirectly(InvokeMethodDirectly node) { | 142 String visitInvokeMethodDirectly(InvokeMethodDirectly node) { |
143 String receiver = access(node.receiver); | 143 String receiver = access(node.receiver); |
144 String name = node.selector.name; | 144 String name = node.selector.name; |
145 String args = formatArguments(node.selector.callStructure, node.arguments, | 145 String args = formatArguments(node.selector.callStructure, node.arguments, |
146 node.callingConvention); | 146 node.callingConvention); |
147 return '(InvokeMethodDirectly $receiver $name $args)'; | 147 return '(InvokeMethodDirectly $receiver $name $args)'; |
148 } | 148 } |
149 | 149 |
150 String visitInvokeConstructor(InvokeConstructor node) { | 150 String visitInvokeConstructor(InvokeConstructor node) { |
151 String className; | |
152 // TODO(karlklose): for illegal nodes constructed for tests or unresolved | 151 // TODO(karlklose): for illegal nodes constructed for tests or unresolved |
153 // constructor calls in the DartBackend, we get an element with no enclosing | 152 // constructor calls in the DartBackend, we get an element with no enclosing |
154 // class. Clean this up by introducing a name field to the node and | 153 // class. Clean this up by introducing a name field to the node and |
155 // removing [ErroneousElement]s from the IR. | 154 // removing [ErroneousElement]s from the IR. |
156 if (node.dartType != null) { | 155 String name = node.dartType != null |
157 className = node.dartType.toString(); | 156 ? node.dartType.toString() |
158 } else { | 157 : node.target.enclosingClass.name; |
159 className = node.target.enclosingClass.name; | 158 if (!node.target.name.isEmpty) { |
160 } | 159 name = '${name}.${node.target.name}'; |
161 String callName; | |
162 if (node.target.name.isEmpty) { | |
163 callName = '${className}'; | |
164 } else { | |
165 callName = '${className}.${node.target.name}'; | |
166 } | 160 } |
167 String args = formatArguments(node.selector.callStructure, node.arguments); | 161 String args = formatArguments(node.selector.callStructure, node.arguments); |
168 return '(InvokeConstructor $callName $args)'; | 162 return '(InvokeConstructor $name $args)'; |
169 } | 163 } |
170 | 164 |
171 String visitInvokeContinuation(InvokeContinuation node) { | 165 String visitInvokeContinuation(InvokeContinuation node) { |
172 String name = access(node.continuation); | 166 String name = access(node.continuation); |
173 if (node.isRecursive) name = 'rec $name'; | 167 if (node.isRecursive) name = 'rec $name'; |
174 String args = node.arguments.map(access).join(' '); | 168 String args = node.arguments.map(access).join(' '); |
175 return '$indentation(InvokeContinuation $name ($args))'; | 169 return '$indentation(InvokeContinuation $name ($args))'; |
176 } | 170 } |
177 | 171 |
178 String visitThrow(Throw node) { | 172 String visitThrow(Throw node) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 void setReturnContinuation(Continuation node) { | 467 void setReturnContinuation(Continuation node) { |
474 assert(!_names.containsKey(node) || _names[node] == 'return'); | 468 assert(!_names.containsKey(node) || _names[node] == 'return'); |
475 _names[node] = 'return'; | 469 _names[node] = 'return'; |
476 } | 470 } |
477 | 471 |
478 String getName(Node node) { | 472 String getName(Node node) { |
479 if (!_names.containsKey(node)) return 'MISSING_NAME'; | 473 if (!_names.containsKey(node)) return 'MISSING_NAME'; |
480 return _names[node]; | 474 return _names[node]; |
481 } | 475 } |
482 } | 476 } |
OLD | NEW |