| 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 '../cps_ir/cps_ir_nodes.dart' as cps_ir; | 9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; |
| 10 import '../dart_types.dart' show DartType, GenericType; | 10 import '../dart_types.dart' show DartType, GenericType; |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 applyPass(Pass pass); | 560 applyPass(Pass pass); |
| 561 } | 561 } |
| 562 | 562 |
| 563 class FieldDefinition extends Node implements ExecutableDefinition { | 563 class FieldDefinition extends Node implements ExecutableDefinition { |
| 564 final FieldElement element; | 564 final FieldElement element; |
| 565 // The `body` of a field is its initializer. | 565 // The `body` of a field is its initializer. |
| 566 Statement body; | 566 Statement body; |
| 567 | 567 |
| 568 FieldDefinition(this.element, this.body); | 568 FieldDefinition(this.element, this.body); |
| 569 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); | 569 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); |
| 570 |
| 571 /// `true` if this field has no initializer. |
| 572 /// |
| 573 /// If `true` [body] is `null`. |
| 574 /// |
| 575 /// This is different from a initializer that is `null`. Consider this class: |
| 576 /// |
| 577 /// class Class { |
| 578 /// final field; |
| 579 /// Class.a(this.field); |
| 580 /// Class.b() : this.field = null; |
| 581 /// Class.c(); |
| 582 /// } |
| 583 /// |
| 584 /// If `field` had an initializer, possibly `null`, constructors `Class.a` and |
| 585 /// `Class.b` would be invalid, and since `field` has no initializer |
| 586 /// constructor `Class.c` is invalid. We therefore need to distinguish the two |
| 587 /// cases. |
| 588 bool get hasInitializer => body != null; |
| 570 } | 589 } |
| 571 | 590 |
| 572 class FunctionDefinition extends Node implements ExecutableDefinition { | 591 class FunctionDefinition extends Node implements ExecutableDefinition { |
| 573 final FunctionElement element; | 592 final FunctionElement element; |
| 574 final List<Variable> parameters; | 593 final List<Variable> parameters; |
| 575 Statement body; | 594 Statement body; |
| 576 final List<ConstDeclaration> localConstants; | 595 final List<ConstDeclaration> localConstants; |
| 577 final List<ConstantExpression> defaultParameterValues; | 596 final List<ConstantExpression> defaultParameterValues; |
| 578 | 597 |
| 579 FunctionDefinition(this.element, this.parameters, this.body, | 598 FunctionDefinition(this.element, this.parameters, this.body, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 visitFunctionDeclaration(FunctionDeclaration node) { | 791 visitFunctionDeclaration(FunctionDeclaration node) { |
| 773 visitFunctionDefinition(node.definition); | 792 visitFunctionDefinition(node.definition); |
| 774 visitStatement(node.next); | 793 visitStatement(node.next); |
| 775 } | 794 } |
| 776 | 795 |
| 777 visitExpressionStatement(ExpressionStatement node) { | 796 visitExpressionStatement(ExpressionStatement node) { |
| 778 visitExpression(node.expression); | 797 visitExpression(node.expression); |
| 779 visitStatement(node.next); | 798 visitStatement(node.next); |
| 780 } | 799 } |
| 781 } | 800 } |
| OLD | NEW |