| 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, InterfaceType, TypeVaria
bleType; | 9 import '../dart_types.dart' show DartType, GenericType, InterfaceType, TypeVaria
bleType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 Not(this.operand); | 385 Not(this.operand); |
| 386 | 386 |
| 387 accept(ExpressionVisitor visitor) => visitor.visitNot(this); | 387 accept(ExpressionVisitor visitor) => visitor.visitNot(this); |
| 388 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); | 388 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitNot(this, arg); |
| 389 } | 389 } |
| 390 | 390 |
| 391 class FunctionExpression extends Expression implements DartSpecificNode { | 391 class FunctionExpression extends Expression implements DartSpecificNode { |
| 392 final FunctionDefinition definition; | 392 final FunctionDefinition definition; |
| 393 | 393 |
| 394 FunctionExpression(this.definition) { | 394 FunctionExpression(this.definition); |
| 395 assert(definition.element.type.returnType.treatAsDynamic); | |
| 396 } | |
| 397 | 395 |
| 398 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); | 396 accept(ExpressionVisitor visitor) => visitor.visitFunctionExpression(this); |
| 399 accept1(ExpressionVisitor1 visitor, arg) { | 397 accept1(ExpressionVisitor1 visitor, arg) { |
| 400 return visitor.visitFunctionExpression(this, arg); | 398 return visitor.visitFunctionExpression(this, arg); |
| 401 } | 399 } |
| 402 } | 400 } |
| 403 | 401 |
| 404 /// Declares a local function. | 402 /// Declares a local function. |
| 405 /// Used for functions that may not occur in expression context due to | 403 /// Used for functions that may not occur in expression context due to |
| 406 /// being recursive or having a return type. | 404 /// being recursive or having a return type. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 action(body); | 697 action(body); |
| 700 } | 698 } |
| 701 | 699 |
| 702 void replaceEachBody(Statement transform(Statement node)) { | 700 void replaceEachBody(Statement transform(Statement node)) { |
| 703 if (isEmpty) return; | 701 if (isEmpty) return; |
| 704 body = transform(body); | 702 body = transform(body); |
| 705 } | 703 } |
| 706 } | 704 } |
| 707 | 705 |
| 708 class FunctionDefinition extends RootNode { | 706 class FunctionDefinition extends RootNode { |
| 709 final FunctionElement element; | 707 final ExecutableElement element; |
| 710 final List<Variable> parameters; | 708 final List<Variable> parameters; |
| 711 Statement body; | 709 Statement body; |
| 712 final List<ConstDeclaration> localConstants; | 710 final List<ConstDeclaration> localConstants; |
| 713 final List<ConstantExpression> defaultParameterValues; | 711 final List<ConstantExpression> defaultParameterValues; |
| 714 | 712 |
| 715 /// Creates a function definition and updates `writeCount` for [parameters]. | 713 /// Creates a function definition and updates `writeCount` for [parameters]. |
| 716 FunctionDefinition(this.element, this.parameters, this.body, | 714 FunctionDefinition(this.element, this.parameters, this.body, |
| 717 this.localConstants, this.defaultParameterValues) { | 715 this.localConstants, this.defaultParameterValues) { |
| 718 for (Variable param in parameters) { | 716 for (Variable param in parameters) { |
| 719 param.writeCount++; // Being a parameter counts as a write. | 717 param.writeCount++; // Being a parameter counts as a write. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 Expression object; | 864 Expression object; |
| 867 Element field; | 865 Element field; |
| 868 Expression value; | 866 Expression value; |
| 869 | 867 |
| 870 SetField(this.object, this.field, this.value); | 868 SetField(this.object, this.field, this.value); |
| 871 | 869 |
| 872 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); | 870 accept(ExpressionVisitor visitor) => visitor.visitSetField(this); |
| 873 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); | 871 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetField(this, arg); |
| 874 } | 872 } |
| 875 | 873 |
| 874 /// Read the value of a field, possibly provoking its initializer to evaluate, |
| 875 /// or tear-off a method. |
| 876 class GetStatic extends Expression { | 876 class GetStatic extends Expression { |
| 877 Element element; | 877 Element element; |
| 878 SourceInformation sourceInformation; | 878 SourceInformation sourceInformation; |
| 879 | 879 |
| 880 GetStatic(this.element, this.sourceInformation); | 880 GetStatic(this.element, this.sourceInformation); |
| 881 | 881 |
| 882 accept(ExpressionVisitor visitor) => visitor.visitGetStatic(this); | 882 accept(ExpressionVisitor visitor) => visitor.visitGetStatic(this); |
| 883 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetStatic(this, arg); | 883 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitGetStatic(this, arg); |
| 884 } | 884 } |
| 885 | 885 |
| 886 | |
| 887 class SetStatic extends Expression { | 886 class SetStatic extends Expression { |
| 888 Element element; | 887 Element element; |
| 889 Expression value; | 888 Expression value; |
| 890 SourceInformation sourceInformation; | 889 SourceInformation sourceInformation; |
| 891 | 890 |
| 892 SetStatic(this.element, this.value, this.sourceInformation); | 891 SetStatic(this.element, this.value, this.sourceInformation); |
| 893 | 892 |
| 894 accept(ExpressionVisitor visitor) => visitor.visitSetStatic(this); | 893 accept(ExpressionVisitor visitor) => visitor.visitSetStatic(this); |
| 895 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetStatic(this, arg); | 894 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitSetStatic(this, arg); |
| 896 } | 895 } |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 visitTypeExpression(TypeExpression node) { | 1454 visitTypeExpression(TypeExpression node) { |
| 1456 _replaceExpressions(node.arguments); | 1455 _replaceExpressions(node.arguments); |
| 1457 return node; | 1456 return node; |
| 1458 } | 1457 } |
| 1459 | 1458 |
| 1460 visitCreateInvocationMirror(CreateInvocationMirror node) { | 1459 visitCreateInvocationMirror(CreateInvocationMirror node) { |
| 1461 _replaceExpressions(node.arguments); | 1460 _replaceExpressions(node.arguments); |
| 1462 return node; | 1461 return node; |
| 1463 } | 1462 } |
| 1464 } | 1463 } |
| OLD | NEW |