| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 447 } |
| 448 | 448 |
| 449 /// Create a potentially recursive function and store it in a [MutableVariable]. | 449 /// Create a potentially recursive function and store it in a [MutableVariable]. |
| 450 /// The function can access itself using [GetMutableVariable] on [variable]. | 450 /// The function can access itself using [GetMutableVariable] on [variable]. |
| 451 /// There must not exist a [SetMutableVariable] to [variable]. | 451 /// There must not exist a [SetMutableVariable] to [variable]. |
| 452 /// | 452 /// |
| 453 /// This can be seen as a let rec binding: | 453 /// This can be seen as a let rec binding: |
| 454 /// | 454 /// |
| 455 /// let rec [variable] = [definition] in [body] | 455 /// let rec [variable] = [definition] in [body] |
| 456 /// | 456 /// |
| 457 class DeclareFunction extends Expression implements InteriorNode { | 457 class DeclareFunction extends Expression |
| 458 implements InteriorNode, DartSpecificNode { |
| 458 final MutableVariable variable; | 459 final MutableVariable variable; |
| 459 final FunctionDefinition definition; | 460 final FunctionDefinition definition; |
| 460 Expression body; | 461 Expression body; |
| 461 | 462 |
| 462 DeclareFunction(this.variable, this.definition); | 463 DeclareFunction(this.variable, this.definition); |
| 463 | 464 |
| 464 Expression plug(Expression expr) { | 465 Expression plug(Expression expr) { |
| 465 assert(body == null); | 466 assert(body == null); |
| 466 return body = expr; | 467 return body = expr; |
| 467 } | 468 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 522 |
| 522 Branch(this.condition, Continuation trueCont, Continuation falseCont) | 523 Branch(this.condition, Continuation trueCont, Continuation falseCont) |
| 523 : trueContinuation = new Reference<Continuation>(trueCont), | 524 : trueContinuation = new Reference<Continuation>(trueCont), |
| 524 falseContinuation = new Reference<Continuation>(falseCont); | 525 falseContinuation = new Reference<Continuation>(falseCont); |
| 525 | 526 |
| 526 accept(Visitor visitor) => visitor.visitBranch(this); | 527 accept(Visitor visitor) => visitor.visitBranch(this); |
| 527 } | 528 } |
| 528 | 529 |
| 529 /// Marker interface for nodes that are only handled in the JavaScript backend. | 530 /// Marker interface for nodes that are only handled in the JavaScript backend. |
| 530 /// | 531 /// |
| 531 /// These nodes are generated by the unsugar step and need special translation | 532 /// These nodes are generated by the unsugar step or the [JsIrBuilder] and need |
| 532 /// to the Tree IR, which is implemented in JsTreeBuilder. | 533 /// special translation to the Tree IR, which is implemented in JsTreeBuilder. |
| 533 abstract class JsSpecificNode {} | 534 abstract class JsSpecificNode implements Node {} |
| 535 |
| 536 /// Marker interface for nodes that are only handled inthe Dart backend. |
| 537 abstract class DartSpecificNode implements Node {} |
| 534 | 538 |
| 535 /// Directly assigns to a field on a given object. | 539 /// Directly assigns to a field on a given object. |
| 536 class SetField extends Expression implements InteriorNode, JsSpecificNode { | 540 class SetField extends Expression implements InteriorNode, JsSpecificNode { |
| 537 final Reference<Primitive> object; | 541 final Reference<Primitive> object; |
| 538 Element field; | 542 Element field; |
| 539 final Reference<Primitive> value; | 543 final Reference<Primitive> value; |
| 540 Expression body; | 544 Expression body; |
| 541 | 545 |
| 542 SetField(Primitive object, this.field, Primitive value) | 546 SetField(Primitive object, this.field, Primitive value) |
| 543 : this.object = new Reference<Primitive>(object), | 547 : this.object = new Reference<Primitive>(object), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 class LiteralMap extends Primitive { | 653 class LiteralMap extends Primitive { |
| 650 final GenericType type; | 654 final GenericType type; |
| 651 final List<LiteralMapEntry> entries; | 655 final List<LiteralMapEntry> entries; |
| 652 | 656 |
| 653 LiteralMap(this.type, this.entries); | 657 LiteralMap(this.type, this.entries); |
| 654 | 658 |
| 655 accept(Visitor visitor) => visitor.visitLiteralMap(this); | 659 accept(Visitor visitor) => visitor.visitLiteralMap(this); |
| 656 } | 660 } |
| 657 | 661 |
| 658 /// Create a non-recursive function. | 662 /// Create a non-recursive function. |
| 659 class CreateFunction extends Primitive { | 663 class CreateFunction extends Primitive implements DartSpecificNode { |
| 660 final FunctionDefinition definition; | 664 final FunctionDefinition definition; |
| 661 | 665 |
| 662 CreateFunction(this.definition); | 666 CreateFunction(this.definition); |
| 663 | 667 |
| 664 accept(Visitor visitor) => visitor.visitCreateFunction(this); | 668 accept(Visitor visitor) => visitor.visitCreateFunction(this); |
| 665 } | 669 } |
| 666 | 670 |
| 667 class Parameter extends Primitive { | 671 class Parameter extends Primitive { |
| 668 Parameter(Entity hint) { | 672 Parameter(Entity hint) { |
| 669 super.hint = hint; | 673 super.hint = hint; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 792 |
| 789 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); | 793 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); |
| 790 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); | 794 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); |
| 791 | 795 |
| 792 /// Returns `true` if this function is abstract or external. | 796 /// Returns `true` if this function is abstract or external. |
| 793 /// | 797 /// |
| 794 /// If `true`, [body] is `null` and [localConstants] is empty. | 798 /// If `true`, [body] is `null` and [localConstants] is empty. |
| 795 bool get isAbstract => body == null; | 799 bool get isAbstract => body == null; |
| 796 } | 800 } |
| 797 | 801 |
| 798 abstract class Initializer extends Node {} | 802 abstract class Initializer extends Node implements DartSpecificNode {} |
| 799 | 803 |
| 800 class FieldInitializer extends Initializer { | 804 class FieldInitializer extends Initializer { |
| 801 final FieldElement element; | 805 final FieldElement element; |
| 802 final RunnableBody body; | 806 final RunnableBody body; |
| 803 | 807 |
| 804 FieldInitializer(this.element, this.body); | 808 FieldInitializer(this.element, this.body); |
| 805 accept(Visitor visitor) => visitor.visitFieldInitializer(this); | 809 accept(Visitor visitor) => visitor.visitFieldInitializer(this); |
| 806 } | 810 } |
| 807 | 811 |
| 808 class SuperInitializer extends Initializer { | 812 class SuperInitializer extends Initializer { |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 | 1395 |
| 1392 void visitIdentical(Identical node) { | 1396 void visitIdentical(Identical node) { |
| 1393 visitReference(node.left); | 1397 visitReference(node.left); |
| 1394 visitReference(node.right); | 1398 visitReference(node.right); |
| 1395 } | 1399 } |
| 1396 | 1400 |
| 1397 void visitInterceptor(Interceptor node) { | 1401 void visitInterceptor(Interceptor node) { |
| 1398 visitReference(node.input); | 1402 visitReference(node.input); |
| 1399 } | 1403 } |
| 1400 } | 1404 } |
| OLD | NEW |