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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ir/ir_unpickler.dart

Issue 231863007: Support local variables in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/ir_tracer.dart ('k') | 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 part of dart2js.ir_pickler; 5 part of dart2js.ir_pickler;
6 6
7 class Unpickler { 7 class Unpickler {
8 final Compiler compiler; 8 final Compiler compiler;
9 9
10 final IrConstantPool constantPool; 10 final IrConstantPool constantPool;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 root = current = expr; 114 root = current = expr;
115 } else { 115 } else {
116 current = current.plug(expr); 116 current = current.plug(expr);
117 } 117 }
118 } 118 }
119 119
120 // Read a single expression and plug it into the outer context. 120 // Read a single expression and plug it into the outer context.
121 ir.Expression readExpressionNode() { 121 ir.Expression readExpressionNode() {
122 int tag = readByte(); 122 int tag = readByte();
123 switch (tag) { 123 switch (tag) {
124 // Nontail-position expressions.
124 case Pickles.NODE_CONSTANT: 125 case Pickles.NODE_CONSTANT:
125 ir.Definition constant = readConstant(); 126 ir.Definition constant = readConstant();
126 unpickled[index++] = constant; 127 unpickled[index++] = constant;
127 addExpression(new ir.LetPrim(constant)); 128 addExpression(new ir.LetPrim(constant));
128 break; 129 break;
129 case Pickles.NODE_LET_CONT: 130 case Pickles.NODE_LET_CONT:
130 int parameterCount = readInt(); 131 int parameterCount = readInt();
131 List<ir.Parameter> parameters = new List<ir.Parameter>.generate( 132 List<ir.Parameter> parameters = new List<ir.Parameter>.generate(
132 parameterCount, (i) => new ir.Parameter(null)); 133 parameterCount, (i) => new ir.Parameter(null));
133 ir.Continuation continuation = new ir.Continuation(parameters); 134 ir.Continuation continuation = new ir.Continuation(parameters);
134 unpickled[index++] = continuation; 135 unpickled[index++] = continuation;
135 ir.Expression body = readDelimitedExpressionNode(); 136 ir.Expression body = readDelimitedExpressionNode();
136 parameters.forEach((p) => unpickled[index++] = p); 137 parameters.forEach((p) => unpickled[index++] = p);
137 addExpression(new ir.LetCont(continuation, body)); 138 addExpression(new ir.LetCont(continuation, body));
138 break; 139 break;
140
141 // Tail-position expressions.
139 case Pickles.NODE_INVOKE_STATIC: 142 case Pickles.NODE_INVOKE_STATIC:
140 addExpression(readInvokeStatic()); 143 addExpression(readInvokeStatic());
141 current = null; 144 current = null;
142 break; 145 break;
143 case Pickles.NODE_INVOKE_CONTINUATION: 146 case Pickles.NODE_INVOKE_CONTINUATION:
144 addExpression(readInvokeContinuation()); 147 addExpression(readInvokeContinuation());
145 current = null; 148 current = null;
146 break; 149 break;
150 case Pickles.NODE_BRANCH:
151 addExpression(readBranch());
152 current = null;
153 break;
154
147 default: 155 default:
148 compiler.internalError(NO_LOCATION_SPANNABLE, 156 compiler.internalError(NO_LOCATION_SPANNABLE,
149 "Unexpected expression entry tag: $tag"); 157 "Unexpected expression entry tag: $tag");
150 break; 158 break;
151 } 159 }
152 } 160 }
153 161
154 // Iteratively read expressions until an expression in a tail position 162 // Iteratively read expressions until an expression in a tail position
155 // (e.g., an invocation) is found. Do not change the outer context. 163 // (e.g., an invocation) is found. Do not change the outer context.
156 ir.Expression readDelimitedExpressionNode() { 164 ir.Expression readDelimitedExpressionNode() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 FunctionElement functionElement = readElement(); 217 FunctionElement functionElement = readElement();
210 Selector selector = readSelector(); 218 Selector selector = readSelector();
211 ir.Continuation continuation = readBackReference(); 219 ir.Continuation continuation = readBackReference();
212 List<ir.Definition> arguments = readBackReferenceList(); 220 List<ir.Definition> arguments = readBackReferenceList();
213 return new ir.InvokeStatic(functionElement, selector, continuation, 221 return new ir.InvokeStatic(functionElement, selector, continuation,
214 arguments); 222 arguments);
215 } 223 }
216 224
217 ir.InvokeContinuation readInvokeContinuation() { 225 ir.InvokeContinuation readInvokeContinuation() {
218 ir.Continuation continuation = readBackReference(); 226 ir.Continuation continuation = readBackReference();
219 ir.Definition argument = readBackReference(); 227 List<ir.Definition> arguments = readBackReferenceList();
220 return new ir.InvokeContinuation(continuation, argument); 228 return new ir.InvokeContinuation(continuation, arguments);
229 }
230
231 ir.Branch readBranch() {
232 ir.Condition condition = readCondition();
233 ir.Continuation trueContinuation = readBackReference();
234 ir.Continuation falseContinuation = readBackReference();
235 return new ir.Branch(condition, trueContinuation, falseContinuation);
236 }
237
238 ir.Condition readCondition() {
239 int tag = readByte();
240 assert(tag == Pickles.NODE_IS_TRUE);
241 return readIsTrue();
242 }
243
244 ir.IsTrue readIsTrue() {
245 ir.Definition value = readBackReference();
246 return new ir.IsTrue(value);
221 } 247 }
222 248
223 Constant readConstantValue() { 249 Constant readConstantValue() {
224 int tag = readByte(); 250 int tag = readByte();
225 switch(tag) { 251 switch(tag) {
226 case Pickles.CONST_BOOL: 252 case Pickles.CONST_BOOL:
227 return constantSystem.createBool(readByte() == 1); 253 return constantSystem.createBool(readByte() == 1);
228 case Pickles.CONST_INT: 254 case Pickles.CONST_INT:
229 return constantSystem.createInt(readInt()); 255 return constantSystem.createInt(readInt());
230 case Pickles.CONST_DOUBLE: 256 case Pickles.CONST_DOUBLE:
(...skipping 27 matching lines...) Expand all
258 case Pickles.CONST_STRING_CONS: 284 case Pickles.CONST_STRING_CONS:
259 return new ast.ConsDartString( 285 return new ast.ConsDartString(
260 readDartString(readByte()), readDartString(readByte())); 286 readDartString(readByte()), readDartString(readByte()));
261 default: 287 default:
262 compiler.internalError(NO_LOCATION_SPANNABLE, 288 compiler.internalError(NO_LOCATION_SPANNABLE,
263 "Unexpected dart string tag: $tag"); 289 "Unexpected dart string tag: $tag");
264 return null; 290 return null;
265 } 291 }
266 } 292 }
267 } 293 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/ir_tracer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698