| 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 ConstantValue; | 10 import '../constants/values.dart' as values show ConstantValue; |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 /// Invoke a continuation in tail position. | 495 /// Invoke a continuation in tail position. |
| 496 class InvokeContinuation extends Expression { | 496 class InvokeContinuation extends Expression { |
| 497 Reference<Continuation> continuation; | 497 Reference<Continuation> continuation; |
| 498 List<Reference<Primitive>> arguments; | 498 List<Reference<Primitive>> arguments; |
| 499 | 499 |
| 500 // An invocation of a continuation is recursive if it occurs in the body of | 500 // An invocation of a continuation is recursive if it occurs in the body of |
| 501 // the continuation itself. | 501 // the continuation itself. |
| 502 bool isRecursive; | 502 bool isRecursive; |
| 503 | 503 |
| 504 InvokeContinuation(Continuation cont, List<Primitive> args, | 504 InvokeContinuation(Continuation cont, List<Primitive> args, |
| 505 {recursive: false}) | 505 {this.isRecursive: false}) |
| 506 : continuation = new Reference<Continuation>(cont), | 506 : continuation = new Reference<Continuation>(cont), |
| 507 arguments = _referenceList(args), | 507 arguments = _referenceList(args) { |
| 508 isRecursive = recursive { | 508 assert(cont.parameters == null || cont.parameters.length == args.length); |
| 509 assert(cont.parameters == null || | 509 if (isRecursive) cont.isRecursive = true; |
| 510 cont.parameters.length == args.length); | |
| 511 if (recursive) cont.isRecursive = true; | |
| 512 } | 510 } |
| 513 | 511 |
| 514 /// A continuation invocation whose target and arguments will be filled | 512 /// A continuation invocation whose target and arguments will be filled |
| 515 /// in later. | 513 /// in later. |
| 516 /// | 514 /// |
| 517 /// Used as a placeholder for a jump whose target is not yet created | 515 /// Used as a placeholder for a jump whose target is not yet created |
| 518 /// (e.g., in the translation of break and continue). | 516 /// (e.g., in the translation of break and continue). |
| 519 InvokeContinuation.uninitialized({recursive: false}) | 517 InvokeContinuation.uninitialized({this.isRecursive: false}) |
| 520 : continuation = null, | 518 : continuation = null, |
| 521 arguments = null, | 519 arguments = null; |
| 522 isRecursive = recursive; | |
| 523 | 520 |
| 524 accept(Visitor visitor) => visitor.visitInvokeContinuation(this); | 521 accept(Visitor visitor) => visitor.visitInvokeContinuation(this); |
| 525 } | 522 } |
| 526 | 523 |
| 527 /// The base class of things which can be tested and branched on. | 524 /// The base class of things which can be tested and branched on. |
| 528 abstract class Condition extends Node { | 525 abstract class Condition extends Node { |
| 529 } | 526 } |
| 530 | 527 |
| 531 class IsTrue extends Condition { | 528 class IsTrue extends Condition { |
| 532 final Reference<Primitive> value; | 529 final Reference<Primitive> value; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 values.ConstantValue get constant => null; | 651 values.ConstantValue get constant => null; |
| 655 | 652 |
| 656 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); | 653 accept(Visitor visitor) => visitor.visitReifyTypeVar(this); |
| 657 } | 654 } |
| 658 | 655 |
| 659 class LiteralList extends Primitive { | 656 class LiteralList extends Primitive { |
| 660 /// The List type being created; this is not the type argument. | 657 /// The List type being created; this is not the type argument. |
| 661 final GenericType type; | 658 final GenericType type; |
| 662 final List<Reference<Primitive>> values; | 659 final List<Reference<Primitive>> values; |
| 663 | 660 |
| 664 LiteralList(this.type, Iterable<Primitive> values) | 661 LiteralList(this.type, List<Primitive> values) |
| 665 : this.values = _referenceList(values); | 662 : this.values = _referenceList(values); |
| 666 | 663 |
| 667 accept(Visitor visitor) => visitor.visitLiteralList(this); | 664 accept(Visitor visitor) => visitor.visitLiteralList(this); |
| 668 } | 665 } |
| 669 | 666 |
| 670 class LiteralMapEntry { | 667 class LiteralMapEntry { |
| 671 final Reference<Primitive> key; | 668 final Reference<Primitive> key; |
| 672 final Reference<Primitive> value; | 669 final Reference<Primitive> value; |
| 673 | 670 |
| 674 LiteralMapEntry(Primitive key, Primitive value) | 671 LiteralMapEntry(Primitive key, Primitive value) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 class Continuation extends Definition<Continuation> implements InteriorNode { | 713 class Continuation extends Definition<Continuation> implements InteriorNode { |
| 717 final List<Parameter> parameters; | 714 final List<Parameter> parameters; |
| 718 Expression body = null; | 715 Expression body = null; |
| 719 | 716 |
| 720 // In addition to a parent pointer to the containing LetCont, continuations | 717 // In addition to a parent pointer to the containing LetCont, continuations |
| 721 // have an index into the list of continuations bound by the LetCont. This | 718 // have an index into the list of continuations bound by the LetCont. This |
| 722 // gives constant-time access to the continuation from the parent. | 719 // gives constant-time access to the continuation from the parent. |
| 723 int parent_index; | 720 int parent_index; |
| 724 | 721 |
| 725 // A continuation is recursive if it has any recursive invocations. | 722 // A continuation is recursive if it has any recursive invocations. |
| 726 bool isRecursive = false; | 723 bool isRecursive; |
| 727 | 724 |
| 728 bool get isReturnContinuation => body == null; | 725 bool get isReturnContinuation => body == null; |
| 729 | 726 |
| 730 Continuation(this.parameters); | 727 Continuation(this.parameters, {this.isRecursive: false}); |
| 731 | 728 |
| 732 Continuation.retrn() : parameters = <Parameter>[new Parameter(null)]; | 729 Continuation.retrn() : parameters = <Parameter>[new Parameter(null)]; |
| 733 | 730 |
| 734 accept(Visitor visitor) => visitor.visitContinuation(this); | 731 accept(Visitor visitor) => visitor.visitContinuation(this); |
| 735 } | 732 } |
| 736 | 733 |
| 737 abstract class ExecutableDefinition implements Node { | 734 abstract class ExecutableDefinition implements Node { |
| 738 RunnableBody get body; | 735 RunnableBody get body; |
| 739 Element get element; | 736 Element get element; |
| 740 | 737 |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 | 1534 |
| 1538 void visitReadTypeVariable(ReadTypeVariable node) { | 1535 void visitReadTypeVariable(ReadTypeVariable node) { |
| 1539 visitReference(node.target); | 1536 visitReference(node.target); |
| 1540 } | 1537 } |
| 1541 | 1538 |
| 1542 @override | 1539 @override |
| 1543 visitTypeExpression(TypeExpression node) { | 1540 visitTypeExpression(TypeExpression node) { |
| 1544 node.arguments.forEach(visitReference); | 1541 node.arguments.forEach(visitReference); |
| 1545 } | 1542 } |
| 1546 } | 1543 } |
| OLD | NEW |