| OLD | NEW |
| 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 // SExpressionUnstringifier implements the inverse operation to | 5 // SExpressionUnstringifier implements the inverse operation to |
| 6 // [SExpressionStringifier]. | 6 // [SExpressionStringifier]. |
| 7 | 7 |
| 8 library sexpr_unstringifier; | 8 library sexpr_unstringifier; |
| 9 | 9 |
| 10 import 'package:compiler/src/constants/expressions.dart' | 10 import 'package:compiler/src/constants/expressions.dart' |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 class SExpressionUnstringifier { | 114 class SExpressionUnstringifier { |
| 115 | 115 |
| 116 // Expressions | 116 // Expressions |
| 117 static const String BRANCH = "Branch"; | 117 static const String BRANCH = "Branch"; |
| 118 static const String CONCATENATE_STRINGS = "ConcatenateStrings"; | 118 static const String CONCATENATE_STRINGS = "ConcatenateStrings"; |
| 119 static const String DECLARE_FUNCTION = "DeclareFunction"; | 119 static const String DECLARE_FUNCTION = "DeclareFunction"; |
| 120 static const String INVOKE_CONSTRUCTOR = "InvokeConstructor"; | 120 static const String INVOKE_CONSTRUCTOR = "InvokeConstructor"; |
| 121 static const String INVOKE_CONTINUATION = "InvokeContinuation"; | 121 static const String INVOKE_CONTINUATION = "InvokeContinuation"; |
| 122 static const String INVOKE_CONTINUATION_RECURSIVE = "InvokeContinuation*"; | 122 static const String INVOKE_CONTINUATION_RECURSIVE = "InvokeContinuation*"; |
| 123 static const String INVOKE_STATIC = "InvokeStatic"; | 123 static const String INVOKE_STATIC = "InvokeStatic"; |
| 124 static const String INVOKE_SUPER_METHOD = "InvokeSuperMethod"; | 124 static const String INVOKE_METHOD_DIRECTLY = "InvokeMethodDirectly"; |
| 125 static const String INVOKE_METHOD = "InvokeMethod"; | 125 static const String INVOKE_METHOD = "InvokeMethod"; |
| 126 static const String LET_PRIM = "LetPrim"; | 126 static const String LET_PRIM = "LetPrim"; |
| 127 static const String LET_CONT = "LetCont"; | 127 static const String LET_CONT = "LetCont"; |
| 128 static const String SET_CLOSURE_VARIABLE = "SetClosureVariable"; | 128 static const String SET_CLOSURE_VARIABLE = "SetClosureVariable"; |
| 129 static const String TYPE_OPERATOR = "TypeOperator"; | 129 static const String TYPE_OPERATOR = "TypeOperator"; |
| 130 | 130 |
| 131 // Primitives | 131 // Primitives |
| 132 static const String CONSTANT = "Constant"; | 132 static const String CONSTANT = "Constant"; |
| 133 static const String CREATE_FUNCTION = "CreateFunction"; | 133 static const String CREATE_FUNCTION = "CreateFunction"; |
| 134 static const String GET_CLOSURE_VARIABLE = "GetClosureVariable"; | 134 static const String GET_CLOSURE_VARIABLE = "GetClosureVariable"; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 case INVOKE_CONSTRUCTOR: | 220 case INVOKE_CONSTRUCTOR: |
| 221 return parseInvokeConstructor(); | 221 return parseInvokeConstructor(); |
| 222 case INVOKE_CONTINUATION: | 222 case INVOKE_CONTINUATION: |
| 223 return parseInvokeContinuation(false); | 223 return parseInvokeContinuation(false); |
| 224 case INVOKE_CONTINUATION_RECURSIVE: | 224 case INVOKE_CONTINUATION_RECURSIVE: |
| 225 return parseInvokeContinuation(true); | 225 return parseInvokeContinuation(true); |
| 226 case INVOKE_METHOD: | 226 case INVOKE_METHOD: |
| 227 return parseInvokeMethod(); | 227 return parseInvokeMethod(); |
| 228 case INVOKE_STATIC: | 228 case INVOKE_STATIC: |
| 229 return parseInvokeStatic(); | 229 return parseInvokeStatic(); |
| 230 case INVOKE_SUPER_METHOD: | 230 case INVOKE_METHOD_DIRECTLY: |
| 231 return parseInvokeSuperMethod(); | 231 return parseInvokeMethodDirectly(); |
| 232 case LET_PRIM: | 232 case LET_PRIM: |
| 233 return parseLetPrim(); | 233 return parseLetPrim(); |
| 234 case LET_CONT: | 234 case LET_CONT: |
| 235 return parseLetCont(); | 235 return parseLetCont(); |
| 236 case SET_CLOSURE_VARIABLE: | 236 case SET_CLOSURE_VARIABLE: |
| 237 return parseSetClosureVariable(); | 237 return parseSetClosureVariable(); |
| 238 case TYPE_OPERATOR: | 238 case TYPE_OPERATOR: |
| 239 return parseTypeOperator(); | 239 return parseTypeOperator(); |
| 240 default: | 240 default: |
| 241 assert(false); | 241 assert(false); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 Continuation cont = name2variable[tokens.read()]; | 431 Continuation cont = name2variable[tokens.read()]; |
| 432 assert(cont != null); | 432 assert(cont != null); |
| 433 | 433 |
| 434 Entity entity = new DummyEntity(methodName); | 434 Entity entity = new DummyEntity(methodName); |
| 435 Selector selector = dummySelector(methodName, args.length); | 435 Selector selector = dummySelector(methodName, args.length); |
| 436 | 436 |
| 437 tokens.consumeEnd(); | 437 tokens.consumeEnd(); |
| 438 return new InvokeStatic(entity, selector, cont, args); | 438 return new InvokeStatic(entity, selector, cont, args); |
| 439 } | 439 } |
| 440 | 440 |
| 441 /// (InvokeSuperMethod method (args) cont) | 441 /// (InvokeMethodDirectly receiver method (args) cont) |
| 442 InvokeSuperMethod parseInvokeSuperMethod() { | 442 InvokeMethodDirectly parseInvokeMethodDirectly() { |
| 443 tokens.consumeStart(INVOKE_SUPER_METHOD); | 443 tokens.consumeStart(INVOKE_METHOD_DIRECTLY); |
| 444 |
| 445 Definition receiver = name2variable[tokens.read()]; |
| 446 assert(receiver != null); |
| 444 | 447 |
| 445 String methodName = tokens.read(); | 448 String methodName = tokens.read(); |
| 446 | 449 |
| 447 List<Primitive> args = parsePrimitiveList(); | 450 List<Primitive> args = parsePrimitiveList(); |
| 448 | 451 |
| 449 Continuation cont = name2variable[tokens.read()]; | 452 Continuation cont = name2variable[tokens.read()]; |
| 450 assert(cont != null); | 453 assert(cont != null); |
| 451 | 454 |
| 452 tokens.consumeEnd(); | 455 tokens.consumeEnd(); |
| 456 Element element = new DummyElement(methodName); |
| 453 Selector selector = dummySelector(methodName, args.length); | 457 Selector selector = dummySelector(methodName, args.length); |
| 454 return new InvokeSuperMethod(selector, cont, args); | 458 return new InvokeMethodDirectly(receiver, element, selector, cont, args); |
| 455 } | 459 } |
| 456 | 460 |
| 457 // (rec? name (args) body) | 461 // (rec? name (args) body) |
| 458 Continuation parseContinuation() { | 462 Continuation parseContinuation() { |
| 459 // (rec? name | 463 // (rec? name |
| 460 tokens.consumeStart(); | 464 tokens.consumeStart(); |
| 461 String name = tokens.read(); | 465 String name = tokens.read(); |
| 462 bool isRecursive = name == "rec"; | 466 bool isRecursive = name == "rec"; |
| 463 if (isRecursive) name = tokens.read(); | 467 if (isRecursive) name = tokens.read(); |
| 464 | 468 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 return new ReifyTypeVar(type); | 694 return new ReifyTypeVar(type); |
| 691 } | 695 } |
| 692 | 696 |
| 693 /// (This) | 697 /// (This) |
| 694 This parseThis() { | 698 This parseThis() { |
| 695 tokens.consumeStart(THIS); | 699 tokens.consumeStart(THIS); |
| 696 tokens.consumeEnd(); | 700 tokens.consumeEnd(); |
| 697 return new This(); | 701 return new This(); |
| 698 } | 702 } |
| 699 } | 703 } |
| OLD | NEW |