OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their | 5 // IrNodes are kept in a separate library to have precise control over their |
6 // dependencies on other parts of the system. | 6 // dependencies on other parts of the system. |
7 library dart2js.ir_nodes; | 7 library dart2js.ir_nodes; |
8 | 8 |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../constants/values.dart' as values show Constant; | 10 import '../constants/values.dart' as values show ConstantValue; |
11 import '../dart2jslib.dart' as dart2js show invariant; | 11 import '../dart2jslib.dart' as dart2js show invariant; |
12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
13 import '../universe/universe.dart' show Selector, SelectorKind; | 13 import '../universe/universe.dart' show Selector, SelectorKind; |
14 import '../dart_types.dart' show DartType, GenericType; | 14 import '../dart_types.dart' show DartType, GenericType; |
15 | 15 |
16 abstract class Node { | 16 abstract class Node { |
17 static int hashCount = 0; | 17 static int hashCount = 0; |
18 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; | 18 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; |
19 | 19 |
20 /// A pointer to the parent node. Is null until set by optimization passes. | 20 /// A pointer to the parent node. Is null until set by optimization passes. |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 final Reference falseContinuation; | 442 final Reference falseContinuation; |
443 | 443 |
444 Branch(this.condition, Continuation trueCont, Continuation falseCont) | 444 Branch(this.condition, Continuation trueCont, Continuation falseCont) |
445 : trueContinuation = new Reference(trueCont), | 445 : trueContinuation = new Reference(trueCont), |
446 falseContinuation = new Reference(falseCont); | 446 falseContinuation = new Reference(falseCont); |
447 | 447 |
448 accept(Visitor visitor) => visitor.visitBranch(this); | 448 accept(Visitor visitor) => visitor.visitBranch(this); |
449 } | 449 } |
450 | 450 |
451 class Constant extends Primitive { | 451 class Constant extends Primitive { |
452 final ConstExp expression; | 452 final ConstantExpression expression; |
453 | 453 |
454 Constant(this.expression); | 454 Constant(this.expression); |
455 | 455 |
456 values.Constant get value => expression.value; | 456 values.ConstantValue get value => expression.value; |
457 | 457 |
458 accept(Visitor visitor) => visitor.visitConstant(this); | 458 accept(Visitor visitor) => visitor.visitConstant(this); |
459 } | 459 } |
460 | 460 |
461 class This extends Primitive { | 461 class This extends Primitive { |
462 This(); | 462 This(); |
463 | 463 |
464 accept(Visitor visitor) => visitor.visitThis(this); | 464 accept(Visitor visitor) => visitor.visitThis(this); |
465 } | 465 } |
466 | 466 |
467 /// Reify the given type variable as a [Type]. | 467 /// Reify the given type variable as a [Type]. |
468 /// This depends on the current binding of 'this'. | 468 /// This depends on the current binding of 'this'. |
469 class ReifyTypeVar extends Primitive { | 469 class ReifyTypeVar extends Primitive { |
470 final TypeVariableElement typeVariable; | 470 final TypeVariableElement typeVariable; |
471 | 471 |
472 ReifyTypeVar(this.typeVariable); | 472 ReifyTypeVar(this.typeVariable); |
473 | 473 |
474 values.Constant get constant => null; | 474 values.ConstantValue get constant => null; |
475 | 475 |
476 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); | 476 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); |
477 } | 477 } |
478 | 478 |
479 class LiteralList extends Primitive { | 479 class LiteralList extends Primitive { |
480 /// The List type being created; this is not the type argument. | 480 /// The List type being created; this is not the type argument. |
481 final GenericType type; | 481 final GenericType type; |
482 final List<Reference> values; | 482 final List<Reference> values; |
483 | 483 |
484 LiteralList(this.type, List<Primitive> values) | 484 LiteralList(this.type, List<Primitive> values) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 /// A function definition, consisting of parameters and a body. The parameters | 538 /// A function definition, consisting of parameters and a body. The parameters |
539 /// include a distinguished continuation parameter. | 539 /// include a distinguished continuation parameter. |
540 class FunctionDefinition extends Node implements InteriorNode { | 540 class FunctionDefinition extends Node implements InteriorNode { |
541 final FunctionElement element; | 541 final FunctionElement element; |
542 final Continuation returnContinuation; | 542 final Continuation returnContinuation; |
543 final List<Parameter> parameters; | 543 final List<Parameter> parameters; |
544 Expression body; | 544 Expression body; |
545 final List<ConstDeclaration> localConstants; | 545 final List<ConstDeclaration> localConstants; |
546 | 546 |
547 /// Values for optional parameters. | 547 /// Values for optional parameters. |
548 final List<ConstExp> defaultParameterValues; | 548 final List<ConstantExpression> defaultParameterValues; |
549 | 549 |
550 FunctionDefinition(this.element, this.returnContinuation, | 550 FunctionDefinition(this.element, this.returnContinuation, |
551 this.parameters, this.body, this.localConstants, | 551 this.parameters, this.body, this.localConstants, |
552 this.defaultParameterValues); | 552 this.defaultParameterValues); |
553 | 553 |
554 FunctionDefinition.abstract(this.element, | 554 FunctionDefinition.abstract(this.element, |
555 this.parameters, | 555 this.parameters, |
556 this.defaultParameterValues) | 556 this.defaultParameterValues) |
557 : this.returnContinuation = null, | 557 : this.returnContinuation = null, |
558 this.localConstants = const <ConstDeclaration>[]; | 558 this.localConstants = const <ConstDeclaration>[]; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 release(node.parameters[i]); | 936 release(node.parameters[i]); |
937 } | 937 } |
938 } | 938 } |
939 | 939 |
940 void visitIsTrue(IsTrue node) { | 940 void visitIsTrue(IsTrue node) { |
941 visitReference(node.value); | 941 visitReference(node.value); |
942 } | 942 } |
943 | 943 |
944 } | 944 } |
945 | 945 |
OLD | NEW |