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

Side by Side Diff: tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart

Issue 1153603006: dart2js cps: Type casts and related changes to type propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Another typo in SExpression unstrngifier Created 5 years, 6 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
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 static const String DECLARE_FUNCTION = "DeclareFunction"; 128 static const String DECLARE_FUNCTION = "DeclareFunction";
129 static const String INVOKE_CONSTRUCTOR = "InvokeConstructor"; 129 static const String INVOKE_CONSTRUCTOR = "InvokeConstructor";
130 static const String INVOKE_CONTINUATION = "InvokeContinuation"; 130 static const String INVOKE_CONTINUATION = "InvokeContinuation";
131 static const String INVOKE_STATIC = "InvokeStatic"; 131 static const String INVOKE_STATIC = "InvokeStatic";
132 static const String INVOKE_METHOD_DIRECTLY = "InvokeMethodDirectly"; 132 static const String INVOKE_METHOD_DIRECTLY = "InvokeMethodDirectly";
133 static const String INVOKE_METHOD = "InvokeMethod"; 133 static const String INVOKE_METHOD = "InvokeMethod";
134 static const String LET_PRIM = "LetPrim"; 134 static const String LET_PRIM = "LetPrim";
135 static const String LET_CONT = "LetCont"; 135 static const String LET_CONT = "LetCont";
136 static const String LET_MUTABLE = "LetMutable"; 136 static const String LET_MUTABLE = "LetMutable";
137 static const String SET_MUTABLE_VARIABLE = "SetMutableVariable"; 137 static const String SET_MUTABLE_VARIABLE = "SetMutableVariable";
138 static const String TYPE_OPERATOR = "TypeOperator"; 138 static const String TYPE_CAST = "TypeCast";
139 static const String SET_STATIC = "SetStatic"; 139 static const String SET_STATIC = "SetStatic";
140 static const String GET_LAZY_STATIC = "GetLazyStatic"; 140 static const String GET_LAZY_STATIC = "GetLazyStatic";
141 static const String UNREACHABLE = "Unreachable";
141 142
142 // Primitives 143 // Primitives
143 static const String CONSTANT = "Constant"; 144 static const String CONSTANT = "Constant";
144 static const String CREATE_FUNCTION = "CreateFunction"; 145 static const String CREATE_FUNCTION = "CreateFunction";
145 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable"; 146 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable";
146 static const String LITERAL_LIST = "LiteralList"; 147 static const String LITERAL_LIST = "LiteralList";
147 static const String LITERAL_MAP = "LiteralMap"; 148 static const String LITERAL_MAP = "LiteralMap";
148 static const String REIFY_TYPE_VAR = "ReifyTypeVar"; 149 static const String REIFY_TYPE_VAR = "ReifyTypeVar";
149 static const String GET_STATIC = "GetStatic"; 150 static const String GET_STATIC = "GetStatic";
151 static const String TYPE_TEST = "TypeTest";
150 152
151 // Other 153 // Other
152 static const String FUNCTION_DEFINITION = "FunctionDefinition"; 154 static const String FUNCTION_DEFINITION = "FunctionDefinition";
153 static const String IS_TRUE = "IsTrue"; 155 static const String IS_TRUE = "IsTrue";
154 156
155 // Constants 157 // Constants
156 static const String BOOL = "Bool"; 158 static const String BOOL = "Bool";
157 static const String DOUBLE = "Double"; 159 static const String DOUBLE = "Double";
158 static const String INT = "Int"; 160 static const String INT = "Int";
159 static const String NULL = "Null"; 161 static const String NULL = "Null";
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 case INVOKE_METHOD_DIRECTLY: 242 case INVOKE_METHOD_DIRECTLY:
241 return parseInvokeMethodDirectly(); 243 return parseInvokeMethodDirectly();
242 case LET_PRIM: 244 case LET_PRIM:
243 return parseLetPrim(); 245 return parseLetPrim();
244 case LET_CONT: 246 case LET_CONT:
245 return parseLetCont(); 247 return parseLetCont();
246 case LET_MUTABLE: 248 case LET_MUTABLE:
247 return parseLetMutable(); 249 return parseLetMutable();
248 case SET_MUTABLE_VARIABLE: 250 case SET_MUTABLE_VARIABLE:
249 return parseSetMutableVariable(); 251 return parseSetMutableVariable();
250 case TYPE_OPERATOR: 252 case TYPE_CAST:
251 return parseTypeOperator(); 253 return parseTypeCast();
252 case SET_STATIC: 254 case SET_STATIC:
253 return parseSetStatic(); 255 return parseSetStatic();
254 case GET_LAZY_STATIC: 256 case GET_LAZY_STATIC:
255 return parseGetLazyStatic(); 257 return parseGetLazyStatic();
258 case UNREACHABLE:
259 return parseUnreachable();
256 default: 260 default:
257 assert(false); 261 assert(false);
258 } 262 }
259 263
260 return null; 264 return null;
261 } 265 }
262 266
263 /// (prim1 prim2 ... primn) 267 /// (prim1 prim2 ... primn)
264 List<Primitive> parsePrimitiveList() { 268 List<Primitive> parsePrimitiveList() {
265 tokens.consumeStart(); 269 tokens.consumeStart();
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 Primitive value = name2variable[tokens.read()]; 550 Primitive value = name2variable[tokens.read()];
547 assert(value != null); 551 assert(value != null);
548 552
549 Expression body = parseExpression(); 553 Expression body = parseExpression();
550 554
551 tokens.consumeEnd(); 555 tokens.consumeEnd();
552 return new SetMutableVariable(local, value) 556 return new SetMutableVariable(local, value)
553 ..plug(body); 557 ..plug(body);
554 } 558 }
555 559
556 /// (TypeOperator operator recv type cont) 560 /// (TypeCast value type args cont)
557 TypeOperator parseTypeOperator() { 561 TypeCast parseTypeCast() {
558 tokens.consumeStart(TYPE_OPERATOR); 562 tokens.consumeStart(TYPE_CAST);
559 563
560 String operator = tokens.read(); 564 Primitive value = name2variable[tokens.read()];
561 565 assert(value != null);
562 Primitive recv = name2variable[tokens.read()];
563 assert(recv != null);
564 566
565 dart_types.DartType type = new DummyNamedType(tokens.read()); 567 dart_types.DartType type = new DummyNamedType(tokens.read());
566 568
567 List<ir.Primitive> typeArguments = parsePrimitiveList(); 569 List<ir.Primitive> typeArguments = parsePrimitiveList();
568 570
569 Continuation cont = name2variable[tokens.read()]; 571 Continuation cont = name2variable[tokens.read()];
570 assert(cont != null); 572 assert(cont != null);
571 573
572 tokens.consumeEnd(); 574 tokens.consumeEnd();
573 return new TypeOperator(recv, type, typeArguments, cont, 575 return new TypeCast(value, type, typeArguments, cont);
574 isTypeTest: operator == 'is'); 576 }
577
578 /// (TypeTest value type args)
579 TypeTest parseTypeTest() {
580 tokens.consumeStart(TYPE_TEST);
581
582 Primitive value = name2variable[tokens.read()];
583 assert(value != null);
584
585 dart_types.DartType type = new DummyNamedType(tokens.read());
586
587 List<ir.Primitive> typeArguments = parsePrimitiveList();
588
589 tokens.consumeEnd();
590 return new TypeTest(value, type, typeArguments);
575 } 591 }
576 592
577 /// (SetStatic field value body) 593 /// (SetStatic field value body)
578 SetStatic parseSetStatic() { 594 SetStatic parseSetStatic() {
579 tokens.consumeStart(SET_STATIC); 595 tokens.consumeStart(SET_STATIC);
580 596
581 Element fieldElement = new DummyElement(tokens.read()); 597 Element fieldElement = new DummyElement(tokens.read());
582 Primitive value = name2variable[tokens.read()]; 598 Primitive value = name2variable[tokens.read()];
583 assert(value != null); 599 assert(value != null);
584 Expression body = parseExpression(); 600 Expression body = parseExpression();
585 601
586 tokens.consumeEnd(); 602 tokens.consumeEnd();
587 return new SetStatic(fieldElement, value, null)..plug(body); 603 return new SetStatic(fieldElement, value, null)..plug(body);
588 } 604 }
589 605
590 /// (GetLazyStatic field cont) 606 /// (GetLazyStatic field cont)
591 GetLazyStatic parseGetLazyStatic() { 607 GetLazyStatic parseGetLazyStatic() {
592 tokens.consumeStart(GET_LAZY_STATIC); 608 tokens.consumeStart(GET_LAZY_STATIC);
593 609
594 Element fieldElement = new DummyElement(tokens.read()); 610 Element fieldElement = new DummyElement(tokens.read());
595 Continuation cont = name2variable[tokens.read()]; 611 Continuation cont = name2variable[tokens.read()];
596 assert(cont != null); 612 assert(cont != null);
597 613
598 tokens.consumeEnd(); 614 tokens.consumeEnd();
599 return new GetLazyStatic(fieldElement, cont, null); 615 return new GetLazyStatic(fieldElement, cont, null);
600 } 616 }
601 617
618 /// (Unreachable)
619 Unreachable parseUnreachable() {
620 tokens.consumeStart(UNREACHABLE);
621 tokens.consumeEnd();
622 return new Unreachable();
623 }
624
602 /// (LetPrim (name primitive) body) 625 /// (LetPrim (name primitive) body)
603 LetPrim parseLetPrim() { 626 LetPrim parseLetPrim() {
604 tokens.consumeStart(LET_PRIM); 627 tokens.consumeStart(LET_PRIM);
605 628
606 // (name 629 // (name
607 tokens.consumeStart(); 630 tokens.consumeStart();
608 String name = tokens.read(); 631 String name = tokens.read();
609 632
610 // primitive) 633 // primitive)
611 Primitive primitive = parsePrimitive(); 634 Primitive primitive = parsePrimitive();
(...skipping 18 matching lines...) Expand all
630 case GET_MUTABLE_VARIABLE: 653 case GET_MUTABLE_VARIABLE:
631 return parseGetMutableVariable(); 654 return parseGetMutableVariable();
632 case LITERAL_LIST: 655 case LITERAL_LIST:
633 return parseLiteralList(); 656 return parseLiteralList();
634 case LITERAL_MAP: 657 case LITERAL_MAP:
635 return parseLiteralMap(); 658 return parseLiteralMap();
636 case REIFY_TYPE_VAR: 659 case REIFY_TYPE_VAR:
637 return parseReifyTypeVar(); 660 return parseReifyTypeVar();
638 case GET_STATIC: 661 case GET_STATIC:
639 return parseGetStatic(); 662 return parseGetStatic();
663 case TYPE_TEST:
664 return parseTypeTest();
640 default: 665 default:
641 assert(false); 666 assert(false);
642 } 667 }
643 668
644 return null; 669 return null;
645 } 670 }
646 671
647 /// (Constant (constant)) 672 /// (Constant (constant))
648 Constant parseConstant() { 673 Constant parseConstant() {
649 tokens.consumeStart(CONSTANT); 674 tokens.consumeStart(CONSTANT);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 /// (GetStatic field) 791 /// (GetStatic field)
767 GetStatic parseGetStatic() { 792 GetStatic parseGetStatic() {
768 tokens.consumeStart(GET_STATIC); 793 tokens.consumeStart(GET_STATIC);
769 794
770 Element field = new DummyElement(tokens.read()); 795 Element field = new DummyElement(tokens.read());
771 796
772 tokens.consumeEnd(); 797 tokens.consumeEnd();
773 return new GetStatic(field, null); 798 return new GetStatic(field, null);
774 } 799 }
775 } 800 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698