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

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

Issue 1136843006: dart2js cps: Access to lazily initialized fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/js_spec_string_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
11 import 'package:compiler/src/constants/values.dart'; 11 import 'package:compiler/src/constants/values.dart';
12 import 'package:compiler/src/dart2jslib.dart' as dart2js 12 import 'package:compiler/src/dart2jslib.dart' as dart2js
13 show MessageKind; 13 show MessageKind;
14 import 'package:compiler/src/dart_types.dart' as dart_types 14 import 'package:compiler/src/dart_types.dart' as dart_types
15 show DartType; 15 show DartType;
16 import 'package:compiler/src/elements/elements.dart' 16 import 'package:compiler/src/elements/elements.dart';
17 show Entity, Element, Elements, Local, TypeVariableElement, ErroneousElement,
18 TypeDeclarationElement, ExecutableElement, PublicName;
19 import 'package:compiler/src/elements/modelx.dart' 17 import 'package:compiler/src/elements/modelx.dart'
20 show ErroneousElementX, TypeVariableElementX; 18 show ErroneousElementX, TypeVariableElementX;
21 import 'package:compiler/src/tree/tree.dart' show LiteralDartString; 19 import 'package:compiler/src/tree/tree.dart' show LiteralDartString;
22 import 'package:compiler/src/universe/universe.dart' 20 import 'package:compiler/src/universe/universe.dart'
23 show Selector, SelectorKind, CallStructure; 21 show Selector, SelectorKind, CallStructure;
24 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart'; 22 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart';
25 23
26 /// Used whenever a node constructed by [SExpressionUnstringifier] needs a 24 /// Used whenever a node constructed by [SExpressionUnstringifier] needs a
27 /// named entity. 25 /// named entity.
28 class DummyEntity extends Entity { 26 class DummyEntity extends Entity {
(...skipping 12 matching lines...) Expand all
41 // TODO(karlklose): we should remove all references to [ErroneousElement] from 39 // TODO(karlklose): we should remove all references to [ErroneousElement] from
42 // the CPS IR. Instead, the builder must construct appropriate terms for ASTs 40 // the CPS IR. Instead, the builder must construct appropriate terms for ASTs
43 // that could not be resolved correctly. Perhaps the IR should not rely on 41 // that could not be resolved correctly. Perhaps the IR should not rely on
44 // elements at all for naming. 42 // elements at all for naming.
45 /// Used whenever a node constructed by [SExpressionUnstringifier] requires 43 /// Used whenever a node constructed by [SExpressionUnstringifier] requires
46 /// an [Element] or [FunctionElement]. Extends [ErroneousElementX] since there 44 /// an [Element] or [FunctionElement]. Extends [ErroneousElementX] since there
47 /// is currently a large amount of overhead when extending the base abstract 45 /// is currently a large amount of overhead when extending the base abstract
48 /// classes, and erroneous elements conveniently also skip several assertion 46 /// classes, and erroneous elements conveniently also skip several assertion
49 /// checks in CPS IR nodes that are irrelevant to us. 47 /// checks in CPS IR nodes that are irrelevant to us.
50 class DummyElement extends ErroneousElementX 48 class DummyElement extends ErroneousElementX
51 implements TypeVariableElement { 49 implements TypeVariableElement, FieldElement {
52 DummyElement(String name) 50 DummyElement(String name)
53 : super(dart2js.MessageKind.GENERIC, {}, name, null); 51 : super(dart2js.MessageKind.GENERIC, {}, name, null);
54 52
55 final dart_types.DartType bound = null; 53 final dart_types.DartType bound = null;
56 final TypeDeclarationElement typeDeclaration = null; 54 final TypeDeclarationElement typeDeclaration = null;
55
56 noSuchMethod(inv) => super.noSuchMethod(inv);
57 } 57 }
58 58
59 /// Used whenever a node constructed by [SExpressionUnstringifier] requires 59 /// Used whenever a node constructed by [SExpressionUnstringifier] requires
60 /// a named type. 60 /// a named type.
61 class DummyNamedType extends dart_types.DartType { 61 class DummyNamedType extends dart_types.DartType {
62 final String name; 62 final String name;
63 63
64 final kind = null; 64 final kind = null;
65 final element = null; 65 final element = null;
66 66
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_OPERATOR = "TypeOperator";
139 static const String SET_STATIC = "SetStatic"; 139 static const String SET_STATIC = "SetStatic";
140 static const String GET_LAZY_STATIC = "GetLazyStatic";
140 141
141 // Primitives 142 // Primitives
142 static const String CONSTANT = "Constant"; 143 static const String CONSTANT = "Constant";
143 static const String CREATE_FUNCTION = "CreateFunction"; 144 static const String CREATE_FUNCTION = "CreateFunction";
144 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable"; 145 static const String GET_MUTABLE_VARIABLE = "GetMutableVariable";
145 static const String LITERAL_LIST = "LiteralList"; 146 static const String LITERAL_LIST = "LiteralList";
146 static const String LITERAL_MAP = "LiteralMap"; 147 static const String LITERAL_MAP = "LiteralMap";
147 static const String REIFY_TYPE_VAR = "ReifyTypeVar"; 148 static const String REIFY_TYPE_VAR = "ReifyTypeVar";
148 static const String GET_STATIC = "GetStatic"; 149 static const String GET_STATIC = "GetStatic";
149 150
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 case LET_CONT: 244 case LET_CONT:
244 return parseLetCont(); 245 return parseLetCont();
245 case LET_MUTABLE: 246 case LET_MUTABLE:
246 return parseLetMutable(); 247 return parseLetMutable();
247 case SET_MUTABLE_VARIABLE: 248 case SET_MUTABLE_VARIABLE:
248 return parseSetMutableVariable(); 249 return parseSetMutableVariable();
249 case TYPE_OPERATOR: 250 case TYPE_OPERATOR:
250 return parseTypeOperator(); 251 return parseTypeOperator();
251 case SET_STATIC: 252 case SET_STATIC:
252 return parseSetStatic(); 253 return parseSetStatic();
254 case GET_LAZY_STATIC:
255 return parseGetLazyStatic();
253 default: 256 default:
254 assert(false); 257 assert(false);
255 } 258 }
256 259
257 return null; 260 return null;
258 } 261 }
259 262
260 /// (prim1 prim2 ... primn) 263 /// (prim1 prim2 ... primn)
261 List<Primitive> parsePrimitiveList() { 264 List<Primitive> parsePrimitiveList() {
262 tokens.consumeStart(); 265 tokens.consumeStart();
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 Continuation cont = name2variable[tokens.read()]; 567 Continuation cont = name2variable[tokens.read()];
565 assert(cont != null); 568 assert(cont != null);
566 569
567 tokens.consumeEnd(); 570 tokens.consumeEnd();
568 return new TypeOperator(recv, type, cont, isTypeTest: operator == 'is'); 571 return new TypeOperator(recv, type, cont, isTypeTest: operator == 'is');
569 } 572 }
570 573
571 /// (SetStatic field value body) 574 /// (SetStatic field value body)
572 SetStatic parseSetStatic() { 575 SetStatic parseSetStatic() {
573 tokens.consumeStart(SET_STATIC); 576 tokens.consumeStart(SET_STATIC);
577
574 Element fieldElement = new DummyElement(tokens.read()); 578 Element fieldElement = new DummyElement(tokens.read());
575
576 Primitive value = name2variable[tokens.read()]; 579 Primitive value = name2variable[tokens.read()];
577 assert(value != null); 580 assert(value != null);
578
579 Expression body = parseExpression(); 581 Expression body = parseExpression();
580 582
581 tokens.consumeEnd(); 583 tokens.consumeEnd();
582 return new SetStatic(fieldElement, value, null).plug(body); 584 return new SetStatic(fieldElement, value, null)..plug(body);
585 }
586
587 /// (GetLazyStatic field cont)
588 GetLazyStatic parseGetLazyStatic() {
589 tokens.consumeStart(GET_LAZY_STATIC);
590
591 Element fieldElement = new DummyElement(tokens.read());
592 Continuation cont = name2variable[tokens.read()];
593 assert(cont != null);
594
595 tokens.consumeEnd();
596 return new GetLazyStatic(fieldElement, cont, null);
583 } 597 }
584 598
585 /// (LetPrim (name primitive) body) 599 /// (LetPrim (name primitive) body)
586 LetPrim parseLetPrim() { 600 LetPrim parseLetPrim() {
587 tokens.consumeStart(LET_PRIM); 601 tokens.consumeStart(LET_PRIM);
588 602
589 // (name 603 // (name
590 tokens.consumeStart(); 604 tokens.consumeStart();
591 String name = tokens.read(); 605 String name = tokens.read();
592 606
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 /// (GetStatic field) 764 /// (GetStatic field)
751 GetStatic parseGetStatic() { 765 GetStatic parseGetStatic() {
752 tokens.consumeStart(GET_STATIC); 766 tokens.consumeStart(GET_STATIC);
753 767
754 Element field = new DummyElement(tokens.read()); 768 Element field = new DummyElement(tokens.read());
755 769
756 tokens.consumeEnd(); 770 tokens.consumeEnd();
757 return new GetStatic(field, null); 771 return new GetStatic(field, null);
758 } 772 }
759 } 773 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/js_spec_string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698