Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart

Issue 762213002: Support top-level field declaration and assignment in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698