| OLD | NEW |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 "Unexpected string tag: $tag"); | 80 "Unexpected string tag: $tag"); |
| 81 return null; | 81 return null; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 Element readElement() { | 85 Element readElement() { |
| 86 int elementIndex = readInt(); | 86 int elementIndex = readInt(); |
| 87 return constantPool.get(elementIndex); | 87 return constantPool.get(elementIndex); |
| 88 } | 88 } |
| 89 | 89 |
| 90 types.DartType readDartType() { |
| 91 int typeIndex = readInt(); |
| 92 return constantPool.get(typeIndex); |
| 93 } |
| 94 |
| 90 Selector readSelector() { | 95 Selector readSelector() { |
| 91 int tag = readByte(); | 96 int tag = readByte(); |
| 92 if (tag == Pickles.BACKREFERENCE) { | 97 if (tag == Pickles.BACKREFERENCE) { |
| 93 return readBackReference(); | 98 return readBackReference(); |
| 94 } | 99 } |
| 95 assert(tag == Pickles.SELECTOR_UNTYPED); | 100 assert(tag == Pickles.SELECTOR_UNTYPED); |
| 96 int entryIndex = index++; | 101 int entryIndex = index++; |
| 97 SelectorKind kind = Pickles.selectorKindFromId[readInt()]; | 102 SelectorKind kind = Pickles.selectorKindFromId[readInt()]; |
| 98 String name = readString(); | 103 String name = readString(); |
| 99 Element library = readElement(); | 104 Element library = readElement(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 ir.Expression body = readDelimitedExpressionNode(); | 141 ir.Expression body = readDelimitedExpressionNode(); |
| 137 parameters.forEach((p) => unpickled[index++] = p); | 142 parameters.forEach((p) => unpickled[index++] = p); |
| 138 addExpression(new ir.LetCont(continuation, body)); | 143 addExpression(new ir.LetCont(continuation, body)); |
| 139 break; | 144 break; |
| 140 | 145 |
| 141 // Tail-position expressions. | 146 // Tail-position expressions. |
| 142 case Pickles.NODE_INVOKE_STATIC: | 147 case Pickles.NODE_INVOKE_STATIC: |
| 143 addExpression(readInvokeStatic()); | 148 addExpression(readInvokeStatic()); |
| 144 current = null; | 149 current = null; |
| 145 break; | 150 break; |
| 151 case Pickles.NODE_INVOKE_METHOD: |
| 152 addExpression(readInvokeMethod()); |
| 153 current = null; |
| 154 break; |
| 155 case Pickles.NODE_INVOKE_CONSTRUCTOR: |
| 156 addExpression(readInvokeConstructor()); |
| 157 current = null; |
| 158 break; |
| 146 case Pickles.NODE_INVOKE_CONTINUATION: | 159 case Pickles.NODE_INVOKE_CONTINUATION: |
| 147 addExpression(readInvokeContinuation()); | 160 addExpression(readInvokeContinuation()); |
| 148 current = null; | 161 current = null; |
| 149 break; | 162 break; |
| 150 case Pickles.NODE_BRANCH: | 163 case Pickles.NODE_BRANCH: |
| 151 addExpression(readBranch()); | 164 addExpression(readBranch()); |
| 152 current = null; | 165 current = null; |
| 153 break; | 166 break; |
| 154 | 167 |
| 155 default: | 168 default: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 227 } |
| 215 | 228 |
| 216 ir.InvokeStatic readInvokeStatic() { | 229 ir.InvokeStatic readInvokeStatic() { |
| 217 FunctionElement functionElement = readElement(); | 230 FunctionElement functionElement = readElement(); |
| 218 Selector selector = readSelector(); | 231 Selector selector = readSelector(); |
| 219 ir.Continuation continuation = readBackReference(); | 232 ir.Continuation continuation = readBackReference(); |
| 220 List<ir.Definition> arguments = readBackReferenceList(); | 233 List<ir.Definition> arguments = readBackReferenceList(); |
| 221 return new ir.InvokeStatic(functionElement, selector, continuation, | 234 return new ir.InvokeStatic(functionElement, selector, continuation, |
| 222 arguments); | 235 arguments); |
| 223 } | 236 } |
| 237 |
| 238 ir.InvokeMethod readInvokeMethod() { |
| 239 ir.Definition receiver = readBackReference(); |
| 240 Selector selector = readSelector(); |
| 241 ir.Continuation continuation = readBackReference(); |
| 242 List<ir.Definition> arguments = readBackReferenceList(); |
| 243 return new ir.InvokeMethod(receiver, selector, continuation, arguments); |
| 244 } |
| 245 |
| 246 ir.InvokeConstructor readInvokeConstructor() { |
| 247 types.GenericType type = readDartType(); |
| 248 FunctionElement target = readElement(); |
| 249 ir.Continuation continuation = readBackReference(); |
| 250 List<ir.Definition> arguments = readBackReferenceList(); |
| 251 return new ir.InvokeConstructor(type, target, continuation, arguments); |
| 252 } |
| 224 | 253 |
| 225 ir.InvokeContinuation readInvokeContinuation() { | 254 ir.InvokeContinuation readInvokeContinuation() { |
| 226 ir.Continuation continuation = readBackReference(); | 255 ir.Continuation continuation = readBackReference(); |
| 227 List<ir.Definition> arguments = readBackReferenceList(); | 256 List<ir.Definition> arguments = readBackReferenceList(); |
| 228 return new ir.InvokeContinuation(continuation, arguments); | 257 return new ir.InvokeContinuation(continuation, arguments); |
| 229 } | 258 } |
| 230 | 259 |
| 231 ir.Branch readBranch() { | 260 ir.Branch readBranch() { |
| 232 ir.Condition condition = readCondition(); | 261 ir.Condition condition = readCondition(); |
| 233 ir.Continuation trueContinuation = readBackReference(); | 262 ir.Continuation trueContinuation = readBackReference(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 case Pickles.CONST_STRING_CONS: | 313 case Pickles.CONST_STRING_CONS: |
| 285 return new ast.ConsDartString( | 314 return new ast.ConsDartString( |
| 286 readDartString(readByte()), readDartString(readByte())); | 315 readDartString(readByte()), readDartString(readByte())); |
| 287 default: | 316 default: |
| 288 compiler.internalError(NO_LOCATION_SPANNABLE, | 317 compiler.internalError(NO_LOCATION_SPANNABLE, |
| 289 "Unexpected dart string tag: $tag"); | 318 "Unexpected dart string tag: $tag"); |
| 290 return null; | 319 return null; |
| 291 } | 320 } |
| 292 } | 321 } |
| 293 } | 322 } |
| OLD | NEW |