Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable"; | 146 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable"; |
| 147 static const String LITERAL_LIST = "LiteralList"; | 147 static const String LITERAL_LIST = "LiteralList"; |
| 148 static const String LITERAL_MAP = "LiteralMap"; | 148 static const String LITERAL_MAP = "LiteralMap"; |
| 149 static const String REIFY_TYPE_VAR = "ReifyTypeVar"; | 149 static const String REIFY_TYPE_VAR = "ReifyTypeVar"; |
| 150 static const String GET_STATIC = "GetStatic"; | 150 static const String GET_STATIC = "GetStatic"; |
| 151 static const String TYPE_TEST = "TypeTest"; | 151 static const String TYPE_TEST = "TypeTest"; |
| 152 static const String APPLY_BUILTIN_OPERATOR = "ApplyBuiltinOperator"; | 152 static const String APPLY_BUILTIN_OPERATOR = "ApplyBuiltinOperator"; |
| 153 static const String GET_LENGTH = "GetLength"; | 153 static const String GET_LENGTH = "GetLength"; |
| 154 static const String GET_INDEX = "GetIndex"; | 154 static const String GET_INDEX = "GetIndex"; |
| 155 static const String SET_INDEX = "SetIndex"; | 155 static const String SET_INDEX = "SetIndex"; |
| 156 static const String GET_FIELD = "GetField"; | |
| 157 static const String SET_FIELD = "SetField"; | |
| 156 | 158 |
| 157 // Other | 159 // Other |
| 158 static const String FUNCTION_DEFINITION = "FunctionDefinition"; | 160 static const String FUNCTION_DEFINITION = "FunctionDefinition"; |
| 159 static const String IS_TRUE = "IsTrue"; | 161 static const String IS_TRUE = "IsTrue"; |
| 160 | 162 |
| 161 // Constants | 163 // Constants |
| 162 static const String BOOL = "Bool"; | 164 static const String BOOL = "Bool"; |
| 163 static const String DOUBLE = "Double"; | 165 static const String DOUBLE = "Double"; |
| 164 static const String INT = "Int"; | 166 static const String INT = "Int"; |
| 165 static const String NULL = "Null"; | 167 static const String NULL = "Null"; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 case INVOKE_STATIC: | 246 case INVOKE_STATIC: |
| 245 return parseInvokeStatic(); | 247 return parseInvokeStatic(); |
| 246 case INVOKE_METHOD_DIRECTLY: | 248 case INVOKE_METHOD_DIRECTLY: |
| 247 return parseInvokeMethodDirectly(); | 249 return parseInvokeMethodDirectly(); |
| 248 case LET_PRIM: | 250 case LET_PRIM: |
| 249 return parseLetPrim(); | 251 return parseLetPrim(); |
| 250 case LET_CONT: | 252 case LET_CONT: |
| 251 return parseLetCont(); | 253 return parseLetCont(); |
| 252 case LET_MUTABLE: | 254 case LET_MUTABLE: |
| 253 return parseLetMutable(); | 255 return parseLetMutable(); |
| 254 case SET_MUTABLE_VARIABLE: | |
| 255 return parseSetMutableVariable(); | |
| 256 case TYPE_CAST: | 256 case TYPE_CAST: |
| 257 return parseTypeCast(); | 257 return parseTypeCast(); |
| 258 case SET_STATIC: | |
| 259 return parseSetStatic(); | |
| 260 case GET_LAZY_STATIC: | 258 case GET_LAZY_STATIC: |
| 261 return parseGetLazyStatic(); | 259 return parseGetLazyStatic(); |
| 262 case UNREACHABLE: | 260 case UNREACHABLE: |
| 263 return parseUnreachable(); | 261 return parseUnreachable(); |
| 264 default: | 262 default: |
| 265 assert(false); | 263 assert(false); |
| 266 } | 264 } |
| 267 | 265 |
| 268 return null; | 266 return null; |
| 269 } | 267 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 String name = tokens.read(); | 537 String name = tokens.read(); |
| 540 MutableVariable local = addMutableVariable(name); | 538 MutableVariable local = addMutableVariable(name); |
| 541 Primitive value = name2variable[tokens.read()]; | 539 Primitive value = name2variable[tokens.read()]; |
| 542 tokens.consumeEnd(); | 540 tokens.consumeEnd(); |
| 543 | 541 |
| 544 Expression body = parseExpression(); | 542 Expression body = parseExpression(); |
| 545 tokens.consumeEnd(); | 543 tokens.consumeEnd(); |
| 546 return new LetMutable(local, value)..plug(body); | 544 return new LetMutable(local, value)..plug(body); |
| 547 } | 545 } |
| 548 | 546 |
| 549 /// (SetMutableVariable name value body) | 547 /// (SetMutableVariable name value) |
| 550 SetMutableVariable parseSetMutableVariable() { | 548 SetMutableVariable parseSetMutableVariable() { |
| 551 tokens.consumeStart(SET_MUTABLE_VARIABLE); | 549 tokens.consumeStart(SET_MUTABLE_VARIABLE); |
| 552 | 550 |
| 553 MutableVariable local = name2variable[tokens.read()]; | 551 MutableVariable local = name2variable[tokens.read()]; |
| 554 Primitive value = name2variable[tokens.read()]; | 552 Primitive value = name2variable[tokens.read()]; |
| 555 assert(value != null); | 553 assert(value != null); |
| 556 | 554 |
| 557 Expression body = parseExpression(); | |
| 558 | |
| 559 tokens.consumeEnd(); | 555 tokens.consumeEnd(); |
| 560 return new SetMutableVariable(local, value) | 556 return new SetMutableVariable(local, value); |
| 561 ..plug(body); | |
| 562 } | 557 } |
| 563 | 558 |
| 564 /// (TypeCast value type args cont) | 559 /// (TypeCast value type args cont) |
| 565 TypeCast parseTypeCast() { | 560 TypeCast parseTypeCast() { |
| 566 tokens.consumeStart(TYPE_CAST); | 561 tokens.consumeStart(TYPE_CAST); |
| 567 | 562 |
| 568 Primitive value = name2variable[tokens.read()]; | 563 Primitive value = name2variable[tokens.read()]; |
| 569 assert(value != null); | 564 assert(value != null); |
| 570 | 565 |
| 571 dart_types.DartType type = new DummyNamedType(tokens.read()); | 566 dart_types.DartType type = new DummyNamedType(tokens.read()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 /// (SetIndex object index value) | 628 /// (SetIndex object index value) |
| 634 SetIndex parseSetIndex() { | 629 SetIndex parseSetIndex() { |
| 635 tokens.consumeStart(SET_INDEX); | 630 tokens.consumeStart(SET_INDEX); |
| 636 Primitive object = name2variable[tokens.read()]; | 631 Primitive object = name2variable[tokens.read()]; |
| 637 Primitive index = name2variable[tokens.read()]; | 632 Primitive index = name2variable[tokens.read()]; |
| 638 Primitive value = name2variable[tokens.read()]; | 633 Primitive value = name2variable[tokens.read()]; |
| 639 tokens.consumeEnd(); | 634 tokens.consumeEnd(); |
| 640 return new SetIndex(object, index, value); | 635 return new SetIndex(object, index, value); |
| 641 } | 636 } |
| 642 | 637 |
| 643 /// (SetStatic field value body) | 638 /// (SetStatic field value) |
| 644 SetStatic parseSetStatic() { | 639 SetStatic parseSetStatic() { |
| 645 tokens.consumeStart(SET_STATIC); | 640 tokens.consumeStart(SET_STATIC); |
| 646 | 641 |
| 647 Element fieldElement = new DummyElement(tokens.read()); | 642 Element fieldElement = new DummyElement(tokens.read()); |
| 648 Primitive value = name2variable[tokens.read()]; | 643 Primitive value = name2variable[tokens.read()]; |
| 649 assert(value != null); | 644 assert(value != null); |
| 650 Expression body = parseExpression(); | |
| 651 | 645 |
| 652 tokens.consumeEnd(); | 646 tokens.consumeEnd(); |
| 653 return new SetStatic(fieldElement, value, null)..plug(body); | 647 return new SetStatic(fieldElement, value, null); |
| 654 } | 648 } |
| 655 | 649 |
| 656 /// (GetLazyStatic field cont) | 650 /// (GetLazyStatic field cont) |
| 657 GetLazyStatic parseGetLazyStatic() { | 651 GetLazyStatic parseGetLazyStatic() { |
| 658 tokens.consumeStart(GET_LAZY_STATIC); | 652 tokens.consumeStart(GET_LAZY_STATIC); |
| 659 | 653 |
| 660 Element fieldElement = new DummyElement(tokens.read()); | 654 Element fieldElement = new DummyElement(tokens.read()); |
| 661 Continuation cont = name2variable[tokens.read()]; | 655 Continuation cont = name2variable[tokens.read()]; |
| 662 assert(cont != null); | 656 assert(cont != null); |
| 663 | 657 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 case TYPE_TEST: | 707 case TYPE_TEST: |
| 714 return parseTypeTest(); | 708 return parseTypeTest(); |
| 715 case APPLY_BUILTIN_OPERATOR: | 709 case APPLY_BUILTIN_OPERATOR: |
| 716 return parseApplyBuiltinOperator(); | 710 return parseApplyBuiltinOperator(); |
| 717 case GET_LENGTH: | 711 case GET_LENGTH: |
| 718 return parseGetLength(); | 712 return parseGetLength(); |
| 719 case GET_INDEX: | 713 case GET_INDEX: |
| 720 return parseGetIndex(); | 714 return parseGetIndex(); |
| 721 case SET_INDEX: | 715 case SET_INDEX: |
| 722 return parseSetIndex(); | 716 return parseSetIndex(); |
| 717 case SET_MUTABLE_VARIABLE: | |
| 718 return parseSetMutableVariable(); | |
| 719 case SET_STATIC: | |
| 720 return parseSetStatic(); | |
| 721 case GET_FIELD: | |
| 722 return parseGetField(); | |
| 723 case SET_FIELD: | |
| 724 return parseSetField(); | |
| 723 default: | 725 default: |
| 724 assert(false); | 726 assert(false); |
| 725 } | 727 } |
| 726 | 728 |
| 727 return null; | 729 return null; |
| 728 } | 730 } |
| 729 | 731 |
| 730 /// (Constant (constant)) | 732 /// (Constant (constant)) |
| 731 Constant parseConstant() { | 733 Constant parseConstant() { |
| 732 tokens.consumeStart(CONSTANT); | 734 tokens.consumeStart(CONSTANT); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 | 850 |
| 849 /// (GetStatic field) | 851 /// (GetStatic field) |
| 850 GetStatic parseGetStatic() { | 852 GetStatic parseGetStatic() { |
| 851 tokens.consumeStart(GET_STATIC); | 853 tokens.consumeStart(GET_STATIC); |
| 852 | 854 |
| 853 Element field = new DummyElement(tokens.read()); | 855 Element field = new DummyElement(tokens.read()); |
| 854 | 856 |
| 855 tokens.consumeEnd(); | 857 tokens.consumeEnd(); |
| 856 return new GetStatic(field, null); | 858 return new GetStatic(field, null); |
| 857 } | 859 } |
| 860 | |
| 861 /// (GetField object field) | |
| 862 GetField parseGetField() { | |
| 863 tokens.consumeStart(GET_FIELD); | |
| 864 | |
| 865 Primitive object = name2variable[tokens.read()]; | |
| 866 Element field = new DummyElement(tokens.read()); | |
| 867 | |
| 868 tokens.consumeEnd(); | |
| 869 return new GetField(object, field); | |
| 870 } | |
| 871 | |
| 872 /// (SetField object field value) | |
| 873 SetField parseSetField() { | |
| 874 tokens.consumeStart(SET_FIELD); | |
| 875 | |
| 876 Primitive object = name2variable[tokens.read()]; | |
| 877 Element field = new DummyElement(tokens.read()); | |
| 878 Primitive value = name2variable[tokens.read()]; | |
| 879 | |
| 880 tokens.consumeEnd(); | |
| 881 return new SetField(object, field, value); | |
| 882 } | |
|
asgerf
2015/07/20 13:35:23
These cases we simply missing from the parser befo
| |
| 858 } | 883 } |
| OLD | NEW |