| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 applyPass(Pass pass); | 500 applyPass(Pass pass); |
| 501 } | 501 } |
| 502 | 502 |
| 503 class FieldDefinition extends Node implements ExecutableDefinition { | 503 class FieldDefinition extends Node implements ExecutableDefinition { |
| 504 final FieldElement element; | 504 final FieldElement element; |
| 505 // The `body` of a field is its initializer. | 505 // The `body` of a field is its initializer. |
| 506 Statement body; | 506 Statement body; |
| 507 | 507 |
| 508 FieldDefinition(this.element, this.body); | 508 FieldDefinition(this.element, this.body); |
| 509 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); | 509 applyPass(Pass pass) => pass.rewriteFieldDefinition(this); |
| 510 |
| 511 /// `true` if this field has no initializer. |
| 512 /// |
| 513 /// If `true` [body] is `null`. |
| 514 /// |
| 515 /// This is different from a initializer that is `null`. Consider this class: |
| 516 /// |
| 517 /// class Class { |
| 518 /// final field; |
| 519 /// Class.a(this.field); |
| 520 /// Class.b() : this.field = null; |
| 521 /// Class.c(); |
| 522 /// } |
| 523 /// |
| 524 /// If `field` had an initializer, possibly `null`, constructors `Class.a` and |
| 525 /// `Class.b` would be invalid, and since `field` has no initializer |
| 526 /// constructor `Class.c` is invalid. We therefore need to distinguish the two |
| 527 /// cases. |
| 528 bool get hasInitializer => body != null; |
| 510 } | 529 } |
| 511 | 530 |
| 512 class FunctionDefinition extends Node implements ExecutableDefinition { | 531 class FunctionDefinition extends Node implements ExecutableDefinition { |
| 513 final FunctionElement element; | 532 final FunctionElement element; |
| 514 final List<Variable> parameters; | 533 final List<Variable> parameters; |
| 515 Statement body; | 534 Statement body; |
| 516 final List<ConstDeclaration> localConstants; | 535 final List<ConstDeclaration> localConstants; |
| 517 final List<ConstantExpression> defaultParameterValues; | 536 final List<ConstantExpression> defaultParameterValues; |
| 518 | 537 |
| 519 FunctionDefinition(this.element, this.parameters, this.body, | 538 FunctionDefinition(this.element, this.parameters, this.body, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 visitFunctionDeclaration(FunctionDeclaration node) { | 691 visitFunctionDeclaration(FunctionDeclaration node) { |
| 673 visitFunctionDefinition(node.definition); | 692 visitFunctionDefinition(node.definition); |
| 674 visitStatement(node.next); | 693 visitStatement(node.next); |
| 675 } | 694 } |
| 676 | 695 |
| 677 visitExpressionStatement(ExpressionStatement node) { | 696 visitExpressionStatement(ExpressionStatement node) { |
| 678 visitExpression(node.expression); | 697 visitExpression(node.expression); |
| 679 visitStatement(node.next); | 698 visitStatement(node.next); |
| 680 } | 699 } |
| 681 } | 700 } |
| OLD | NEW |