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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/unsugar.dart

Issue 1250633002: Add operators test to source_mapping_test. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup Created 5 years, 5 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 library dart2js.unsugar_cps; 1 library dart2js.unsugar_cps;
2 2
3 import '../../cps_ir/cps_ir_nodes.dart'; 3 import '../../cps_ir/cps_ir_nodes.dart';
4 4
5 import '../../cps_ir/optimizers.dart' show ParentVisitor; 5 import '../../cps_ir/optimizers.dart' show ParentVisitor;
6 import '../../constants/expressions.dart'; 6 import '../../constants/expressions.dart';
7 import '../../constants/values.dart'; 7 import '../../constants/values.dart';
8 import '../../elements/elements.dart' show 8 import '../../elements/elements.dart' show
9 ClassElement, 9 ClassElement,
10 FieldElement, 10 FieldElement,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Continuation returnFalse = new Continuation(<Parameter>[]); 120 Continuation returnFalse = new Continuation(<Parameter>[]);
121 Primitive falsePrimitive = falseConstant; 121 Primitive falsePrimitive = falseConstant;
122 returnFalse.body = 122 returnFalse.body =
123 new LetPrim(falsePrimitive, 123 new LetPrim(falsePrimitive,
124 new InvokeContinuation( 124 new InvokeContinuation(
125 function.returnContinuation, <Primitive>[falsePrimitive])); 125 function.returnContinuation, <Primitive>[falsePrimitive]));
126 126
127 Primitive nullPrimitive = nullConstant; 127 Primitive nullPrimitive = nullConstant;
128 Primitive test = new ApplyBuiltinOperator( 128 Primitive test = new ApplyBuiltinOperator(
129 BuiltinOperator.Identical, 129 BuiltinOperator.Identical,
130 <Primitive>[function.parameters.single, nullPrimitive]); 130 <Primitive>[function.parameters.single, nullPrimitive],
131 function.parameters.single.sourceInformation);
131 132
132 Expression newBody = 133 Expression newBody =
133 new LetCont.many(<Continuation>[returnFalse, originalBody], 134 new LetCont.many(<Continuation>[returnFalse, originalBody],
134 new LetPrim(nullPrimitive, 135 new LetPrim(nullPrimitive,
135 new LetPrim(test, 136 new LetPrim(test,
136 new Branch( 137 new Branch(
137 new IsTrue(test), 138 new IsTrue(test),
138 returnFalse, 139 returnFalse,
139 originalBody)))); 140 originalBody))));
140 function.body = newBody; 141 function.body = newBody;
(...skipping 10 matching lines...) Expand all
151 Parameter result, 152 Parameter result,
152 Expression node) { 153 Expression node) {
153 InteriorNode parent = node.parent; 154 InteriorNode parent = node.parent;
154 Continuation continuation = new Continuation([result]); 155 Continuation continuation = new Continuation([result]);
155 continuation.body = node; 156 continuation.body = node;
156 _parentVisitor.processContinuation(continuation); 157 _parentVisitor.processContinuation(continuation);
157 158
158 Selector selector = new Selector.fromElement(function); 159 Selector selector = new Selector.fromElement(function);
159 // TODO(johnniwinther): Come up with an implementation of SourceInformation 160 // TODO(johnniwinther): Come up with an implementation of SourceInformation
160 // for calls such as this one that don't appear in the original source. 161 // for calls such as this one that don't appear in the original source.
161 InvokeStatic invoke = 162 InvokeStatic invoke = new InvokeStatic(
162 new InvokeStatic(function, selector, arguments, continuation, null); 163 function, selector, arguments, continuation, null);
163 _parentVisitor.processInvokeStatic(invoke); 164 _parentVisitor.processInvokeStatic(invoke);
164 165
165 LetCont letCont = new LetCont(continuation, invoke); 166 LetCont letCont = new LetCont(continuation, invoke);
166 _parentVisitor.processLetCont(letCont); 167 _parentVisitor.processLetCont(letCont);
167 168
168 parent.body = letCont; 169 parent.body = letCont;
169 letCont.parent = parent; 170 letCont.parent = parent;
170 } 171 }
171 172
172 processLetHandler(LetHandler node) { 173 processLetHandler(LetHandler node) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // If the receiver is the explicit receiver, we are calling a method in 239 // If the receiver is the explicit receiver, we are calling a method in
239 // the same interceptor: 240 // the same interceptor:
240 // Change 'receiver.foo()' to 'this.foo(receiver)'. 241 // Change 'receiver.foo()' to 'this.foo(receiver)'.
241 newReceiver = thisParameter; 242 newReceiver = thisParameter;
242 } else { 243 } else {
243 // TODO(sra): Move the computation of interceptedClasses to a much later 244 // TODO(sra): Move the computation of interceptedClasses to a much later
244 // phase and take into account the remaining uses of the interceptor. 245 // phase and take into account the remaining uses of the interceptor.
245 Set<ClassElement> interceptedClasses = 246 Set<ClassElement> interceptedClasses =
246 _glue.getInterceptedClassesOn(selector); 247 _glue.getInterceptedClassesOn(selector);
247 _glue.registerSpecializedGetInterceptor(interceptedClasses); 248 _glue.registerSpecializedGetInterceptor(interceptedClasses);
248 newReceiver = new Interceptor(receiver, interceptedClasses); 249 newReceiver = new Interceptor(
250 receiver, interceptedClasses, node.sourceInformation);
249 insertLetPrim(newReceiver, node); 251 insertLetPrim(newReceiver, node);
250 } 252 }
251 253
252 node.arguments.insert(0, node.receiver); 254 node.arguments.insert(0, node.receiver);
253 node.receiver = new Reference<Primitive>(newReceiver); 255 node.receiver = new Reference<Primitive>(newReceiver);
254 } 256 }
255 257
256 processInvokeMethodDirectly(InvokeMethodDirectly node) { 258 processInvokeMethodDirectly(InvokeMethodDirectly node) {
257 if (_glue.isInterceptedMethod(node.target)) { 259 if (_glue.isInterceptedMethod(node.target)) {
258 Primitive nullPrim = nullConstant; 260 Primitive nullPrim = nullConstant;
259 insertLetPrim(nullPrim, node); 261 insertLetPrim(nullPrim, node);
260 node.arguments.insert(0, node.receiver); 262 node.arguments.insert(0, node.receiver);
261 // TODO(sra): `null` is not adequate. Interceptors project the class 263 // TODO(sra): `null` is not adequate. Interceptors project the class
262 // hierarchy onto an interceptor hierarchy. A super call that does a 264 // hierarchy onto an interceptor hierarchy. A super call that does a
263 // method call will use the javascript 'this' parameter to avoid calling 265 // method call will use the javascript 'this' parameter to avoid calling
264 // getInterceptor again, so the receiver must be the interceptor (likely 266 // getInterceptor again, so the receiver must be the interceptor (likely
265 // `this`), not `null`. 267 // `this`), not `null`.
266 node.receiver = new Reference<Primitive>(nullPrim); 268 node.receiver = new Reference<Primitive>(nullPrim);
267 } 269 }
268 } 270 }
269 271
270 processBranch(Branch node) { 272 processBranch(Branch node) {
271 // TODO(karlklose): implement the checked mode part of boolean conversion. 273 // TODO(karlklose): implement the checked mode part of boolean conversion.
272 InteriorNode parent = node.parent; 274 InteriorNode parent = node.parent;
273 IsTrue condition = node.condition; 275 IsTrue condition = node.condition;
274 Primitive t = trueConstant; 276 Primitive t = trueConstant;
275 Primitive i = new ApplyBuiltinOperator( 277 Primitive i = new ApplyBuiltinOperator(
276 BuiltinOperator.Identical, 278 BuiltinOperator.Identical,
277 <Primitive>[condition.value.definition, t]); 279 <Primitive>[condition.value.definition, t],
280 condition.value.definition.sourceInformation);
278 LetPrim newNode = new LetPrim(t, 281 LetPrim newNode = new LetPrim(t,
279 new LetPrim(i, 282 new LetPrim(i,
280 new Branch(new IsTrue(i), 283 new Branch(new IsTrue(i),
281 node.trueContinuation.definition, 284 node.trueContinuation.definition,
282 node.falseContinuation.definition))); 285 node.falseContinuation.definition)));
283 condition.value.unlink(); 286 condition.value.unlink();
284 node.trueContinuation.unlink(); 287 node.trueContinuation.unlink();
285 node.falseContinuation.unlink(); 288 node.falseContinuation.unlink();
286 parent.body = newNode; 289 parent.body = newNode;
287 } 290 }
288 291
289 processInterceptor(Interceptor node) { 292 processInterceptor(Interceptor node) {
290 _glue.registerSpecializedGetInterceptor(node.interceptedClasses); 293 _glue.registerSpecializedGetInterceptor(node.interceptedClasses);
291 } 294 }
292 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698