| 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 IndentN(indent); | 501 IndentN(indent); |
| 502 ISL_Print("}\n"); | 502 ISL_Print("}\n"); |
| 503 child = child->sibling(); | 503 child = child->sibling(); |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 | 507 |
| 508 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) { | 508 void AstPrinter::PrintFunctionScope(const ParsedFunction& parsed_function) { |
| 509 HANDLESCOPE(Isolate::Current()); | 509 HANDLESCOPE(Isolate::Current()); |
| 510 const Function& function = parsed_function.function(); | 510 const Function& function = parsed_function.function(); |
| 511 const Array& default_parameter_values = | |
| 512 parsed_function.default_parameter_values(); | |
| 513 SequenceNode* node_sequence = parsed_function.node_sequence(); | 511 SequenceNode* node_sequence = parsed_function.node_sequence(); |
| 514 ASSERT(node_sequence != NULL); | 512 ASSERT(node_sequence != NULL); |
| 515 const LocalScope* scope = node_sequence->scope(); | 513 const LocalScope* scope = node_sequence->scope(); |
| 516 ASSERT(scope != NULL); | 514 ASSERT(scope != NULL); |
| 517 const char* function_name = function.ToFullyQualifiedCString(); | 515 const char* function_name = function.ToFullyQualifiedCString(); |
| 518 ISL_Print("Scope for function '%s'\n{scope %p ", function_name, scope); | 516 ISL_Print("Scope for function '%s'\n{scope %p ", function_name, scope); |
| 519 if (scope->HasContextLevel()) { | 517 if (scope->HasContextLevel()) { |
| 520 ISL_Print("ctx %d numctxvar %d ", | 518 ISL_Print("ctx %d numctxvar %d ", |
| 521 scope->context_level(), | 519 scope->context_level(), |
| 522 scope->num_context_variables()); | 520 scope->num_context_variables()); |
| 523 } | 521 } |
| 524 ISL_Print("llev %d\n", scope->loop_level()); | 522 ISL_Print("llev %d\n", scope->loop_level()); |
| 525 const int num_fixed_params = function.num_fixed_parameters(); | 523 const int num_fixed_params = function.num_fixed_parameters(); |
| 526 const int num_params = num_fixed_params + function.NumOptionalParameters(); | 524 const int num_params = num_fixed_params + function.NumOptionalParameters(); |
| 527 // Parameters must be listed first and must all appear in the top scope. | 525 // Parameters must be listed first and must all appear in the top scope. |
| 528 ASSERT(num_params <= scope->num_variables()); | 526 ASSERT(num_params <= scope->num_variables()); |
| 529 int pos = 0; // Current position of variable in scope. | 527 int pos = 0; // Current position of variable in scope. |
| 530 int indent = kScopeIndent; | 528 int indent = kScopeIndent; |
| 531 while (pos < num_params) { | 529 while (pos < num_params) { |
| 532 LocalVariable* param = scope->VariableAt(pos); | 530 LocalVariable* param = scope->VariableAt(pos); |
| 533 ASSERT(param->owner() == scope); // No aliases should precede parameters. | 531 ASSERT(param->owner() == scope); // No aliases should precede parameters. |
| 534 IndentN(indent); | 532 IndentN(indent); |
| 535 ISL_Print("(param %s%s '%s'", | 533 ISL_Print("(param %s%s '%s'", |
| 536 param->is_final() ? "final " : "", | 534 param->is_final() ? "final " : "", |
| 537 String::Handle(param->type().Name()).ToCString(), | 535 String::Handle(param->type().Name()).ToCString(), |
| 538 param->name().ToCString()); | 536 param->name().ToCString()); |
| 539 // Print the default value if the parameter is optional. | 537 // Print the default value if the parameter is optional. |
| 540 if (pos >= num_fixed_params && pos < num_params) { | 538 if (pos >= num_fixed_params && pos < num_params) { |
| 541 const Object& default_parameter_value = Object::Handle( | 539 const Instance& default_parameter_value = |
| 542 default_parameter_values.At(pos - num_fixed_params)); | 540 parsed_function.DefaultParameterValueAt(pos - num_fixed_params); |
| 543 ISL_Print(" =%s", default_parameter_value.ToCString()); | 541 ISL_Print(" =%s", default_parameter_value.ToCString()); |
| 544 } | 542 } |
| 545 if (param->HasIndex()) { | 543 if (param->HasIndex()) { |
| 546 ISL_Print(" @%d", param->index()); | 544 ISL_Print(" @%d", param->index()); |
| 547 if (param->is_captured()) { | 545 if (param->is_captured()) { |
| 548 ISL_Print(" ctx %d", param->owner()->context_level()); | 546 ISL_Print(" ctx %d", param->owner()->context_level()); |
| 549 } | 547 } |
| 550 } | 548 } |
| 551 ISL_Print(" valid %" Pd "-%" Pd ")\n", | 549 ISL_Print(" valid %" Pd "-%" Pd ")\n", |
| 552 param->token_pos(), | 550 param->token_pos(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 565 ASSERT(node_sequence != NULL); | 563 ASSERT(node_sequence != NULL); |
| 566 AstPrinter ast_printer; | 564 AstPrinter ast_printer; |
| 567 const char* function_name = | 565 const char* function_name = |
| 568 parsed_function.function().ToFullyQualifiedCString(); | 566 parsed_function.function().ToFullyQualifiedCString(); |
| 569 ISL_Print("Ast for function '%s' {\n", function_name); | 567 ISL_Print("Ast for function '%s' {\n", function_name); |
| 570 node_sequence->Visit(&ast_printer); | 568 node_sequence->Visit(&ast_printer); |
| 571 ISL_Print("}\n"); | 569 ISL_Print("}\n"); |
| 572 } | 570 } |
| 573 | 571 |
| 574 } // namespace dart | 572 } // namespace dart |
| OLD | NEW |