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

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

Issue 9392020: Fix context unchaining (issue 5991015). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 OS::Print(")"); 23 OS::Print(")");
24 } 24 }
25 25
26 26
27 void AstPrinter::VisitSequenceNode(SequenceNode* node_sequence) { 27 void AstPrinter::VisitSequenceNode(SequenceNode* node_sequence) {
28 // TODO(regis): Make the output more readable by indenting the nested 28 // TODO(regis): Make the output more readable by indenting the nested
29 // sequences. This could be achieved using a AstPrinterContext similar to the 29 // sequences. This could be achieved using a AstPrinterContext similar to the
30 // CodeGeneratorContext. 30 // CodeGeneratorContext.
31 ASSERT(node_sequence != NULL); 31 ASSERT(node_sequence != NULL);
32 for (int i = 0; i < node_sequence->length(); i++) { 32 for (int i = 0; i < node_sequence->length(); i++) {
33 OS::Print("id %d: ", node_sequence->NodeAt(i)->id()); 33 OS::Print("id %d, scope 0x%x: ",
34 node_sequence->NodeAt(i)->id(),
35 node_sequence->scope());
34 node_sequence->NodeAt(i)->Visit(this); 36 node_sequence->NodeAt(i)->Visit(this);
35 OS::Print("\n"); 37 OS::Print("\n");
36 } 38 }
37 } 39 }
38 40
39 41
40 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { 42 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) {
41 VisitGenericAstNode(node); 43 VisitGenericAstNode(node);
42 } 44 }
43 45
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) { 234 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) {
233 OS::Print("(do "); 235 OS::Print("(do ");
234 node->body()->Visit(this); 236 node->body()->Visit(this);
235 OS::Print(" while "); 237 OS::Print(" while ");
236 node->condition()->Visit(this); 238 node->condition()->Visit(this);
237 OS::Print(")"); 239 OS::Print(")");
238 } 240 }
239 241
240 242
241 void AstPrinter::VisitJumpNode(JumpNode* node) { 243 void AstPrinter::VisitJumpNode(JumpNode* node) {
242 OS::Print("(%s %s)", node->Name(), node->label()->name().ToCString()); 244 OS::Print("(%s %s in scope 0x%x)",
245 node->Name(),
246 node->label()->name().ToCString(),
247 node->label()->owner());
243 } 248 }
244 249
245 250
246 void AstPrinter::VisitIncrOpLocalNode(IncrOpLocalNode* node) { 251 void AstPrinter::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
247 VisitGenericLocalNode(node, node->local()); 252 VisitGenericLocalNode(node, node->local());
248 } 253 }
249 254
250 255
251 void AstPrinter::VisitIncrOpInstanceFieldNode(IncrOpInstanceFieldNode* node) { 256 void AstPrinter::VisitIncrOpInstanceFieldNode(IncrOpInstanceFieldNode* node) {
252 VisitGenericAstNode(node); 257 VisitGenericAstNode(node);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (var->is_captured()) { 419 if (var->is_captured()) {
415 OS::Print(" ctx %d", var->owner()->context_level()); 420 OS::Print(" ctx %d", var->owner()->context_level());
416 } 421 }
417 } else if (var->owner()->function_level() != 0) { 422 } else if (var->owner()->function_level() != 0) {
418 OS::Print(" lev %d", var->owner()->function_level()); 423 OS::Print(" lev %d", var->owner()->function_level());
419 } 424 }
420 OS::Print(" valid %d-%d)", var->token_index(), scope->end_token_index()); 425 OS::Print(" valid %d-%d)", var->token_index(), scope->end_token_index());
421 } 426 }
422 const LocalScope* child = scope->child(); 427 const LocalScope* child = scope->child();
423 while (child != NULL) { 428 while (child != NULL) {
424 OS::Print("{scope "); 429 OS::Print("{scope 0x%x ", child);
430 if (child->HasContextLevel()) {
431 OS::Print("ctx %d numctxvar %d ",
432 child->context_level(),
433 child->num_context_variables());
434 }
435 OS::Print("llev %d ", child->loop_level());
425 PrintLocalScope(child, 0); 436 PrintLocalScope(child, 0);
426 OS::Print("}"); 437 OS::Print("}");
427 child = child->sibling(); 438 child = child->sibling();
428 } 439 }
429 } 440 }
430 441
431 442
432 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) { 443 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) {
433 HANDLESCOPE(Isolate::Current()); 444 HANDLESCOPE(Isolate::Current());
434 const Function& function = parsed_function.function(); 445 const Function& function = parsed_function.function();
435 const Array& default_parameter_values = 446 const Array& default_parameter_values =
436 parsed_function.default_parameter_values(); 447 parsed_function.default_parameter_values();
437 SequenceNode* node_sequence = parsed_function.node_sequence(); 448 SequenceNode* node_sequence = parsed_function.node_sequence();
438 ASSERT(node_sequence != NULL); 449 ASSERT(node_sequence != NULL);
439 const LocalScope* scope = node_sequence->scope(); 450 const LocalScope* scope = node_sequence->scope();
440 ASSERT(scope != NULL); 451 ASSERT(scope != NULL);
441 const char* function_name = function.ToFullyQualifiedCString(); 452 const char* function_name = function.ToFullyQualifiedCString();
442 OS::Print("Scope for function '%s' {\n", function_name); 453 OS::Print("Scope for function '%s' {scope 0x%x ", function_name, scope);
454 if (scope->HasContextLevel()) {
455 OS::Print("ctx %d numctxvar %d ",
456 scope->context_level(),
457 scope->num_context_variables());
458 }
459 OS::Print("llev %d ", scope->loop_level());
443 const int num_fixed_params = function.num_fixed_parameters(); 460 const int num_fixed_params = function.num_fixed_parameters();
444 const int num_opt_params = function.num_optional_parameters(); 461 const int num_opt_params = function.num_optional_parameters();
445 const int num_params = num_fixed_params + num_opt_params; 462 const int num_params = num_fixed_params + num_opt_params;
446 // Parameters must be listed first and must all appear in the top scope. 463 // Parameters must be listed first and must all appear in the top scope.
447 ASSERT(num_params <= scope->num_variables()); 464 ASSERT(num_params <= scope->num_variables());
448 int pos = 0; // Current position of variable in scope. 465 int pos = 0; // Current position of variable in scope.
449 while (pos < num_params) { 466 while (pos < num_params) {
450 LocalVariable* param = scope->VariableAt(pos); 467 LocalVariable* param = scope->VariableAt(pos);
451 ASSERT(param->owner() == scope); 468 ASSERT(param->owner() == scope);
452 OS::Print("(param %s%s '%s'", 469 OS::Print("(param %s%s '%s'",
(...skipping 27 matching lines...) Expand all
480 ASSERT(node_sequence != NULL); 497 ASSERT(node_sequence != NULL);
481 AstPrinter ast_printer; 498 AstPrinter ast_printer;
482 const char* function_name = 499 const char* function_name =
483 parsed_function.function().ToFullyQualifiedCString(); 500 parsed_function.function().ToFullyQualifiedCString();
484 OS::Print("Ast for function '%s' {\n", function_name); 501 OS::Print("Ast for function '%s' {\n", function_name);
485 node_sequence->Visit(&ast_printer); 502 node_sequence->Visit(&ast_printer);
486 OS::Print("}\n"); 503 OS::Print("}\n");
487 } 504 }
488 505
489 } // namespace dart 506 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698