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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1211393003: dart2js cps: Fix translation of local constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase Created 5 years, 5 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 currentMask: elements.getCurrentTypeMask(node), 332 currentMask: elements.getCurrentTypeMask(node),
333 moveNextMask: elements.getMoveNextTypeMask(node), 333 moveNextMask: elements.getMoveNextTypeMask(node),
334 iteratorMask: elements.getIteratorTypeMask(node), 334 iteratorMask: elements.getIteratorTypeMask(node),
335 buildBody: subbuild(node.body), 335 buildBody: subbuild(node.body),
336 target: elements.getTargetDefinition(node), 336 target: elements.getTargetDefinition(node),
337 closureScope: getClosureScopeForNode(node)); 337 closureScope: getClosureScopeForNode(node));
338 } 338 }
339 339
340 ir.Primitive visitVariableDefinitions(ast.VariableDefinitions node) { 340 ir.Primitive visitVariableDefinitions(ast.VariableDefinitions node) {
341 assert(irBuilder.isOpen); 341 assert(irBuilder.isOpen);
342 if (node.modifiers.isConst) { 342 for (ast.Node definition in node.definitions.nodes) {
343 // Do nothing. 343 Element element = elements[definition];
344 // handleLocalConstantGet inlines the constant at use-site. 344 ir.Primitive initialValue;
345 } else { 345 // Definitions are either SendSets if there is an initializer, or
346 for (ast.Node definition in node.definitions.nodes) { 346 // Identifiers if there is no initializer.
347 Element element = elements[definition]; 347 if (definition is ast.SendSet) {
348 ir.Primitive initialValue; 348 assert(!definition.arguments.isEmpty);
349 // Definitions are either SendSets if there is an initializer, or 349 assert(definition.arguments.tail.isEmpty);
350 // Identifiers if there is no initializer. 350 initialValue = visit(definition.arguments.head);
351 if (definition is ast.SendSet) { 351 } else {
352 assert(!definition.arguments.isEmpty); 352 assert(definition is ast.Identifier);
353 assert(definition.arguments.tail.isEmpty);
354 initialValue = visit(definition.arguments.head);
355 } else {
356 assert(definition is ast.Identifier);
357 }
358 irBuilder.declareLocalVariable(element, initialValue: initialValue);
359 } 353 }
354 irBuilder.declareLocalVariable(element, initialValue: initialValue);
360 } 355 }
361 return null; 356 return null;
362 } 357 }
363 358
364 // Build(Return(e), C) = C'[InvokeContinuation(return, x)] 359 // Build(Return(e), C) = C'[InvokeContinuation(return, x)]
365 // where (C', x) = Build(e, C) 360 // where (C', x) = Build(e, C)
366 // 361 //
367 // Return without a subexpression is translated as if it were return null. 362 // Return without a subexpression is translated as if it were return null.
368 ir.Primitive visitReturn(ast.Return node) { 363 ir.Primitive visitReturn(ast.Return node) {
369 assert(irBuilder.isOpen); 364 assert(irBuilder.isOpen);
(...skipping 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 } 3247 }
3253 3248
3254 processSetStatic(ir.SetStatic node) { 3249 processSetStatic(ir.SetStatic node) {
3255 node.body = replacementFor(node.body); 3250 node.body = replacementFor(node.body);
3256 } 3251 }
3257 3252
3258 processContinuation(ir.Continuation node) { 3253 processContinuation(ir.Continuation node) {
3259 node.body = replacementFor(node.body); 3254 node.body = replacementFor(node.body);
3260 } 3255 }
3261 } 3256 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698