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

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: Address comments. 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 String visitInvokeMethodDirectly(InvokeMethodDirectly node) { 201 String visitInvokeMethodDirectly(InvokeMethodDirectly node) {
202 String receiver = access(node.receiver); 202 String receiver = access(node.receiver);
203 String name = node.selector.name; 203 String name = node.selector.name;
204 String cont = access(node.continuation); 204 String cont = access(node.continuation);
205 String args = formatArguments(node); 205 String args = formatArguments(node);
206 return '$indentation(InvokeMethodDirectly $receiver $name $args $cont)'; 206 return '$indentation(InvokeMethodDirectly $receiver $name $args $cont)';
207 } 207 }
208 208
209 String visitInvokeConstructor(InvokeConstructor node) { 209 String visitInvokeConstructor(InvokeConstructor node) {
210 String className;
211 // TODO(karlklose): for illegal nodes constructed for tests or unresolved
212 // constructor calls in the DartBackend, we get an element with no enclosing
213 // class. Clean this up by introducing a name field to the node and
214 // removing [ErroneousElement]s from the IR.
215 if (node.type != null) {
216 className = node.type.toString();
217 } else {
218 className = node.target.enclosingClass.name;
219 }
210 String callName; 220 String callName;
211 if (node.target.name.isEmpty) { 221 if (node.target.name.isEmpty) {
212 callName = '${node.type}'; 222 callName = '${className}';
213 } else { 223 } else {
214 callName = '${node.type}.${node.target.name}'; 224 callName = '${className}.${node.target.name}';
215 } 225 }
216 String cont = access(node.continuation); 226 String cont = access(node.continuation);
217 String args = formatArguments(node); 227 String args = formatArguments(node);
218 return '$indentation(InvokeConstructor $callName $args $cont)'; 228 return '$indentation(InvokeConstructor $callName $args $cont)';
219 } 229 }
220 230
221 String visitConcatenateStrings(ConcatenateStrings node) { 231 String visitConcatenateStrings(ConcatenateStrings node) {
222 String cont = access(node.continuation); 232 String cont = access(node.continuation);
223 String args = node.arguments.map(access).join(' '); 233 String args = node.arguments.map(access).join(' ');
224 return '$indentation(ConcatenateStrings ($args) $cont)'; 234 return '$indentation(ConcatenateStrings ($args) $cont)';
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return '(GetField $object $field)'; 326 return '(GetField $object $field)';
317 } 327 }
318 328
319 String visitCreateBox(CreateBox node) { 329 String visitCreateBox(CreateBox node) {
320 return '(CreateBox)'; 330 return '(CreateBox)';
321 } 331 }
322 332
323 String visitCreateInstance(CreateInstance node) { 333 String visitCreateInstance(CreateInstance node) {
324 String className = node.classElement.name; 334 String className = node.classElement.name;
325 String arguments = node.arguments.map(access).join(' '); 335 String arguments = node.arguments.map(access).join(' ');
326 return '(CreateInstance $className ($arguments))'; 336 String typeInformation = node.typeInformation.map(access).join(' ');
337 return '(CreateInstance $className ($arguments)$typeInformation)';
327 } 338 }
328 339
329 String visitIdentical(Identical node) { 340 String visitIdentical(Identical node) {
330 String left = access(node.left); 341 String left = access(node.left);
331 String right = access(node.right); 342 String right = access(node.right);
332 return '(Identical $left $right)'; 343 return '(Identical $left $right)';
333 } 344 }
334 345
335 String visitInterceptor(Interceptor node) { 346 String visitInterceptor(Interceptor node) {
336 return '(Interceptor ${access(node.input)})'; 347 return '(Interceptor ${access(node.input)})';
337 } 348 }
338 349
339 String visitReifyRuntimeType(ReifyRuntimeType node) { 350 String visitReifyRuntimeType(ReifyRuntimeType node) {
340 return '(ReifyRuntimeType ${access(node.value)})'; 351 return '(ReifyRuntimeType ${access(node.value)})';
341 } 352 }
342 353
343 String visitReadTypeVariable(ReadTypeVariable node) { 354 String visitReadTypeVariable(ReadTypeVariable node) {
344 return '(ReadTypeVariable ${access(node.target)}.${node.variable})'; 355 return '(ReadTypeVariable ${access(node.target)}.${node.variable})';
345 } 356 }
357
358 @override
359 String visitTypeExpression(TypeExpression node) {
360 String args = node.arguments.map(access).join(', ');
361 return '(TypeExpression ${node.dartType.toString()} $args)';
362 }
346 } 363 }
347 364
348 class ConstantStringifier extends ConstantValueVisitor<String, Null> { 365 class ConstantStringifier extends ConstantValueVisitor<String, Null> {
349 // Some of these methods are unimplemented because we haven't had a need 366 // Some of these methods are unimplemented because we haven't had a need
350 // to print such constants. When printing is implemented, the corresponding 367 // to print such constants. When printing is implemented, the corresponding
351 // parsing support should be added to SExpressionUnstringifier.parseConstant 368 // parsing support should be added to SExpressionUnstringifier.parseConstant
352 // in the dart2js tests (currently in the file 369 // in the dart2js tests (currently in the file
353 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart). 370 // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart).
354 371
355 String _failWith(ConstantValue constant) { 372 String _failWith(ConstantValue constant) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 class _Namer { 437 class _Namer {
421 final Map<Node, String> _names = <Node, String>{}; 438 final Map<Node, String> _names = <Node, String>{};
422 int _valueCounter = 0; 439 int _valueCounter = 0;
423 int _continuationCounter = 0; 440 int _continuationCounter = 0;
424 441
425 // TODO(sra): Make the methods not assert and print something indicating an 442 // TODO(sra): Make the methods not assert and print something indicating an
426 // error, so printer can be used to inspect broken terms. 443 // error, so printer can be used to inspect broken terms.
427 444
428 String nameParameter(Parameter parameter) { 445 String nameParameter(Parameter parameter) {
429 assert(!_names.containsKey(parameter)); 446 assert(!_names.containsKey(parameter));
430 return _names[parameter] = parameter.hint.name; 447 String name =
448 parameter.hint != null ? parameter.hint.name : nameValue(parameter);
449 return _names[parameter] = name;
431 } 450 }
432 451
433 String nameMutableVariable(MutableVariable variable) { 452 String nameMutableVariable(MutableVariable variable) {
434 assert(!_names.containsKey(variable)); 453 assert(!_names.containsKey(variable));
435 return _names[variable] = variable.hint.name; 454 return _names[variable] = variable.hint.name;
436 } 455 }
437 456
438 String nameContinuation(Continuation node) { 457 String nameContinuation(Continuation node) {
439 assert(!_names.containsKey(node)); 458 assert(!_names.containsKey(node));
440 return _names[node] = 'k${_continuationCounter++}'; 459 return _names[node] = 'k${_continuationCounter++}';
441 } 460 }
442 461
443 String nameValue(Primitive node) { 462 String nameValue(Primitive node) {
444 assert(!_names.containsKey(node)); 463 assert(!_names.containsKey(node));
445 return _names[node] = 'v${_valueCounter++}'; 464 return _names[node] = 'v${_valueCounter++}';
446 } 465 }
447 466
448 void setReturnContinuation(Continuation node) { 467 void setReturnContinuation(Continuation node) {
449 assert(!_names.containsKey(node) || _names[node] == 'return'); 468 assert(!_names.containsKey(node) || _names[node] == 'return');
450 _names[node] = 'return'; 469 _names[node] = 'return';
451 } 470 }
452 471
453 String getName(Node node) { 472 String getName(Node node) {
454 assert(_names.containsKey(node)); 473 assert(_names.containsKey(node));
455 return _names[node]; 474 return _names[node];
456 } 475 }
457 } 476 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698