| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 | 165 |
| 166 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) { | 166 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) { |
| 167 VisitGenericAstNode(node); | 167 VisitGenericAstNode(node); |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) { | 171 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) { |
| 172 OS::Print("(%s ", node->Name()); | 172 OS::Print("(%s ", node->Name()); |
| 173 node->VisitChildren(this); | 173 node->VisitChildren(this); |
| 174 OS::Print(" & 0x%"Px64"", node->mask32()); | 174 OS::Print(" & 0x%" Px64 "", node->mask32()); |
| 175 OS::Print(")"); | 175 OS::Print(")"); |
| 176 } | 176 } |
| 177 | 177 |
| 178 | 178 |
| 179 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) { | 179 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) { |
| 180 VisitGenericAstNode(node); | 180 VisitGenericAstNode(node); |
| 181 } | 181 } |
| 182 | 182 |
| 183 | 183 |
| 184 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) { | 184 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 OS::Print(" alias"); | 412 OS::Print(" alias"); |
| 413 } | 413 } |
| 414 if (var->HasIndex()) { | 414 if (var->HasIndex()) { |
| 415 OS::Print(" @%d", var->index()); | 415 OS::Print(" @%d", var->index()); |
| 416 if (var->is_captured()) { | 416 if (var->is_captured()) { |
| 417 OS::Print(" ctx %d", var->owner()->context_level()); | 417 OS::Print(" ctx %d", var->owner()->context_level()); |
| 418 } | 418 } |
| 419 } else if (var->owner()->function_level() != 0) { | 419 } else if (var->owner()->function_level() != 0) { |
| 420 OS::Print(" lev %d", var->owner()->function_level()); | 420 OS::Print(" lev %d", var->owner()->function_level()); |
| 421 } | 421 } |
| 422 OS::Print(" valid %"Pd"-%"Pd")", | 422 OS::Print(" valid %" Pd "-%" Pd ")", |
| 423 var->token_pos(), | 423 var->token_pos(), |
| 424 scope->end_token_pos()); | 424 scope->end_token_pos()); |
| 425 } | 425 } |
| 426 const LocalScope* child = scope->child(); | 426 const LocalScope* child = scope->child(); |
| 427 while (child != NULL) { | 427 while (child != NULL) { |
| 428 OS::Print("{scope %p ", child); | 428 OS::Print("{scope %p ", child); |
| 429 if (child->HasContextLevel()) { | 429 if (child->HasContextLevel()) { |
| 430 OS::Print("ctx %d numctxvar %d ", | 430 OS::Print("ctx %d numctxvar %d ", |
| 431 child->context_level(), | 431 child->context_level(), |
| 432 child->num_context_variables()); | 432 child->num_context_variables()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 const Object& default_parameter_value = Object::Handle( | 473 const Object& default_parameter_value = Object::Handle( |
| 474 default_parameter_values.At(pos - num_fixed_params)); | 474 default_parameter_values.At(pos - num_fixed_params)); |
| 475 OS::Print(" =%s", default_parameter_value.ToCString()); | 475 OS::Print(" =%s", default_parameter_value.ToCString()); |
| 476 } | 476 } |
| 477 if (param->HasIndex()) { | 477 if (param->HasIndex()) { |
| 478 OS::Print(" @%d", param->index()); | 478 OS::Print(" @%d", param->index()); |
| 479 if (param->is_captured()) { | 479 if (param->is_captured()) { |
| 480 OS::Print(" ctx %d", param->owner()->context_level()); | 480 OS::Print(" ctx %d", param->owner()->context_level()); |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 OS::Print(" valid %"Pd"-%"Pd")", | 483 OS::Print(" valid %" Pd "-%" Pd ")", |
| 484 param->token_pos(), | 484 param->token_pos(), |
| 485 scope->end_token_pos()); | 485 scope->end_token_pos()); |
| 486 pos++; | 486 pos++; |
| 487 } | 487 } |
| 488 // Visit remaining non-parameter variables and children scopes. | 488 // Visit remaining non-parameter variables and children scopes. |
| 489 PrintLocalScope(scope, pos); | 489 PrintLocalScope(scope, pos); |
| 490 OS::Print("}\n"); | 490 OS::Print("}\n"); |
| 491 } | 491 } |
| 492 | 492 |
| 493 | 493 |
| 494 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { | 494 void AstPrinter::PrintFunctionNodes(const ParsedFunction& parsed_function) { |
| 495 HANDLESCOPE(Isolate::Current()); | 495 HANDLESCOPE(Isolate::Current()); |
| 496 SequenceNode* node_sequence = parsed_function.node_sequence(); | 496 SequenceNode* node_sequence = parsed_function.node_sequence(); |
| 497 ASSERT(node_sequence != NULL); | 497 ASSERT(node_sequence != NULL); |
| 498 AstPrinter ast_printer; | 498 AstPrinter ast_printer; |
| 499 const char* function_name = | 499 const char* function_name = |
| 500 parsed_function.function().ToFullyQualifiedCString(); | 500 parsed_function.function().ToFullyQualifiedCString(); |
| 501 OS::Print("Ast for function '%s' {\n", function_name); | 501 OS::Print("Ast for function '%s' {\n", function_name); |
| 502 node_sequence->Visit(&ast_printer); | 502 node_sequence->Visit(&ast_printer); |
| 503 OS::Print("}\n"); | 503 OS::Print("}\n"); |
| 504 } | 504 } |
| 505 | 505 |
| 506 } // namespace dart | 506 } // namespace dart |
| OLD | NEW |