OLD | NEW |
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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 OS::Print(" alias"); | 395 OS::Print(" alias"); |
396 } | 396 } |
397 if (var->HasIndex()) { | 397 if (var->HasIndex()) { |
398 OS::Print(" @%d", var->index()); | 398 OS::Print(" @%d", var->index()); |
399 if (var->is_captured()) { | 399 if (var->is_captured()) { |
400 OS::Print(" ctx %d", var->owner()->context_level()); | 400 OS::Print(" ctx %d", var->owner()->context_level()); |
401 } | 401 } |
402 } else if (var->owner()->function_level() != 0) { | 402 } else if (var->owner()->function_level() != 0) { |
403 OS::Print(" lev %d", var->owner()->function_level()); | 403 OS::Print(" lev %d", var->owner()->function_level()); |
404 } | 404 } |
405 OS::Print(" valid %d-%d)", var->token_index(), scope->end_token_index()); | 405 OS::Print(" valid %d-%d)", var->token_pos(), scope->end_token_pos()); |
406 } | 406 } |
407 const LocalScope* child = scope->child(); | 407 const LocalScope* child = scope->child(); |
408 while (child != NULL) { | 408 while (child != NULL) { |
409 OS::Print("{scope 0x%x ", child); | 409 OS::Print("{scope 0x%x ", child); |
410 if (child->HasContextLevel()) { | 410 if (child->HasContextLevel()) { |
411 OS::Print("ctx %d numctxvar %d ", | 411 OS::Print("ctx %d numctxvar %d ", |
412 child->context_level(), | 412 child->context_level(), |
413 child->num_context_variables()); | 413 child->num_context_variables()); |
414 } | 414 } |
415 OS::Print("llev %d ", child->loop_level()); | 415 OS::Print("llev %d ", child->loop_level()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 const Object& default_parameter_value = Object::Handle( | 455 const Object& default_parameter_value = Object::Handle( |
456 default_parameter_values.At(pos - num_fixed_params)); | 456 default_parameter_values.At(pos - num_fixed_params)); |
457 OS::Print(" =%s", default_parameter_value.ToCString()); | 457 OS::Print(" =%s", default_parameter_value.ToCString()); |
458 } | 458 } |
459 if (param->HasIndex()) { | 459 if (param->HasIndex()) { |
460 OS::Print(" @%d", param->index()); | 460 OS::Print(" @%d", param->index()); |
461 if (param->is_captured()) { | 461 if (param->is_captured()) { |
462 OS::Print(" ctx %d", param->owner()->context_level()); | 462 OS::Print(" ctx %d", param->owner()->context_level()); |
463 } | 463 } |
464 } | 464 } |
465 OS::Print(" valid %d-%d)", param->token_index(), scope->end_token_index()); | 465 OS::Print(" valid %d-%d)", param->token_pos(), scope->end_token_pos()); |
466 pos++; | 466 pos++; |
467 } | 467 } |
468 // Visit remaining non-parameter variables and children scopes. | 468 // Visit remaining non-parameter variables and children scopes. |
469 PrintLocalScope(scope, pos); | 469 PrintLocalScope(scope, pos); |
470 OS::Print("}\n"); | 470 OS::Print("}\n"); |
471 } | 471 } |
472 | 472 |
473 | 473 |
474 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { | 474 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { |
475 HANDLESCOPE(Isolate::Current()); | 475 HANDLESCOPE(Isolate::Current()); |
476 SequenceNode* node_sequence = parsed_function.node_sequence(); | 476 SequenceNode* node_sequence = parsed_function.node_sequence(); |
477 ASSERT(node_sequence != NULL); | 477 ASSERT(node_sequence != NULL); |
478 AstPrinter ast_printer; | 478 AstPrinter ast_printer; |
479 const char* function_name = | 479 const char* function_name = |
480 parsed_function.function().ToFullyQualifiedCString(); | 480 parsed_function.function().ToFullyQualifiedCString(); |
481 OS::Print("Ast for function '%s' {\n", function_name); | 481 OS::Print("Ast for function '%s' {\n", function_name); |
482 node_sequence->Visit(&ast_printer); | 482 node_sequence->Visit(&ast_printer); |
483 OS::Print("}\n"); | 483 OS::Print("}\n"); |
484 } | 484 } |
485 | 485 |
486 } // namespace dart | 486 } // namespace dart |
OLD | NEW |