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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_tracer.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 tree_ir_tracer; 5 library tree_ir_tracer;
6 6
7 import 'dart:async' show EventSink; 7 import 'dart:async' show EventSink;
8 import '../tracer.dart'; 8 import '../tracer.dart';
9 import 'tree_ir_nodes.dart'; 9 import 'tree_ir_nodes.dart';
10 import 'optimization/optimization.dart'; 10 import 'optimization/optimization.dart';
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 String visitInvokeMethodDirectly(InvokeMethodDirectly node) { 375 String visitInvokeMethodDirectly(InvokeMethodDirectly node) {
376 String receiver = visitExpression(node.receiver); 376 String receiver = visitExpression(node.receiver);
377 String host = node.target.enclosingClass.name; 377 String host = node.target.enclosingClass.name;
378 String name = node.selector.name; 378 String name = node.selector.name;
379 String args = formatArguments(node); 379 String args = formatArguments(node);
380 return "$receiver.$host::$name($args)"; 380 return "$receiver.$host::$name($args)";
381 } 381 }
382 382
383 String visitInvokeConstructor(InvokeConstructor node) { 383 String visitInvokeConstructor(InvokeConstructor node) {
384 String className = node.target.enclosingClass.name;
384 String callName; 385 String callName;
385 if (node.target.name.isEmpty) { 386 if (node.target.name.isEmpty) {
386 callName = '${node.type}'; 387 callName = '${className}';
387 } else { 388 } else {
388 callName = '${node.type}.${node.target.name}'; 389 callName = '${className}.${node.target.name}';
389 } 390 }
390 String args = formatArguments(node); 391 String args = formatArguments(node);
391 String keyword = node.constant != null ? 'const' : 'new'; 392 String keyword = node.constant != null ? 'const' : 'new';
392 return "$keyword $callName($args)"; 393 return "$keyword $callName($args)";
393 } 394 }
394 395
395 String visitConcatenateStrings(ConcatenateStrings node) { 396 String visitConcatenateStrings(ConcatenateStrings node) {
396 String args = node.arguments.map(visitExpression).join(', '); 397 String args = node.arguments.map(visitExpression).join(', ');
397 return "concat [$args]"; 398 return "concat [$args]";
398 } 399 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 489
489 String visitCreateInstance(CreateInstance node) { 490 String visitCreateInstance(CreateInstance node) {
490 String className = node.classElement.name; 491 String className = node.classElement.name;
491 String arguments = node.arguments.map(visitExpression).join(', '); 492 String arguments = node.arguments.map(visitExpression).join(', ');
492 return 'CreateInstance $className($arguments)'; 493 return 'CreateInstance $className($arguments)';
493 } 494 }
494 495
495 496
496 @override 497 @override
497 String visitReadTypeVariable(ReadTypeVariable node) { 498 String visitReadTypeVariable(ReadTypeVariable node) {
498 return 'read ${node.variable.element} ${visitExpression(node.target)}'; 499 return 'Read ${node.variable.element} ${visitExpression(node.target)}';
499 } 500 }
500 501
501 @override 502 @override
502 String visitReifyRuntimeType(ReifyRuntimeType node) { 503 String visitReifyRuntimeType(ReifyRuntimeType node) {
503 return 'reify ${node.value}'; 504 return 'Reify ${node.value}';
505 }
506
507 @override
508 String visitTypeExpression(TypeExpression node) {
509 return node.dartType.toString();
504 } 510 }
505 } 511 }
506 512
507 /** 513 /**
508 * Invents (and remembers) names for Variables that do not have an associated 514 * Invents (and remembers) names for Variables that do not have an associated
509 * identifier. 515 * identifier.
510 * 516 *
511 * In case a variable is named v0, v1, etc, it may be assigned a different 517 * In case a variable is named v0, v1, etc, it may be assigned a different
512 * name to avoid clashing with a previously synthesized variable name. 518 * name to avoid clashing with a previously synthesized variable name.
513 */ 519 */
514 class Names { 520 class Names {
515 final Map<Variable, String> _names = {}; 521 final Map<Variable, String> _names = {};
516 final Set<String> _usedNames = new Set(); 522 final Set<String> _usedNames = new Set();
517 int _counter = 0; 523 int _counter = 0;
518 524
519 String varName(Variable v) { 525 String varName(Variable v) {
520 String name = _names[v]; 526 String name = _names[v];
521 if (name == null) { 527 if (name == null) {
522 String prefix = v.element == null ? 'v' : '${v.element.name}_'; 528 String prefix = v.element == null ? 'v' : '${v.element.name}_';
523 while (name == null || _usedNames.contains(name)) { 529 while (name == null || _usedNames.contains(name)) {
524 name = "$prefix${_counter++}"; 530 name = "$prefix${_counter++}";
525 } 531 }
526 _names[v] = name; 532 _names[v] = name;
527 _usedNames.add(name); 533 _usedNames.add(name);
528 } 534 }
529 return name; 535 return name;
530 } 536 }
531 } 537 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_basic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698