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 tree_ir_nodes; | 5 library tree_ir_nodes; |
6 | 6 |
7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; | 9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; |
10 import '../dart_types.dart' show DartType, GenericType; | 10 import '../dart_types.dart' show DartType, GenericType; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 /** | 161 /** |
162 * Call to a factory or generative constructor. | 162 * Call to a factory or generative constructor. |
163 */ | 163 */ |
164 class InvokeConstructor extends Expression implements Invoke { | 164 class InvokeConstructor extends Expression implements Invoke { |
165 final DartType type; | 165 final DartType type; |
166 final FunctionElement target; | 166 final FunctionElement target; |
167 final List<Expression> arguments; | 167 final List<Expression> arguments; |
168 final Selector selector; | 168 final Selector selector; |
169 final values.Constant constant; | 169 final values.ConstantValue constant; |
170 | 170 |
171 InvokeConstructor(this.type, this.target, this.selector, this.arguments, | 171 InvokeConstructor(this.type, this.target, this.selector, this.arguments, |
172 [this.constant]); | 172 [this.constant]); |
173 | 173 |
174 ClassElement get targetClass => target.enclosingElement; | 174 ClassElement get targetClass => target.enclosingElement; |
175 | 175 |
176 accept(ExpressionVisitor visitor) => visitor.visitInvokeConstructor(this); | 176 accept(ExpressionVisitor visitor) => visitor.visitInvokeConstructor(this); |
177 } | 177 } |
178 | 178 |
179 /// Calls [toString] on each argument and concatenates the results. | 179 /// Calls [toString] on each argument and concatenates the results. |
180 class ConcatenateStrings extends Expression { | 180 class ConcatenateStrings extends Expression { |
181 final List<Expression> arguments; | 181 final List<Expression> arguments; |
182 final values.Constant constant; | 182 final values.ConstantValue constant; |
183 | 183 |
184 ConcatenateStrings(this.arguments, [this.constant]); | 184 ConcatenateStrings(this.arguments, [this.constant]); |
185 | 185 |
186 accept(ExpressionVisitor visitor) => visitor.visitConcatenateStrings(this); | 186 accept(ExpressionVisitor visitor) => visitor.visitConcatenateStrings(this); |
187 } | 187 } |
188 | 188 |
189 /** | 189 /** |
190 * A constant. | 190 * A constant. |
191 */ | 191 */ |
192 class Constant extends Expression { | 192 class Constant extends Expression { |
193 final ConstExp expression; | 193 final ConstantExpression expression; |
194 | 194 |
195 Constant(this.expression); | 195 Constant(this.expression); |
196 | 196 |
197 Constant.primitive(values.PrimitiveConstant primitiveValue) | 197 Constant.primitive(values.PrimitiveConstantValue primitiveValue) |
198 : expression = new PrimitiveConstExp(primitiveValue); | 198 : expression = new PrimitiveConstantExpression(primitiveValue); |
199 | 199 |
200 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); | 200 accept(ExpressionVisitor visitor) => visitor.visitConstant(this); |
201 | 201 |
202 values.Constant get value => expression.value; | 202 values.ConstantValue get value => expression.value; |
203 } | 203 } |
204 | 204 |
205 class This extends Expression { | 205 class This extends Expression { |
206 accept(ExpressionVisitor visitor) => visitor.visitThis(this); | 206 accept(ExpressionVisitor visitor) => visitor.visitThis(this); |
207 } | 207 } |
208 | 208 |
209 class ReifyTypeVar extends Expression { | 209 class ReifyTypeVar extends Expression { |
210 TypeVariableElement typeVariable; | 210 TypeVariableElement typeVariable; |
211 | 211 |
212 ReifyTypeVar(this.typeVariable); | 212 ReifyTypeVar(this.typeVariable); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 accept(StatementVisitor visitor) => visitor.visitAssign(this); | 441 accept(StatementVisitor visitor) => visitor.visitAssign(this); |
442 } | 442 } |
443 | 443 |
444 /** | 444 /** |
445 * A return exit from the function. | 445 * A return exit from the function. |
446 * | 446 * |
447 * In contrast to the CPS-based IR, the return value is an arbitrary | 447 * In contrast to the CPS-based IR, the return value is an arbitrary |
448 * expression. | 448 * expression. |
449 */ | 449 */ |
450 class Return extends Statement { | 450 class Return extends Statement { |
451 /// Should not be null. Use [Constant] with [NullConstant] for void returns. | 451 /// Should not be null. Use [Constant] with [NullConstantValue] for void |
| 452 /// returns. |
452 Expression value; | 453 Expression value; |
453 | 454 |
454 Statement get next => null; | 455 Statement get next => null; |
455 void set next(Statement s) => throw 'UNREACHABLE'; | 456 void set next(Statement s) => throw 'UNREACHABLE'; |
456 | 457 |
457 Return(this.value); | 458 Return(this.value); |
458 | 459 |
459 accept(StatementVisitor visitor) => visitor.visitReturn(this); | 460 accept(StatementVisitor visitor) => visitor.visitReturn(this); |
460 } | 461 } |
461 | 462 |
(...skipping 20 matching lines...) Expand all Loading... |
482 ExpressionStatement(this.expression, this.next); | 483 ExpressionStatement(this.expression, this.next); |
483 | 484 |
484 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this); | 485 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this); |
485 } | 486 } |
486 | 487 |
487 class FunctionDefinition extends Node { | 488 class FunctionDefinition extends Node { |
488 final FunctionElement element; | 489 final FunctionElement element; |
489 final List<Variable> parameters; | 490 final List<Variable> parameters; |
490 Statement body; | 491 Statement body; |
491 final List<ConstDeclaration> localConstants; | 492 final List<ConstDeclaration> localConstants; |
492 final List<ConstExp> defaultParameterValues; | 493 final List<ConstantExpression> defaultParameterValues; |
493 | 494 |
494 FunctionDefinition(this.element, this.parameters, this.body, | 495 FunctionDefinition(this.element, this.parameters, this.body, |
495 this.localConstants, this.defaultParameterValues); | 496 this.localConstants, this.defaultParameterValues); |
496 | 497 |
497 /// Returns `true` if this function is abstract. | 498 /// Returns `true` if this function is abstract. |
498 /// | 499 /// |
499 /// If `true` [body] is `null` and [localConstants] is empty. | 500 /// If `true` [body] is `null` and [localConstants] is empty. |
500 bool get isAbstract => body == null; | 501 bool get isAbstract => body == null; |
501 } | 502 } |
502 | 503 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 visitFunctionDeclaration(FunctionDeclaration node) { | 647 visitFunctionDeclaration(FunctionDeclaration node) { |
647 visitFunctionDefinition(node.definition); | 648 visitFunctionDefinition(node.definition); |
648 visitStatement(node.next); | 649 visitStatement(node.next); |
649 } | 650 } |
650 | 651 |
651 visitExpressionStatement(ExpressionStatement node) { | 652 visitExpressionStatement(ExpressionStatement node) { |
652 visitExpression(node.expression); | 653 visitExpression(node.expression); |
653 visitStatement(node.next); | 654 visitStatement(node.next); |
654 } | 655 } |
655 } | 656 } |
OLD | NEW |