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

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

Issue 759193005: Add support for fields to the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase 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;
11 import '../elements/elements.dart'; 11 import '../elements/elements.dart';
12 import '../universe/universe.dart'; 12 import '../universe/universe.dart';
13 import '../universe/universe.dart' show Selector; 13 import '../universe/universe.dart' show Selector;
14 import 'optimization/optimization.dart';
14 15
15 // The Tree language is the target of translation out of the CPS-based IR. 16 // The Tree language is the target of translation out of the CPS-based IR.
16 // 17 //
17 // The translation from CPS to Dart consists of several stages. Among the 18 // The translation from CPS to Dart consists of several stages. Among the
18 // stages are translation to direct style, translation out of SSA, eliminating 19 // stages are translation to direct style, translation out of SSA, eliminating
19 // unnecessary names, recognizing high-level control constructs. Combining 20 // unnecessary names, recognizing high-level control constructs. Combining
20 // these separate concerns is complicated and the constraints of the CPS-based 21 // these separate concerns is complicated and the constraints of the CPS-based
21 // language do not permit a multi-stage translation. 22 // language do not permit a multi-stage translation.
22 // 23 //
23 // For that reason, CPS is translated to the direct-style language Tree. 24 // For that reason, CPS is translated to the direct-style language Tree.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 80
80 /// The [LabeledStatement] or [WhileTrue] binding this label. 81 /// The [LabeledStatement] or [WhileTrue] binding this label.
81 JumpTarget binding; 82 JumpTarget binding;
82 } 83 }
83 84
84 /** 85 /**
85 * Variables are [Expression]s. 86 * Variables are [Expression]s.
86 */ 87 */
87 class Variable extends Expression { 88 class Variable extends Expression {
88 /// Function that declares this variable. 89 /// Function that declares this variable.
89 FunctionDefinition host; 90 ExecutableElement host;
90 91
91 /// [Entity] used for synthesizing a name for the variable. 92 /// [Entity] used for synthesizing a name for the variable.
92 /// Different variables may have the same entity. May be null. 93 /// Different variables may have the same entity. May be null.
93 Entity element; 94 Entity element;
94 95
95 int readCount = 0; 96 int readCount = 0;
96 97
97 /// Number of places where this variable occurs as: 98 /// Number of places where this variable occurs as:
98 /// - left-hand of an [Assign] 99 /// - left-hand of an [Assign]
99 /// - left-hand of a [FunctionDeclaration] 100 /// - left-hand of a [FunctionDeclaration]
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 486
486 class ExpressionStatement extends Statement { 487 class ExpressionStatement extends Statement {
487 Statement next; 488 Statement next;
488 Expression expression; 489 Expression expression;
489 490
490 ExpressionStatement(this.expression, this.next); 491 ExpressionStatement(this.expression, this.next);
491 492
492 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this); 493 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this);
493 } 494 }
494 495
495 class FunctionDefinition extends Node { 496 abstract class ExecutableDefinition {
497 ExecutableElement get element;
498 Statement body;
499
500 applyPass(Pass pass);
501 }
502
503 class FieldDefinition extends Node implements ExecutableDefinition {
504 final FieldElement element;
505 // The `body` of a field is its initializer.
506 Statement body;
507
508 FieldDefinition(this.element, this.body);
509 applyPass(Pass pass) => pass.rewriteFieldDefinition(this);
510 }
511
512 class FunctionDefinition extends Node implements ExecutableDefinition {
496 final FunctionElement element; 513 final FunctionElement element;
497 final List<Variable> parameters; 514 final List<Variable> parameters;
498 Statement body; 515 Statement body;
499 final List<ConstDeclaration> localConstants; 516 final List<ConstDeclaration> localConstants;
500 final List<ConstantExpression> defaultParameterValues; 517 final List<ConstantExpression> defaultParameterValues;
501 518
502 FunctionDefinition(this.element, this.parameters, this.body, 519 FunctionDefinition(this.element, this.parameters, this.body,
503 this.localConstants, this.defaultParameterValues); 520 this.localConstants, this.defaultParameterValues);
504 521
505 /// Returns `true` if this function is abstract. 522 /// Returns `true` if this function is abstract.
506 /// 523 ///
507 /// If `true` [body] is `null` and [localConstants] is empty. 524 /// If `true` [body] is `null` and [localConstants] is empty.
508 bool get isAbstract => body == null; 525 bool get isAbstract => body == null;
526 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this);
509 } 527 }
510 528
511 abstract class ExpressionVisitor<E> { 529 abstract class ExpressionVisitor<E> {
512 E visitExpression(Expression e) => e.accept(this); 530 E visitExpression(Expression e) => e.accept(this);
513 E visitVariable(Variable node); 531 E visitVariable(Variable node);
514 E visitInvokeStatic(InvokeStatic node); 532 E visitInvokeStatic(InvokeStatic node);
515 E visitInvokeMethod(InvokeMethod node); 533 E visitInvokeMethod(InvokeMethod node);
516 E visitInvokeSuperMethod(InvokeSuperMethod node); 534 E visitInvokeSuperMethod(InvokeSuperMethod node);
517 E visitInvokeConstructor(InvokeConstructor node); 535 E visitInvokeConstructor(InvokeConstructor node);
518 E visitConcatenateStrings(ConcatenateStrings node); 536 E visitConcatenateStrings(ConcatenateStrings node);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 visitFunctionDeclaration(FunctionDeclaration node) { 672 visitFunctionDeclaration(FunctionDeclaration node) {
655 visitFunctionDefinition(node.definition); 673 visitFunctionDefinition(node.definition);
656 visitStatement(node.next); 674 visitStatement(node.next);
657 } 675 }
658 676
659 visitExpressionStatement(ExpressionStatement node) { 677 visitExpressionStatement(ExpressionStatement node) {
660 visitExpression(node.expression); 678 visitExpression(node.expression);
661 visitStatement(node.next); 679 visitStatement(node.next);
662 } 680 }
663 } 681 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698