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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.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: Updated cf. 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_builder; 5 library tree_ir_builder;
6 6
7 import '../dart2jslib.dart' as dart2js; 7 import '../dart2jslib.dart' as dart2js;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ExecutableDefinition build(cps_ir.ExecutableDefinition node) { 119 ExecutableDefinition build(cps_ir.ExecutableDefinition node) {
120 if (node is cps_ir.FieldDefinition) { 120 if (node is cps_ir.FieldDefinition) {
121 return buildField(node); 121 return buildField(node);
122 } else if (node is cps_ir.FunctionDefinition) { 122 } else if (node is cps_ir.FunctionDefinition) {
123 return buildFunction(node); 123 return buildFunction(node);
124 } 124 }
125 assert(false); 125 assert(false);
126 } 126 }
127 127
128 FieldDefinition buildField(cps_ir.FieldDefinition node) { 128 FieldDefinition buildField(cps_ir.FieldDefinition node) {
129 currentElement = node.element; 129 Statement body;
130 returnContinuation = node.returnContinuation; 130 if (node.hasInitializer) {
131 currentElement = node.element;
132 returnContinuation = node.returnContinuation;
131 133
132 phiTempVar = new Variable(node.element, null); 134 phiTempVar = new Variable(node.element, null);
133 135
134 return new FieldDefinition(node.element, visit(node.body)); 136 body = visit(node.body);
137 }
138 return new FieldDefinition(node.element, body);
135 } 139 }
136 140
137 FunctionDefinition buildFunction(cps_ir.FunctionDefinition node) { 141 FunctionDefinition buildFunction(cps_ir.FunctionDefinition node) {
138 currentElement = node.element; 142 currentElement = node.element;
139 List<Variable> parameters = <Variable>[]; 143 List<Variable> parameters = <Variable>[];
140 for (cps_ir.Parameter p in node.parameters) { 144 for (cps_ir.Parameter p in node.parameters) {
141 Variable parameter = getVariable(p); 145 Variable parameter = getVariable(p);
142 assert(parameter != null); 146 assert(parameter != null);
143 ++parameter.writeCount; // Being a parameter counts as a write. 147 ++parameter.writeCount; // Being a parameter counts as a write.
144 parameters.add(parameter); 148 parameters.add(parameter);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 500
497 Expression visitIdentical(cps_ir.Identical node) { 501 Expression visitIdentical(cps_ir.Identical node) {
498 return new InvokeStatic( 502 return new InvokeStatic(
499 compiler.identicalFunction, 503 compiler.identicalFunction,
500 identicalSelector, 504 identicalSelector,
501 <Expression>[getVariableReference(node.left), 505 <Expression>[getVariableReference(node.left),
502 getVariableReference(node.right)]); 506 getVariableReference(node.right)]);
503 } 507 }
504 } 508 }
505 509
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698