| 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 '../dart_types.dart' show DartType, GenericType; | 9 import '../dart_types.dart' show DartType, GenericType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 /// Logical negation. | 323 /// Logical negation. |
| 324 class Not extends Expression { | 324 class Not extends Expression { |
| 325 Expression operand; | 325 Expression operand; |
| 326 | 326 |
| 327 Not(this.operand); | 327 Not(this.operand); |
| 328 | 328 |
| 329 accept(ExpressionVisitor visitor) => visitor.visitNot(this); | 329 accept(ExpressionVisitor visitor) => visitor.visitNot(this); |
| 330 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); | 330 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); |
| 331 } | 331 } |
| 332 | 332 |
| 333 class FunctionExpression extends Expression { | 333 class FunctionExpression extends Expression implements DartSpecificNode { |
| 334 final FunctionDefinition definition; | 334 final FunctionDefinition definition; |
| 335 | 335 |
| 336 FunctionExpression(this.definition) { | 336 FunctionExpression(this.definition) { |
| 337 assert(definition.element.type.returnType.treatAsDynamic); | 337 assert(definition.element.type.returnType.treatAsDynamic); |
| 338 } | 338 } |
| 339 | 339 |
| 340 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); | 340 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); |
| 341 accept1(ExpressionVisitor1 visitor, arg) { | 341 accept1(ExpressionVisitor1 visitor, arg) { |
| 342 return visitor.visitFunctionExpression(this, arg); | 342 return visitor.visitFunctionExpression(this, arg); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 /// Declares a local function. | 346 /// Declares a local function. |
| 347 /// Used for functions that may not occur in expression context due to | 347 /// Used for functions that may not occur in expression context due to |
| 348 /// being recursive or having a return type. | 348 /// being recursive or having a return type. |
| 349 /// The [variable] must not occur as the left-hand side of an [Assign] or | 349 /// The [variable] must not occur as the left-hand side of an [Assign] or |
| 350 /// any other [FunctionDeclaration]. | 350 /// any other [FunctionDeclaration]. |
| 351 class FunctionDeclaration extends Statement { | 351 class FunctionDeclaration extends Statement implements DartSpecificNode { |
| 352 Variable variable; | 352 Variable variable; |
| 353 final FunctionDefinition definition; | 353 final FunctionDefinition definition; |
| 354 Statement next; | 354 Statement next; |
| 355 | 355 |
| 356 FunctionDeclaration(this.variable, this.definition, this.next) { | 356 FunctionDeclaration(this.variable, this.definition, this.next) { |
| 357 ++variable.writeCount; | 357 ++variable.writeCount; |
| 358 } | 358 } |
| 359 | 359 |
| 360 accept(StatementVisitor visitor) => visitor.visitFunctionDeclaration(this); | 360 accept(StatementVisitor visitor) => visitor.visitFunctionDeclaration(this); |
| 361 accept1(StatementVisitor1 visitor, arg) { | 361 accept1(StatementVisitor1 visitor, arg) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 FunctionDefinition(this.element, this.parameters, this.body, | 605 FunctionDefinition(this.element, this.parameters, this.body, |
| 606 this.localConstants, this.defaultParameterValues); | 606 this.localConstants, this.defaultParameterValues); |
| 607 | 607 |
| 608 /// Returns `true` if this function is abstract. | 608 /// Returns `true` if this function is abstract. |
| 609 /// | 609 /// |
| 610 /// If `true` [body] is `null` and [localConstants] is empty. | 610 /// If `true` [body] is `null` and [localConstants] is empty. |
| 611 bool get isAbstract => body == null; | 611 bool get isAbstract => body == null; |
| 612 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); | 612 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); |
| 613 } | 613 } |
| 614 | 614 |
| 615 abstract class Initializer implements Expression {} | 615 abstract class Initializer implements Expression, DartSpecificNode {} |
| 616 | 616 |
| 617 class FieldInitializer extends Initializer { | 617 class FieldInitializer extends Initializer { |
| 618 final FieldElement element; | 618 final FieldElement element; |
| 619 Statement body; | 619 Statement body; |
| 620 bool processed = false; | 620 bool processed = false; |
| 621 | 621 |
| 622 FieldInitializer(this.element, this.body); | 622 FieldInitializer(this.element, this.body); |
| 623 | 623 |
| 624 accept(ExpressionVisitor visitor) => visitor.visitFieldInitializer(this); | 624 accept(ExpressionVisitor visitor) => visitor.visitFieldInitializer(this); |
| 625 accept1(ExpressionVisitor1 visitor, arg) { | 625 accept1(ExpressionVisitor1 visitor, arg) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 650 List<ConstDeclaration> localConstants, | 650 List<ConstDeclaration> localConstants, |
| 651 List<ConstantExpression> defaultParameterValues) | 651 List<ConstantExpression> defaultParameterValues) |
| 652 : super(element, parameters, body, localConstants, | 652 : super(element, parameters, body, localConstants, |
| 653 defaultParameterValues); | 653 defaultParameterValues); |
| 654 | 654 |
| 655 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this); | 655 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this); |
| 656 } | 656 } |
| 657 | 657 |
| 658 abstract class JsSpecificNode implements Node {} | 658 abstract class JsSpecificNode implements Node {} |
| 659 | 659 |
| 660 abstract class DartSpecificNode implements Node {} |
| 661 |
| 660 class CreateBox extends Expression implements JsSpecificNode { | 662 class CreateBox extends Expression implements JsSpecificNode { |
| 661 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); | 663 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); |
| 662 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); | 664 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); |
| 663 } | 665 } |
| 664 | 666 |
| 665 class CreateInstance extends Expression implements JsSpecificNode { | 667 class CreateInstance extends Expression implements JsSpecificNode { |
| 666 ClassElement classElement; | 668 ClassElement classElement; |
| 667 List<Expression> arguments; | 669 List<Expression> arguments; |
| 668 | 670 |
| 669 CreateInstance(this.classElement, this.arguments); | 671 CreateInstance(this.classElement, this.arguments); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 visitStatement(node.next); | 922 visitStatement(node.next); |
| 921 } | 923 } |
| 922 | 924 |
| 923 visitCreateBox(CreateBox node) { | 925 visitCreateBox(CreateBox node) { |
| 924 } | 926 } |
| 925 | 927 |
| 926 visitCreateInstance(CreateInstance node) { | 928 visitCreateInstance(CreateInstance node) { |
| 927 node.arguments.forEach(visitExpression); | 929 node.arguments.forEach(visitExpression); |
| 928 } | 930 } |
| 929 } | 931 } |
| OLD | NEW |