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

Side by Side Diff: runtime/vm/ast_printer.cc

Issue 8234016: Inline allocation of implicit closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "vm/ast_printer.h" 5 #include "vm/ast_printer.h"
6 6
7 #include "vm/handles.h" 7 #include "vm/handles.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 void AstPrinter::VisitReturnNode(ReturnNode* node) { 45 void AstPrinter::VisitReturnNode(ReturnNode* node) {
46 VisitGenericAstNode(node); 46 VisitGenericAstNode(node);
47 } 47 }
48 48
49 49
50 void AstPrinter::VisitGenericLocalNode(AstNode* node, 50 void AstPrinter::VisitGenericLocalNode(AstNode* node,
51 const LocalVariable& var) { 51 const LocalVariable& var) {
52 OS::Print("(%s %s%s '%s'", 52 OS::Print("(%s %s%s '%s'",
53 node->Name(), 53 node->Name(),
54 var.is_final() ? "final " : "", 54 var.is_final() ? "final " : "",
55 var.type().ToCString(), 55 String::Handle(var.type().Name()).ToCString(),
56 var.name().ToCString()); 56 var.name().ToCString());
57 if (var.HasIndex()) { 57 if (var.HasIndex()) {
58 OS::Print(" @%d", var.index()); 58 OS::Print(" @%d", var.index());
59 if (var.is_captured()) { 59 if (var.is_captured()) {
60 OS::Print(" ctx %d", var.owner()->context_level()); 60 OS::Print(" ctx %d", var.owner()->context_level());
61 } 61 }
62 } 62 }
63 node->VisitChildren(this); 63 node->VisitChildren(this);
64 OS::Print(")"); 64 OS::Print(")");
65 } 65 }
66 66
67 67
68 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) { 68 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) {
69 VisitGenericLocalNode(node, node->local()); 69 VisitGenericLocalNode(node, node->local());
70 } 70 }
71 71
72 72
73 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) { 73 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) {
74 VisitGenericLocalNode(node, node->local()); 74 VisitGenericLocalNode(node, node->local());
75 } 75 }
76 76
77 77
78 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) { 78 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) {
79 OS::Print("(%s %s%s '%s' ", 79 OS::Print("(%s %s%s '%s' ",
80 node->Name(), 80 node->Name(),
81 field.is_final() ? "final " : "", 81 field.is_final() ? "final " : "",
82 Type::Handle(field.type()).ToCString(), 82 String::Handle(Type::Handle(field.type()).Name()).ToCString(),
83 String::Handle(field.name()).ToCString()); 83 String::Handle(field.name()).ToCString());
84 node->VisitChildren(this); 84 node->VisitChildren(this);
85 OS::Print(")"); 85 OS::Print(")");
86 } 86 }
87 87
88 88
89 void AstPrinter::VisitLoadInstanceFieldNode(LoadInstanceFieldNode* node) { 89 void AstPrinter::VisitLoadInstanceFieldNode(LoadInstanceFieldNode* node) {
90 VisitGenericFieldNode(node, node->field()); 90 VisitGenericFieldNode(node, node->field());
91 } 91 }
92 92
(...skipping 19 matching lines...) Expand all
112 112
113 113
114 void AstPrinter::VisitLiteralNode(LiteralNode* node) { 114 void AstPrinter::VisitLiteralNode(LiteralNode* node) {
115 const Instance& literal = node->literal(); 115 const Instance& literal = node->literal();
116 OS::Print("'%s'", literal.ToCString()); 116 OS::Print("'%s'", literal.ToCString());
117 } 117 }
118 118
119 119
120 void AstPrinter::VisitTypeNode(TypeNode* node) { 120 void AstPrinter::VisitTypeNode(TypeNode* node) {
121 const Type& type = node->type(); 121 const Type& type = node->type();
122 OS::Print("'%s'", type.ToCString()); 122 OS::Print("'%s'", String::Handle(type.Name()).ToCString());
123 } 123 }
124 124
125 125
126 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) { 126 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) {
127 OS::Print("***** PRIMARY NODE IN AST ***** (%s '%s')", 127 OS::Print("***** PRIMARY NODE IN AST ***** (%s '%s')",
128 node->Name(), node->primary().ToCString()); 128 node->Name(), node->primary().ToCString());
129 } 129 }
130 130
131 131
132 void AstPrinter::VisitComparisonNode(ComparisonNode* node) { 132 void AstPrinter::VisitComparisonNode(ComparisonNode* node) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 395
396 void AstPrinter::PrintLocalScope(const LocalScope* scope, 396 void AstPrinter::PrintLocalScope(const LocalScope* scope,
397 int start_index) { 397 int start_index) {
398 ASSERT(scope != NULL); 398 ASSERT(scope != NULL);
399 for (int i = start_index; i < scope->num_variables(); i++) { 399 for (int i = start_index; i < scope->num_variables(); i++) {
400 LocalVariable* var = scope->VariableAt(i); 400 LocalVariable* var = scope->VariableAt(i);
401 OS::Print("(%s%s '%s'", 401 OS::Print("(%s%s '%s'",
402 var->is_final() ? "final " : "", 402 var->is_final() ? "final " : "",
403 var->type().ToCString(), 403 String::Handle(var->type().Name()).ToCString(),
404 var->name().ToCString()); 404 var->name().ToCString());
405 if (var->owner() != scope) { 405 if (var->owner() != scope) {
406 OS::Print(" alias"); 406 OS::Print(" alias");
407 } 407 }
408 if (var->HasIndex()) { 408 if (var->HasIndex()) {
409 OS::Print(" @%d", var->index()); 409 OS::Print(" @%d", var->index());
410 if (var->is_captured()) { 410 if (var->is_captured()) {
411 OS::Print(" ctx %d", var->owner()->context_level()); 411 OS::Print(" ctx %d", var->owner()->context_level());
412 } 412 }
413 } else if (var->owner()->function_level() != 0) { 413 } else if (var->owner()->function_level() != 0) {
(...skipping 26 matching lines...) Expand all
440 const int num_opt_params = function.num_optional_parameters(); 440 const int num_opt_params = function.num_optional_parameters();
441 const int num_params = num_fixed_params + num_opt_params; 441 const int num_params = num_fixed_params + num_opt_params;
442 // Parameters must be listed first and must all appear in the top scope. 442 // Parameters must be listed first and must all appear in the top scope.
443 ASSERT(num_params <= scope->num_variables()); 443 ASSERT(num_params <= scope->num_variables());
444 int pos = 0; // Current position of variable in scope. 444 int pos = 0; // Current position of variable in scope.
445 while (pos < num_params) { 445 while (pos < num_params) {
446 LocalVariable* param = scope->VariableAt(pos); 446 LocalVariable* param = scope->VariableAt(pos);
447 ASSERT(param->owner() == scope); 447 ASSERT(param->owner() == scope);
448 OS::Print("(param %s%s '%s'", 448 OS::Print("(param %s%s '%s'",
449 param->is_final() ? "final " : "", 449 param->is_final() ? "final " : "",
450 param->type().ToCString(), 450 String::Handle(param->type().Name()).ToCString(),
451 param->name().ToCString()); 451 param->name().ToCString());
452 // Print the default value if the parameter is optional. 452 // Print the default value if the parameter is optional.
453 if (pos >= num_fixed_params && pos < num_params) { 453 if (pos >= num_fixed_params && pos < num_params) {
454 const Object& default_parameter_value = Object::Handle( 454 const Object& default_parameter_value = Object::Handle(
455 default_parameter_values.At(pos - num_fixed_params)); 455 default_parameter_values.At(pos - num_fixed_params));
456 OS::Print(" =%s", default_parameter_value.ToCString()); 456 OS::Print(" =%s", default_parameter_value.ToCString());
457 } 457 }
458 if (param->HasIndex()) { 458 if (param->HasIndex()) {
459 OS::Print(" @%d", param->index()); 459 OS::Print(" @%d", param->index());
460 if (param->is_captured()) { 460 if (param->is_captured()) {
(...skipping 15 matching lines...) Expand all
476 ASSERT(node_sequence != NULL); 476 ASSERT(node_sequence != NULL);
477 AstPrinter ast_printer; 477 AstPrinter ast_printer;
478 const char* function_name = 478 const char* function_name =
479 parsed_function.function().ToFullyQualifiedCString(); 479 parsed_function.function().ToFullyQualifiedCString();
480 OS::Print("Ast for function '%s' {\n", function_name); 480 OS::Print("Ast for function '%s' {\n", function_name);
481 node_sequence->Visit(&ast_printer); 481 node_sequence->Visit(&ast_printer);
482 OS::Print("}\n"); 482 OS::Print("}\n");
483 } 483 }
484 484
485 } // namespace dart 485 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/code_generator.cc » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698