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/log.h" | 8 #include "vm/log.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 THR_Print(")"); | 24 THR_Print(")"); |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 void AstPrinter::VisitSequenceNode(SequenceNode* node) { | 28 void AstPrinter::VisitSequenceNode(SequenceNode* node) { |
29 indent_++; | 29 indent_++; |
30 LocalScope* scope = node->scope(); | 30 LocalScope* scope = node->scope(); |
31 THR_Print("(%s (scope \"%p\"", node->PrettyName(), scope); | 31 THR_Print("(%s (scope \"%p\"", node->PrettyName(), scope); |
32 if (scope != NULL) { | 32 if (scope != NULL) { |
33 THR_Print(" (%" Pd "-%" Pd ") loop %d", | 33 THR_Print(" (%" Pd "-%" Pd ") loop %d", |
34 scope->begin_token_pos(), | 34 scope->begin_token_pos().value(), |
Ivan Posva
2016/02/01 17:16:52
ditto.
Cutch
2016/02/02 18:00:20
Done.
| |
35 scope->end_token_pos(), | 35 scope->end_token_pos().value(), |
36 scope->loop_level()); | 36 scope->loop_level()); |
37 if (scope->HasContextLevel()) { | 37 if (scope->HasContextLevel()) { |
38 THR_Print(" context %d captures %d", | 38 THR_Print(" context %d captures %d", |
39 scope->context_level(), | 39 scope->context_level(), |
40 scope->num_context_variables()); | 40 scope->num_context_variables()); |
41 } else { | 41 } else { |
42 ASSERT(scope->num_context_variables() == 0); | 42 ASSERT(scope->num_context_variables() == 0); |
43 } | 43 } |
44 } | 44 } |
45 THR_Print(")"); | 45 THR_Print(")"); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 } | 472 } |
473 if (var->HasIndex()) { | 473 if (var->HasIndex()) { |
474 THR_Print(" @%d", var->index()); | 474 THR_Print(" @%d", var->index()); |
475 if (var->is_captured()) { | 475 if (var->is_captured()) { |
476 THR_Print(" ctx %d", var->owner()->context_level()); | 476 THR_Print(" ctx %d", var->owner()->context_level()); |
477 } | 477 } |
478 } else if (var->owner()->function_level() != 0) { | 478 } else if (var->owner()->function_level() != 0) { |
479 THR_Print(" lev %d", var->owner()->function_level()); | 479 THR_Print(" lev %d", var->owner()->function_level()); |
480 } | 480 } |
481 THR_Print(" valid %" Pd "-%" Pd ")\n", | 481 THR_Print(" valid %" Pd "-%" Pd ")\n", |
482 var->token_pos(), | 482 var->token_pos().value(), |
483 scope->end_token_pos()); | 483 scope->end_token_pos().value()); |
484 } | 484 } |
485 | 485 |
486 | 486 |
487 void AstPrinter::PrintLocalScope(const LocalScope* scope, | 487 void AstPrinter::PrintLocalScope(const LocalScope* scope, |
488 int start_index, | 488 int start_index, |
489 int indent) { | 489 int indent) { |
490 ASSERT(scope != NULL); | 490 ASSERT(scope != NULL); |
491 for (int i = start_index; i < scope->num_variables(); i++) { | 491 for (int i = start_index; i < scope->num_variables(); i++) { |
492 LocalVariable* var = scope->VariableAt(i); | 492 LocalVariable* var = scope->VariableAt(i); |
493 PrintLocalScopeVariable(scope, var, indent); | 493 PrintLocalScopeVariable(scope, var, indent); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 parsed_function.DefaultParameterValueAt(pos - num_fixed_params); | 545 parsed_function.DefaultParameterValueAt(pos - num_fixed_params); |
546 THR_Print(" =%s", default_parameter_value.ToCString()); | 546 THR_Print(" =%s", default_parameter_value.ToCString()); |
547 } | 547 } |
548 if (param->HasIndex()) { | 548 if (param->HasIndex()) { |
549 THR_Print(" @%d", param->index()); | 549 THR_Print(" @%d", param->index()); |
550 if (param->is_captured()) { | 550 if (param->is_captured()) { |
551 THR_Print(" ctx %d", param->owner()->context_level()); | 551 THR_Print(" ctx %d", param->owner()->context_level()); |
552 } | 552 } |
553 } | 553 } |
554 THR_Print(" valid %" Pd "-%" Pd ")\n", | 554 THR_Print(" valid %" Pd "-%" Pd ")\n", |
555 param->token_pos(), | 555 param->token_pos().value(), |
556 scope->end_token_pos()); | 556 scope->end_token_pos().value()); |
557 pos++; | 557 pos++; |
558 } | 558 } |
559 // Visit remaining non-parameter variables and children scopes. | 559 // Visit remaining non-parameter variables and children scopes. |
560 PrintLocalScope(scope, pos, indent); | 560 PrintLocalScope(scope, pos, indent); |
561 THR_Print("}\n"); | 561 THR_Print("}\n"); |
562 } | 562 } |
563 | 563 |
564 | 564 |
565 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { | 565 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { |
566 HANDLESCOPE(parsed_function.thread()); | 566 HANDLESCOPE(parsed_function.thread()); |
567 SequenceNode* node_sequence = parsed_function.node_sequence(); | 567 SequenceNode* node_sequence = parsed_function.node_sequence(); |
568 ASSERT(node_sequence != NULL); | 568 ASSERT(node_sequence != NULL); |
569 AstPrinter ast_printer; | 569 AstPrinter ast_printer; |
570 const char* function_name = | 570 const char* function_name = |
571 parsed_function.function().ToFullyQualifiedCString(); | 571 parsed_function.function().ToFullyQualifiedCString(); |
572 THR_Print("Ast for function '%s' {\n", function_name); | 572 THR_Print("Ast for function '%s' {\n", function_name); |
573 node_sequence->Visit(&ast_printer); | 573 node_sequence->Visit(&ast_printer); |
574 THR_Print("}\n"); | 574 THR_Print("}\n"); |
575 } | 575 } |
576 | 576 |
577 } // namespace dart | 577 } // namespace dart |
OLD | NEW |