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

Unified Diff: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart

Issue 231863007: Support local variables in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_tree.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
index 7057a5504a20b48230475302e44b897bf3a0e5eb..5dda57843d7958316e2e1de85a56e703c2d9086c 100644
--- a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
@@ -419,12 +419,39 @@ class IrBuilder extends ResolvedVisitor<ir.Definition> {
if (!Elements.isLocal(element)) return giveup();
if (node.assignmentOperator.source != '=') return giveup();
// Exactly one argument expected for a simple assignment.
- assert(!node.arguments.isEmpty && node.arguments.tail.isEmpty);
+ assert(!node.arguments.isEmpty);
+ assert(node.arguments.tail.isEmpty);
ir.Definition result = node.arguments.head.accept(this);
assignedVars[variableIndex[element]] = result;
return result;
}
+ ir.Definition visitVariableDefinitions(ast.VariableDefinitions node) {
+ assert(isOpen);
+ for (ast.Node definition in node.definitions.nodes) {
+ Element element = elements[definition];
+ // Definitions are either SendSets if there is an initializer, or
+ // Identifiers if there is no initializer.
+ if (definition is ast.SendSet) {
+ assert(!definition.arguments.isEmpty);
+ assert(definition.arguments.tail.isEmpty);
+ ir.Definition initialValue = definition.arguments.head.accept(this);
+ if (!isOpen) return null;
karlklose 2014/04/11 09:01:56 Perhaps add a comment.
Kevin Millikin (Google) 2014/04/11 10:28:51 I will.
+ variableIndex[element] = assignedVars.length;
+ assignedVars.add(initialValue);
+ } else {
+ assert(definition is ast.Identifier);
+ // The initial value is null.
+ // TODO(kmillikin): Consider pooling constants.
+ ir.Constant constant = new ir.Constant(constantSystem.createNull());
+ add(new ir.LetPrim(constant));
+ variableIndex[element] = assignedVars.length;
+ assignedVars.add(constant);
+ }
+ }
+ return null;
+ }
+
static final String ABORT_IRNODE_BUILDER = "IrNode builder aborted";
ir.Definition giveup() => throw ABORT_IRNODE_BUILDER;
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/dart_tree.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698