| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Primitives | 143 // Primitives |
| 144 static const String CONSTANT = "Constant"; | 144 static const String CONSTANT = "Constant"; |
| 145 static const String CREATE_FUNCTION = "CreateFunction"; | 145 static const String CREATE_FUNCTION = "CreateFunction"; |
| 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"; |
| 154 static const String GET_INDEX = "GetIndex"; |
| 155 static const String SET_INDEX = "SetIndex"; |
| 153 | 156 |
| 154 // Other | 157 // Other |
| 155 static const String FUNCTION_DEFINITION = "FunctionDefinition"; | 158 static const String FUNCTION_DEFINITION = "FunctionDefinition"; |
| 156 static const String IS_TRUE = "IsTrue"; | 159 static const String IS_TRUE = "IsTrue"; |
| 157 | 160 |
| 158 // Constants | 161 // Constants |
| 159 static const String BOOL = "Bool"; | 162 static const String BOOL = "Bool"; |
| 160 static const String DOUBLE = "Double"; | 163 static const String DOUBLE = "Double"; |
| 161 static const String INT = "Int"; | 164 static const String INT = "Int"; |
| 162 static const String NULL = "Null"; | 165 static const String NULL = "Null"; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 break; | 606 break; |
| 604 } | 607 } |
| 605 } | 608 } |
| 606 assert(operator != null); | 609 assert(operator != null); |
| 607 List<ir.Primitive> arguments = parsePrimitiveList(); | 610 List<ir.Primitive> arguments = parsePrimitiveList(); |
| 608 | 611 |
| 609 tokens.consumeEnd(); | 612 tokens.consumeEnd(); |
| 610 return new ApplyBuiltinOperator(operator, arguments); | 613 return new ApplyBuiltinOperator(operator, arguments); |
| 611 } | 614 } |
| 612 | 615 |
| 616 /// (GetLength object) |
| 617 GetLength parseGetLength() { |
| 618 tokens.consumeStart(GET_LENGTH); |
| 619 Primitive object = name2variable[tokens.read()]; |
| 620 tokens.consumeEnd(); |
| 621 return new GetLength(object); |
| 622 } |
| 623 |
| 624 /// (GetIndex object index) |
| 625 GetIndex parseGetIndex() { |
| 626 tokens.consumeStart(GET_INDEX); |
| 627 Primitive object = name2variable[tokens.read()]; |
| 628 Primitive index = name2variable[tokens.read()]; |
| 629 tokens.consumeEnd(); |
| 630 return new GetIndex(object, index); |
| 631 } |
| 632 |
| 633 /// (SetIndex object index value) |
| 634 SetIndex parseSetIndex() { |
| 635 tokens.consumeStart(SET_INDEX); |
| 636 Primitive object = name2variable[tokens.read()]; |
| 637 Primitive index = name2variable[tokens.read()]; |
| 638 Primitive value = name2variable[tokens.read()]; |
| 639 tokens.consumeEnd(); |
| 640 return new SetIndex(object, index, value); |
| 641 } |
| 642 |
| 613 /// (SetStatic field value body) | 643 /// (SetStatic field value body) |
| 614 SetStatic parseSetStatic() { | 644 SetStatic parseSetStatic() { |
| 615 tokens.consumeStart(SET_STATIC); | 645 tokens.consumeStart(SET_STATIC); |
| 616 | 646 |
| 617 Element fieldElement = new DummyElement(tokens.read()); | 647 Element fieldElement = new DummyElement(tokens.read()); |
| 618 Primitive value = name2variable[tokens.read()]; | 648 Primitive value = name2variable[tokens.read()]; |
| 619 assert(value != null); | 649 assert(value != null); |
| 620 Expression body = parseExpression(); | 650 Expression body = parseExpression(); |
| 621 | 651 |
| 622 tokens.consumeEnd(); | 652 tokens.consumeEnd(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 case LITERAL_MAP: | 707 case LITERAL_MAP: |
| 678 return parseLiteralMap(); | 708 return parseLiteralMap(); |
| 679 case REIFY_TYPE_VAR: | 709 case REIFY_TYPE_VAR: |
| 680 return parseReifyTypeVar(); | 710 return parseReifyTypeVar(); |
| 681 case GET_STATIC: | 711 case GET_STATIC: |
| 682 return parseGetStatic(); | 712 return parseGetStatic(); |
| 683 case TYPE_TEST: | 713 case TYPE_TEST: |
| 684 return parseTypeTest(); | 714 return parseTypeTest(); |
| 685 case APPLY_BUILTIN_OPERATOR: | 715 case APPLY_BUILTIN_OPERATOR: |
| 686 return parseApplyBuiltinOperator(); | 716 return parseApplyBuiltinOperator(); |
| 717 case GET_LENGTH: |
| 718 return parseGetLength(); |
| 719 case GET_INDEX: |
| 720 return parseGetIndex(); |
| 721 case SET_INDEX: |
| 722 return parseSetIndex(); |
| 687 default: | 723 default: |
| 688 assert(false); | 724 assert(false); |
| 689 } | 725 } |
| 690 | 726 |
| 691 return null; | 727 return null; |
| 692 } | 728 } |
| 693 | 729 |
| 694 /// (Constant (constant)) | 730 /// (Constant (constant)) |
| 695 Constant parseConstant() { | 731 Constant parseConstant() { |
| 696 tokens.consumeStart(CONSTANT); | 732 tokens.consumeStart(CONSTANT); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 /// (GetStatic field) | 849 /// (GetStatic field) |
| 814 GetStatic parseGetStatic() { | 850 GetStatic parseGetStatic() { |
| 815 tokens.consumeStart(GET_STATIC); | 851 tokens.consumeStart(GET_STATIC); |
| 816 | 852 |
| 817 Element field = new DummyElement(tokens.read()); | 853 Element field = new DummyElement(tokens.read()); |
| 818 | 854 |
| 819 tokens.consumeEnd(); | 855 tokens.consumeEnd(); |
| 820 return new GetStatic(field, null); | 856 return new GetStatic(field, null); |
| 821 } | 857 } |
| 822 } | 858 } |
| OLD | NEW |