Chromium Code Reviews| 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" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 AstPrinter::AstPrinter() { } | 14 AstPrinter::AstPrinter() { } |
| 15 | 15 |
| 16 | 16 |
| 17 AstPrinter::~AstPrinter() { } | 17 AstPrinter::~AstPrinter() { } |
| 18 | 18 |
| 19 | 19 |
| 20 void AstPrinter::VisitGenericAstNode(AstNode* node) { | 20 void AstPrinter::VisitGenericAstNode(AstNode* node) { |
| 21 OS::Print("(%s ", node->PrettyName()); | 21 OS::Print("(%s ", node->PrettyName()); |
| 22 node->VisitChildren(this); | 22 node->VisitChildren(this); |
| 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) { |
| 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. |
|
regis
2013/09/06 16:27:34
Feel free to remove this TODO :-)
It could be repl
| |
| 31 ASSERT(node_sequence != NULL); | 31 OS::Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); |
| 32 for (int i = 0; i < node_sequence->length(); i++) { | 32 for (int i = 0; i < node->length(); ++i) { |
| 33 OS::Print("scope %p: ", | |
| 34 node_sequence->scope()); | |
| 35 node_sequence->NodeAt(i)->Visit(this); | |
| 36 OS::Print("\n"); | 33 OS::Print("\n"); |
| 34 node->NodeAt(i)->Visit(this); | |
| 37 } | 35 } |
| 36 OS::Print(")"); | |
| 38 } | 37 } |
| 39 | 38 |
| 40 | 39 |
| 41 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { | 40 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { |
| 42 VisitGenericAstNode(node); | 41 VisitGenericAstNode(node); |
| 43 } | 42 } |
| 44 | 43 |
| 45 | 44 |
| 46 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) { | 45 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) { |
| 47 VisitGenericAstNode(arguments); | 46 VisitGenericAstNode(arguments); |
| 48 } | 47 } |
| 49 | 48 |
| 50 | 49 |
| 51 void AstPrinter::VisitReturnNode(ReturnNode* node) { | 50 void AstPrinter::VisitReturnNode(ReturnNode* node) { |
| 52 VisitGenericAstNode(node); | 51 VisitGenericAstNode(node); |
| 53 } | 52 } |
| 54 | 53 |
| 55 | 54 |
| 56 void AstPrinter::VisitGenericLocalNode(AstNode* node, | 55 void AstPrinter::VisitGenericLocalNode(AstNode* node, |
| 57 const LocalVariable& var) { | 56 const LocalVariable& var) { |
| 58 OS::Print("(%s %s%s '%s'", | 57 OS::Print("(%s %s%s \"%s\"", |
| 59 node->PrettyName(), | 58 node->PrettyName(), |
| 60 var.is_final() ? "final " : "", | 59 var.is_final() ? "final " : "", |
| 61 String::Handle(var.type().Name()).ToCString(), | 60 String::Handle(var.type().Name()).ToCString(), |
| 62 var.name().ToCString()); | 61 var.name().ToCString()); |
| 63 if (var.HasIndex()) { | 62 if (var.HasIndex()) { |
| 64 OS::Print(" @%d", var.index()); | |
| 65 if (var.is_captured()) { | 63 if (var.is_captured()) { |
| 66 OS::Print(" ctx %d", var.owner()->context_level()); | 64 OS::Print(" (context %d %d)", var.owner()->context_level(), var.index()); |
| 65 } else { | |
| 66 OS::Print(" (stack %d)", var.index()); | |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 OS::Print(" "); | |
| 69 node->VisitChildren(this); | 70 node->VisitChildren(this); |
| 70 OS::Print(")"); | 71 OS::Print(")"); |
| 71 } | 72 } |
| 72 | 73 |
| 73 | 74 |
| 74 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) { | 75 void AstPrinter::VisitLoadLocalNode(LoadLocalNode* node) { |
| 75 VisitGenericLocalNode(node, node->local()); | 76 VisitGenericLocalNode(node, node->local()); |
| 76 } | 77 } |
| 77 | 78 |
| 78 | 79 |
| 79 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) { | 80 void AstPrinter::VisitStoreLocalNode(StoreLocalNode* node) { |
| 80 VisitGenericLocalNode(node, node->local()); | 81 VisitGenericLocalNode(node, node->local()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 | 84 |
| 84 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) { | 85 void AstPrinter::VisitGenericFieldNode(AstNode* node, const Field& field) { |
| 85 OS::Print("(%s %s%s '%s' ", | 86 OS::Print("(%s %s%s \"%s\" ", |
| 86 node->PrettyName(), | 87 node->PrettyName(), |
| 87 field.is_final() ? "final " : "", | 88 field.is_final() ? "final " : "", |
| 88 String::Handle(AbstractType::Handle(field.type()).Name()). | 89 String::Handle(AbstractType::Handle(field.type()).Name()). |
| 89 ToCString(), | 90 ToCString(), |
| 90 String::Handle(field.name()).ToCString()); | 91 String::Handle(field.name()).ToCString()); |
| 91 node->VisitChildren(this); | 92 node->VisitChildren(this); |
| 92 OS::Print(")"); | 93 OS::Print(")"); |
| 93 } | 94 } |
| 94 | 95 |
| 95 | 96 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 118 } | 119 } |
| 119 | 120 |
| 120 | 121 |
| 121 void AstPrinter::VisitArrayNode(ArrayNode* node) { | 122 void AstPrinter::VisitArrayNode(ArrayNode* node) { |
| 122 VisitGenericAstNode(node); | 123 VisitGenericAstNode(node); |
| 123 } | 124 } |
| 124 | 125 |
| 125 | 126 |
| 126 void AstPrinter::VisitLiteralNode(LiteralNode* node) { | 127 void AstPrinter::VisitLiteralNode(LiteralNode* node) { |
| 127 const Instance& literal = node->literal(); | 128 const Instance& literal = node->literal(); |
| 128 OS::Print("'%s'", literal.ToCString()); | 129 OS::Print("(%s \"%s\")", node->PrettyName(), literal.ToCString()); |
| 129 } | 130 } |
| 130 | 131 |
| 131 | 132 |
| 132 void AstPrinter::VisitTypeNode(TypeNode* node) { | 133 void AstPrinter::VisitTypeNode(TypeNode* node) { |
| 133 const AbstractType& type = node->type(); | 134 const AbstractType& type = node->type(); |
| 134 OS::Print("'%s'", String::Handle(type.Name()).ToCString()); | 135 OS::Print("(%s \"%s\")", |
| 136 node->PrettyName(), | |
| 137 String::Handle(type.Name()).ToCString()); | |
| 135 } | 138 } |
| 136 | 139 |
| 137 | 140 |
| 138 void AstPrinter::VisitAssignableNode(AssignableNode* node) { | 141 void AstPrinter::VisitAssignableNode(AssignableNode* node) { |
| 139 OS::Print("(assignable "); | |
| 140 node->expr()->Visit(this); | |
| 141 const AbstractType& type = node->type(); | 142 const AbstractType& type = node->type(); |
| 142 const String& dst_name = node->dst_name(); | 143 const String& dst_name = node->dst_name(); |
| 143 OS::Print(" to type '%s' of '%s')", | 144 OS::Print("(%s (type \"%s\") (of \"%s\") ", |
| 145 node->PrettyName(), | |
| 144 String::Handle(type.Name()).ToCString(), | 146 String::Handle(type.Name()).ToCString(), |
| 145 dst_name.ToCString()); | 147 dst_name.ToCString()); |
| 148 node->VisitChildren(this); | |
| 149 OS::Print(")"); | |
| 146 } | 150 } |
| 147 | 151 |
| 148 | 152 |
| 149 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) { | 153 void AstPrinter::VisitPrimaryNode(PrimaryNode* node) { |
| 150 OS::Print("***** PRIMARY NODE IN AST ***** (primary '%s')", | 154 OS::Print("*****%s***** \"%s\")", |
| 155 node->PrettyName(), | |
| 151 node->primary().ToCString()); | 156 node->primary().ToCString()); |
| 152 } | 157 } |
| 153 | 158 |
| 154 | 159 |
| 155 void AstPrinter::VisitComparisonNode(ComparisonNode* node) { | 160 void AstPrinter::VisitComparisonNode(ComparisonNode* node) { |
| 156 if (node->kind() == Token::kAS) { | 161 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); |
| 157 OS::Print("(as "); | 162 node->VisitChildren(this); |
| 158 node->VisitChildren(this); | 163 OS::Print(")"); |
| 159 OS::Print(")"); | |
| 160 } else { | |
| 161 VisitGenericAstNode(node); | |
| 162 } | |
| 163 } | 164 } |
| 164 | 165 |
| 165 | 166 |
| 166 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) { | 167 void AstPrinter::VisitBinaryOpNode(BinaryOpNode* node) { |
| 167 VisitGenericAstNode(node); | 168 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); |
| 169 node->VisitChildren(this); | |
| 170 OS::Print(")"); | |
| 168 } | 171 } |
| 169 | 172 |
| 170 | 173 |
| 171 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) { | 174 void AstPrinter::VisitBinaryOpWithMask32Node(BinaryOpWithMask32Node* node) { |
| 172 OS::Print("(%s %s", node->PrettyName(), node->TokenName()); | 175 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); |
| 173 node->VisitChildren(this); | 176 node->VisitChildren(this); |
| 174 OS::Print(" & 0x%" Px64 "", node->mask32()); | 177 OS::Print(" & \"0x%" Px64 "", node->mask32()); |
| 178 OS::Print("\")"); | |
| 179 } | |
| 180 | |
| 181 | |
| 182 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) { | |
| 183 OS::Print("(%s %s ", node->PrettyName(), node->TokenName()); | |
| 184 node->VisitChildren(this); | |
| 175 OS::Print(")"); | 185 OS::Print(")"); |
| 176 } | 186 } |
| 177 | 187 |
| 178 | 188 |
| 179 void AstPrinter::VisitUnaryOpNode(UnaryOpNode* node) { | |
| 180 VisitGenericAstNode(node); | |
| 181 } | |
| 182 | |
| 183 | |
| 184 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) { | 189 void AstPrinter::VisitConditionalExprNode(ConditionalExprNode* node) { |
| 185 VisitGenericAstNode(node); | 190 VisitGenericAstNode(node); |
| 186 } | 191 } |
| 187 | 192 |
| 188 | 193 |
| 189 void AstPrinter::VisitIfNode(IfNode* node) { | 194 void AstPrinter::VisitIfNode(IfNode* node) { |
| 190 OS::Print("(if "); | 195 VisitGenericAstNode(node); |
| 191 node->condition()->Visit(this); | |
| 192 OS::Print(" then "); | |
| 193 node->true_branch()->Visit(this); | |
| 194 OS::Print(" else "); | |
| 195 if (node->false_branch() != NULL) { | |
| 196 node->false_branch()->Visit(this); | |
| 197 } | |
| 198 OS::Print(")"); | |
| 199 } | 196 } |
| 200 | 197 |
| 201 | 198 |
| 202 void AstPrinter::VisitCaseNode(CaseNode* node) { | 199 void AstPrinter::VisitCaseNode(CaseNode* node) { |
| 203 OS::Print("(case ("); | 200 OS::Print("(%s (", node->PrettyName()); |
| 204 for (int i = 0; i < node->case_expressions()->length(); i++) { | 201 for (int i = 0; i < node->case_expressions()->length(); i++) { |
| 205 node->case_expressions()->NodeAt(i)->Visit(this); | 202 node->case_expressions()->NodeAt(i)->Visit(this); |
| 206 } | 203 } |
| 207 if (node->contains_default()) { | 204 if (node->contains_default()) { |
| 208 OS::Print(" default "); | 205 OS::Print(" default"); |
| 209 } | 206 } |
| 210 OS::Print(")"); | 207 OS::Print(")"); |
| 211 node->statements()->Visit(this); | 208 node->statements()->Visit(this); |
| 212 OS::Print(")"); | 209 OS::Print(")"); |
| 213 } | 210 } |
| 214 | 211 |
| 215 | 212 |
| 216 void AstPrinter::VisitSwitchNode(SwitchNode* node) { | 213 void AstPrinter::VisitSwitchNode(SwitchNode* node) { |
| 217 OS::Print("(switch "); | 214 VisitGenericAstNode(node); |
| 215 } | |
| 216 | |
| 217 | |
| 218 void AstPrinter::VisitWhileNode(WhileNode* node) { | |
| 219 VisitGenericAstNode(node); | |
| 220 } | |
| 221 | |
| 222 | |
| 223 void AstPrinter::VisitForNode(ForNode* node) { | |
| 224 // Complicated because the condition is optional and so we clearly want to | |
| 225 // indicate the subparts. | |
| 226 OS::Print("(%s (init ", node->PrettyName()); | |
| 227 node->initializer()->Visit(this); | |
| 228 if (node->condition() != NULL) { | |
| 229 OS::Print(") (cond "); | |
| 230 node->condition()->Visit(this); | |
| 231 } | |
| 232 OS::Print(") (update "); | |
| 233 node->increment()->Visit(this); | |
| 234 OS::Print(") "); | |
| 218 node->body()->Visit(this); | 235 node->body()->Visit(this); |
| 219 OS::Print(")"); | 236 OS::Print(")"); |
| 220 } | 237 } |
| 221 | 238 |
| 222 | 239 |
| 223 void AstPrinter::VisitWhileNode(WhileNode* node) { | |
| 224 OS::Print("(while "); | |
| 225 node->condition()->Visit(this); | |
| 226 OS::Print(" do "); | |
| 227 node->body()->Visit(this); | |
| 228 OS::Print(")"); | |
| 229 } | |
| 230 | |
| 231 | |
| 232 void AstPrinter::VisitForNode(ForNode* node) { | |
| 233 OS::Print("(for (init: "); | |
| 234 node->initializer()->Visit(this); | |
| 235 OS::Print("; cond:"); | |
| 236 if (node->condition() != NULL) { | |
| 237 node->condition()->Visit(this); | |
| 238 } | |
| 239 OS::Print("; incr:"); | |
| 240 node->increment()->Visit(this); | |
| 241 OS::Print(") body:"); | |
| 242 node->body()->Visit(this); | |
| 243 OS::Print("endfor)"); | |
| 244 } | |
| 245 | |
| 246 | |
| 247 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) { | 240 void AstPrinter::VisitDoWhileNode(DoWhileNode* node) { |
| 248 OS::Print("(do "); | 241 VisitGenericAstNode(node); |
| 249 node->body()->Visit(this); | |
| 250 OS::Print(" while "); | |
| 251 node->condition()->Visit(this); | |
| 252 OS::Print(")"); | |
| 253 } | 242 } |
| 254 | 243 |
| 255 | 244 |
| 256 void AstPrinter::VisitJumpNode(JumpNode* node) { | 245 void AstPrinter::VisitJumpNode(JumpNode* node) { |
| 257 OS::Print("(%s %s %s in scope %p)", | 246 OS::Print("(%s %s %s (scope \"%p\"))", |
| 258 node->PrettyName(), | 247 node->PrettyName(), |
| 259 node->TokenName(), | 248 node->TokenName(), |
| 260 node->label()->name().ToCString(), | 249 node->label()->name().ToCString(), |
| 261 node->label()->owner()); | 250 node->label()->owner()); |
| 262 } | 251 } |
| 263 | 252 |
| 264 | 253 |
| 265 void AstPrinter::VisitInstanceCallNode(InstanceCallNode* node) { | 254 void AstPrinter::VisitInstanceCallNode(InstanceCallNode* node) { |
| 266 OS::Print("(%s '%s'(", node->PrettyName(), node->function_name().ToCString()); | 255 OS::Print("(%s \"%s\" ", |
| 256 node->PrettyName(), | |
| 257 node->function_name().ToCString()); | |
| 267 node->VisitChildren(this); | 258 node->VisitChildren(this); |
| 268 OS::Print("))"); | 259 OS::Print(")"); |
| 269 } | 260 } |
| 270 | 261 |
| 271 | 262 |
| 272 void AstPrinter::VisitStaticCallNode(StaticCallNode* node) { | 263 void AstPrinter::VisitStaticCallNode(StaticCallNode* node) { |
| 273 const char* function_fullname = node->function().ToFullyQualifiedCString(); | 264 const char* function_fullname = node->function().ToFullyQualifiedCString(); |
| 274 OS::Print("(%s '%s'(", node->PrettyName(), function_fullname); | 265 OS::Print("(%s \"%s\" ", node->PrettyName(), function_fullname); |
| 275 node->VisitChildren(this); | 266 node->VisitChildren(this); |
| 276 OS::Print("))"); | 267 OS::Print(")"); |
| 277 } | 268 } |
| 278 | 269 |
| 279 | 270 |
| 280 void AstPrinter::VisitClosureNode(ClosureNode* node) { | 271 void AstPrinter::VisitClosureNode(ClosureNode* node) { |
| 281 const char* function_fullname = node->function().ToFullyQualifiedCString(); | 272 const char* function_fullname = node->function().ToFullyQualifiedCString(); |
| 282 OS::Print("(%s '%s')", node->PrettyName(), function_fullname); | 273 OS::Print("(%s \"%s\")", node->PrettyName(), function_fullname); |
| 283 } | 274 } |
| 284 | 275 |
| 285 | 276 |
| 286 void AstPrinter::VisitClosureCallNode(ClosureCallNode* node) { | 277 void AstPrinter::VisitClosureCallNode(ClosureCallNode* node) { |
| 287 VisitGenericAstNode(node); | 278 VisitGenericAstNode(node); |
| 288 } | 279 } |
| 289 | 280 |
| 290 | 281 |
| 291 void AstPrinter::VisitConstructorCallNode(ConstructorCallNode* node) { | 282 void AstPrinter::VisitConstructorCallNode(ConstructorCallNode* node) { |
| 292 const char* kind = node->constructor().IsFactory() ? "factory " : ""; | 283 const char* kind = node->constructor().IsFactory() ? "factory " : ""; |
| 293 const char* constructor_name = node->constructor().ToFullyQualifiedCString(); | 284 const char* constructor_name = node->constructor().ToFullyQualifiedCString(); |
| 294 OS::Print("(%s %s'%s' ((this)", node->PrettyName(), kind, constructor_name); | 285 OS::Print("(%s %s \"%s\" ", node->PrettyName(), kind, constructor_name); |
| 295 node->VisitChildren(this); | 286 node->VisitChildren(this); |
| 296 OS::Print("))"); | 287 OS::Print(")"); |
| 297 } | 288 } |
| 298 | 289 |
| 299 | 290 |
| 300 void AstPrinter::VisitInstanceGetterNode(InstanceGetterNode* node) { | 291 void AstPrinter::VisitInstanceGetterNode(InstanceGetterNode* node) { |
| 301 OS::Print("(%s 'get %s'(", | 292 OS::Print("(%s \"%s\" ", |
| 302 node->PrettyName(), | 293 node->PrettyName(), |
| 303 node->field_name().ToCString()); | 294 node->field_name().ToCString()); |
| 304 node->VisitChildren(this); | 295 node->VisitChildren(this); |
| 305 OS::Print("))"); | 296 OS::Print(")"); |
| 306 } | 297 } |
| 307 | 298 |
| 308 | 299 |
| 309 void AstPrinter::VisitInstanceSetterNode(InstanceSetterNode* node) { | 300 void AstPrinter::VisitInstanceSetterNode(InstanceSetterNode* node) { |
| 310 OS::Print("(%s 'set %s'(", | 301 OS::Print("(%s \"%s\" ", |
| 311 node->PrettyName(), | 302 node->PrettyName(), |
| 312 node->field_name().ToCString()); | 303 node->field_name().ToCString()); |
| 313 node->VisitChildren(this); | 304 node->VisitChildren(this); |
| 314 OS::Print("))"); | 305 OS::Print(")"); |
| 315 } | 306 } |
| 316 | 307 |
| 317 | 308 |
| 318 void AstPrinter::VisitStaticGetterNode(StaticGetterNode* node) { | 309 void AstPrinter::VisitStaticGetterNode(StaticGetterNode* node) { |
| 319 String& class_name = String::Handle(node->cls().Name()); | 310 String& class_name = String::Handle(node->cls().Name()); |
| 320 OS::Print("(%s '%s.%s'(", | 311 OS::Print("(%s \"%s.%s\")", |
| 321 node->PrettyName(), | 312 node->PrettyName(), |
| 322 class_name.ToCString(), | 313 class_name.ToCString(), |
| 323 node->field_name().ToCString()); | 314 node->field_name().ToCString()); |
| 324 OS::Print("))"); | |
| 325 } | 315 } |
| 326 | 316 |
| 327 | 317 |
| 328 void AstPrinter::VisitStaticSetterNode(StaticSetterNode* node) { | 318 void AstPrinter::VisitStaticSetterNode(StaticSetterNode* node) { |
| 329 String& class_name = String::Handle(node->cls().Name()); | 319 String& class_name = String::Handle(node->cls().Name()); |
| 330 OS::Print("(%s '%s.%s'(", | 320 OS::Print("(%s \"%s.%s\" ", |
| 331 node->PrettyName(), | 321 node->PrettyName(), |
| 332 class_name.ToCString(), | 322 class_name.ToCString(), |
| 333 node->field_name().ToCString()); | 323 node->field_name().ToCString()); |
| 334 node->VisitChildren(this); | 324 node->VisitChildren(this); |
| 335 OS::Print("))"); | 325 OS::Print(")"); |
| 336 } | 326 } |
| 337 | 327 |
| 338 | 328 |
| 339 void AstPrinter::VisitLoadIndexedNode(LoadIndexedNode* node) { | 329 void AstPrinter::VisitLoadIndexedNode(LoadIndexedNode* node) { |
| 340 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperLoad() ? " super" : ""); | 330 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperLoad() ? " super" : ""); |
| 341 node->VisitChildren(this); | 331 node->VisitChildren(this); |
| 342 OS::Print(")"); | 332 OS::Print(")"); |
| 343 } | 333 } |
| 344 | 334 |
| 345 | 335 |
| 346 void AstPrinter::VisitStoreIndexedNode(StoreIndexedNode* node) { | 336 void AstPrinter::VisitStoreIndexedNode(StoreIndexedNode* node) { |
| 347 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperStore() ? " super" : ""); | 337 OS::Print("(%s%s ", node->PrettyName(), node->IsSuperStore() ? " super" : ""); |
| 348 node->VisitChildren(this); | 338 node->VisitChildren(this); |
| 349 OS::Print(")"); | 339 OS::Print(")"); |
| 350 } | 340 } |
| 351 | 341 |
| 352 | 342 |
| 353 void AstPrinter::VisitNativeBodyNode(NativeBodyNode* node) { | 343 void AstPrinter::VisitNativeBodyNode(NativeBodyNode* node) { |
| 354 OS::Print("(native_c call '%s'(%d args))", | 344 OS::Print("(%s \"%s\" (%d args))", |
| 345 node->PrettyName(), | |
| 355 node->native_c_function_name().ToCString(), | 346 node->native_c_function_name().ToCString(), |
| 356 NativeArguments::ParameterCountForResolution(node->function())); | 347 NativeArguments::ParameterCountForResolution(node->function())); |
| 357 } | 348 } |
| 358 | 349 |
| 359 | 350 |
| 360 void AstPrinter::VisitCatchClauseNode(CatchClauseNode* node) { | 351 void AstPrinter::VisitCatchClauseNode(CatchClauseNode* node) { |
| 361 node->VisitChildren(this); | 352 VisitGenericAstNode(node); |
| 362 } | 353 } |
| 363 | 354 |
| 364 | 355 |
| 365 void AstPrinter::VisitTryCatchNode(TryCatchNode* node) { | 356 void AstPrinter::VisitTryCatchNode(TryCatchNode* node) { |
| 366 OS::Print("("); | 357 OS::Print("(%s ", node->PrettyName()); |
| 367 | |
| 368 // First visit the try block. | |
| 369 OS::Print("(try block ("); | |
| 370 node->try_block()->Visit(this); | 358 node->try_block()->Visit(this); |
| 371 OS::Print("))"); | |
| 372 | |
| 373 // Now visit the catch block if it exists. | |
| 374 if (node->catch_block() != NULL) { | 359 if (node->catch_block() != NULL) { |
| 375 OS::Print("(catch block () ("); | |
| 376 node->catch_block()->Visit(this); | 360 node->catch_block()->Visit(this); |
| 377 OS::Print("))"); | |
| 378 } | 361 } |
| 379 | |
| 380 // Now visit the finally block if it exists. | |
| 381 if (node->finally_block() != NULL) { | 362 if (node->finally_block() != NULL) { |
| 382 OS::Print("(finally block () ("); | 363 OS::Print("(finally "); |
| 383 node->finally_block()->Visit(this); | 364 node->finally_block()->Visit(this); |
| 384 OS::Print("))"); | 365 OS::Print(")"); |
| 385 } | 366 } |
| 386 | |
| 387 OS::Print(")"); | 367 OS::Print(")"); |
| 388 } | 368 } |
| 389 | 369 |
| 390 | 370 |
| 391 void AstPrinter::VisitThrowNode(ThrowNode* node) { | 371 void AstPrinter::VisitThrowNode(ThrowNode* node) { |
| 392 VisitGenericAstNode(node); | 372 VisitGenericAstNode(node); |
| 393 } | 373 } |
| 394 | 374 |
| 395 | 375 |
| 396 void AstPrinter::VisitInlinedFinallyNode(InlinedFinallyNode* node) { | 376 void AstPrinter::VisitInlinedFinallyNode(InlinedFinallyNode* node) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 ASSERT(node_sequence != NULL); | 484 ASSERT(node_sequence != NULL); |
| 505 AstPrinter ast_printer; | 485 AstPrinter ast_printer; |
| 506 const char* function_name = | 486 const char* function_name = |
| 507 parsed_function.function().ToFullyQualifiedCString(); | 487 parsed_function.function().ToFullyQualifiedCString(); |
| 508 OS::Print("Ast for function '%s' {\n", function_name); | 488 OS::Print("Ast for function '%s' {\n", function_name); |
| 509 node_sequence->Visit(&ast_printer); | 489 node_sequence->Visit(&ast_printer); |
| 510 OS::Print("}\n"); | 490 OS::Print("}\n"); |
| 511 } | 491 } |
| 512 | 492 |
| 513 } // namespace dart | 493 } // namespace dart |
| OLD | NEW |