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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart

Issue 1011403003: cps-ir: Set runtime type information for new objects that require it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add parameter for each type variable to the JS-factory. Created 5 years, 9 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
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 library dart2js.ir_nodes_sexpr; 5 library dart2js.ir_nodes_sexpr;
6 6
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../util/util.dart'; 8 import '../util/util.dart';
9 import 'cps_ir_nodes.dart'; 9 import 'cps_ir_nodes.dart';
10 10
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 String visitInvokeMethodDirectly(InvokeMethodDirectly node) { 192 String visitInvokeMethodDirectly(InvokeMethodDirectly node) {
193 String receiver = access(node.receiver); 193 String receiver = access(node.receiver);
194 String name = node.selector.name; 194 String name = node.selector.name;
195 String cont = access(node.continuation); 195 String cont = access(node.continuation);
196 String args = formatArguments(node); 196 String args = formatArguments(node);
197 return '$indentation(InvokeMethodDirectly $receiver $name $args $cont)'; 197 return '$indentation(InvokeMethodDirectly $receiver $name $args $cont)';
198 } 198 }
199 199
200 String visitInvokeConstructor(InvokeConstructor node) { 200 String visitInvokeConstructor(InvokeConstructor node) {
201 String className;
202 // TODO(karlklose): for illegal nodes constructed for tests or unresolved
203 // cosntructor calls in the DartBackend, we get an element with no enclosing
204 // class. Clean this up by introducing a name field to the node and
205 // removing [ErroneousElement]s from the IR.
206 if (node.type != null) {
207 className = node.type.toString();
208 } else {
209 className = node.target.enclosingClass.name;
210 }
201 String callName; 211 String callName;
202 if (node.target.name.isEmpty) { 212 if (node.target.name.isEmpty) {
203 callName = '${node.type}'; 213 callName = '${className}';
204 } else { 214 } else {
205 callName = '${node.type}.${node.target.name}'; 215 callName = '${className}.${node.target.name}';
206 } 216 }
207 String cont = access(node.continuation); 217 String cont = access(node.continuation);
208 String args = formatArguments(node); 218 String args = formatArguments(node);
209 return '$indentation(InvokeConstructor $callName $args $cont)'; 219 return '$indentation(InvokeConstructor $callName $args $cont)';
210 } 220 }
211 221
212 String visitConcatenateStrings(ConcatenateStrings node) { 222 String visitConcatenateStrings(ConcatenateStrings node) {
213 String cont = access(node.continuation); 223 String cont = access(node.continuation);
214 String args = node.arguments.map(access).join(' '); 224 String args = node.arguments.map(access).join(' ');
215 return '$indentation(ConcatenateStrings ($args) $cont)'; 225 return '$indentation(ConcatenateStrings ($args) $cont)';
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return '(GetField $object $field)'; 321 return '(GetField $object $field)';
312 } 322 }
313 323
314 String visitCreateBox(CreateBox node) { 324 String visitCreateBox(CreateBox node) {
315 return '(CreateBox)'; 325 return '(CreateBox)';
316 } 326 }
317 327
318 String visitCreateInstance(CreateInstance node) { 328 String visitCreateInstance(CreateInstance node) {
319 String className = node.classElement.name; 329 String className = node.classElement.name;
320 String arguments = node.arguments.map(access).join(' '); 330 String arguments = node.arguments.map(access).join(' ');
321 return '(CreateInstance $className ($arguments))'; 331 String typeInformation = node.hasTypeInformation
332 ? ' ${node.typeInformation.map(access).join(' ')}' : '';
333 return '(CreateInstance $className ($arguments)$typeInformation)';
322 } 334 }
323 335
324 String visitIdentical(Identical node) { 336 String visitIdentical(Identical node) {
325 String left = access(node.left); 337 String left = access(node.left);
326 String right = access(node.right); 338 String right = access(node.right);
327 return '(Identical $left $right)'; 339 return '(Identical $left $right)';
328 } 340 }
329 341
330 String visitInterceptor(Interceptor node) { 342 String visitInterceptor(Interceptor node) {
331 return '(Interceptor ${access(node.input)})'; 343 return '(Interceptor ${access(node.input)})';
332 } 344 }
333 345
334 String visitReifyRuntimeType(ReifyRuntimeType node) { 346 String visitReifyRuntimeType(ReifyRuntimeType node) {
335 return '(ReifyRuntimeType ${access(node.value)})'; 347 return '(ReifyRuntimeType ${access(node.value)})';
336 } 348 }
337 349
338 String visitReadTypeVariable(ReadTypeVariable node) { 350 String visitReadTypeVariable(ReadTypeVariable node) {
339 return '(ReadTypeVariable ${access(node.target)}.${node.variable})'; 351 return '(ReadTypeVariable ${access(node.target)}.${node.variable})';
340 } 352 }
353
354 @override
355 String visitTypeExpression(TypeExpression node) {
356 String args = node.arguments.map(access).join(', ');
357 return '(TypeExpression ${node.dartType.toString()} $args)';
358 }
341 } 359 }
342 360
343 class ConstantStringifier extends ConstantValueVisitor<String, Null> { 361 class ConstantStringifier extends ConstantValueVisitor<String, Null> {
344 // Some of these methods are unimplemented because we haven't had a need 362 // Some of these methods are unimplemented because we haven't had a need
345 // to print such constants. When printing is implemented, the corresponding 363 // to print such constants. When printing is implemented, the corresponding
346 // parsing support should be added to SExpressionUnstringifier.parseConstant 364 // parsing support should be added to SExpressionUnstringifier.parseConstant
347 // in the dart2js tests (currently in the file 365 // in the dart2js tests (currently in the file
348 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). 366 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart).
349 367
350 String _failWith(ConstantValue constant) { 368 String _failWith(ConstantValue constant) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 430 }
413 } 431 }
414 432
415 class _Namer { 433 class _Namer {
416 final Map<Node, String> _names = <Node, String>{}; 434 final Map<Node, String> _names = <Node, String>{};
417 int _valueCounter = 0; 435 int _valueCounter = 0;
418 int _continuationCounter = 0; 436 int _continuationCounter = 0;
419 437
420 String nameParameter(Parameter parameter) { 438 String nameParameter(Parameter parameter) {
421 assert(!_names.containsKey(parameter)); 439 assert(!_names.containsKey(parameter));
422 return _names[parameter] = parameter.hint.name; 440 String name =
441 parameter.hint != null ? parameter.hint.name : nameValue(parameter);
442 return _names[parameter] = name;
423 } 443 }
424 444
425 String nameMutableVariable(MutableVariable variable) { 445 String nameMutableVariable(MutableVariable variable) {
426 assert(!_names.containsKey(variable)); 446 assert(!_names.containsKey(variable));
427 return _names[variable] = variable.hint.name; 447 return _names[variable] = variable.hint.name;
428 } 448 }
429 449
430 String nameContinuation(Continuation node) { 450 String nameContinuation(Continuation node) {
431 assert(!_names.containsKey(node)); 451 assert(!_names.containsKey(node));
432 return _names[node] = 'k${_continuationCounter++}'; 452 return _names[node] = 'k${_continuationCounter++}';
433 } 453 }
434 454
435 String nameValue(Primitive node) { 455 String nameValue(Primitive node) {
436 assert(!_names.containsKey(node)); 456 assert(!_names.containsKey(node));
437 return _names[node] = 'v${_valueCounter++}'; 457 return _names[node] = 'v${_valueCounter++}';
438 } 458 }
439 459
440 void setReturnContinuation(Continuation node) { 460 void setReturnContinuation(Continuation node) {
441 assert(!_names.containsKey(node) || _names[node] == 'return'); 461 assert(!_names.containsKey(node) || _names[node] == 'return');
442 _names[node] = 'return'; 462 _names[node] = 'return';
443 } 463 }
444 464
445 String getName(Node node) { 465 String getName(Node node) {
446 assert(_names.containsKey(node)); 466 assert(_names.containsKey(node));
447 return _names[node]; 467 return _names[node];
448 } 468 }
449 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698