| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 StaticCallComp* call = | 419 StaticCallComp* call = |
| 420 new StaticCallComp(node->token_index(), | 420 new StaticCallComp(node->token_index(), |
| 421 owner()->try_index(), | 421 owner()->try_index(), |
| 422 interpol_func, | 422 interpol_func, |
| 423 interpol_arg->names(), | 423 interpol_arg->names(), |
| 424 values); | 424 values); |
| 425 ReturnComputation(call); | 425 ReturnComputation(call); |
| 426 } | 426 } |
| 427 | 427 |
| 428 | 428 |
| 429 void EffectGraphVisitor::BuildInstanceOf(ComparisonNode* node) { |
| 430 ASSERT(Token::IsInstanceofOperator(node->kind())); |
| 431 ArgumentGraphVisitor for_left_value(owner(), temp_index()); |
| 432 node->left()->Visit(&for_left_value); |
| 433 Append(for_left_value); |
| 434 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 435 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 436 Value* type_arguments = NULL; |
| 437 if (!type.IsInstantiated()) { |
| 438 type_arguments = BuildInstantiatorTypeArguments( |
| 439 node->token_index(), for_left_value.temp_index()); |
| 440 } |
| 441 InstanceOfComp* instance_of = new InstanceOfComp( |
| 442 node->id(), |
| 443 node->token_index(), |
| 444 owner()->try_index(), |
| 445 for_left_value.value(), |
| 446 type_arguments, |
| 447 node->right()->AsTypeNode()->type(), |
| 448 (node->kind() == Token::kISNOT)); |
| 449 ReturnComputation(instance_of); |
| 450 } |
| 451 |
| 452 |
| 429 // <Expression> :: Comparison { kind: Token::Kind | 453 // <Expression> :: Comparison { kind: Token::Kind |
| 430 // left: <Expression> | 454 // left: <Expression> |
| 431 // right: <Expression> } | 455 // right: <Expression> } |
| 432 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 456 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 433 if (Token::IsInstanceofOperator(node->kind())) { | 457 if (Token::IsInstanceofOperator(node->kind())) { |
| 434 ArgumentGraphVisitor for_left_value(owner(), temp_index()); | 458 BuildInstanceOf(node); |
| 435 node->left()->Visit(&for_left_value); | |
| 436 Append(for_left_value); | |
| 437 InstanceOfComp* instance_of = new InstanceOfComp( | |
| 438 node->id(), | |
| 439 node->token_index(), | |
| 440 owner()->try_index(), | |
| 441 for_left_value.value(), | |
| 442 node->right()->AsTypeNode()->type(), | |
| 443 (node->kind() == Token::kISNOT)); | |
| 444 ReturnComputation(instance_of); | |
| 445 return; | 459 return; |
| 446 } | 460 } |
| 447 if ((node->kind() == Token::kEQ_STRICT) || | 461 if ((node->kind() == Token::kEQ_STRICT) || |
| 448 (node->kind() == Token::kNE_STRICT)) { | 462 (node->kind() == Token::kNE_STRICT)) { |
| 449 ValueGraphVisitor for_left_value(owner(), temp_index()); | 463 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 450 node->left()->Visit(&for_left_value); | 464 node->left()->Visit(&for_left_value); |
| 451 Append(for_left_value); | 465 Append(for_left_value); |
| 452 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); | 466 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); |
| 453 node->right()->Visit(&for_right_value); | 467 node->right()->Visit(&for_right_value); |
| 454 Append(for_right_value); | 468 Append(for_right_value); |
| (...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 OS::Print("! "); | 2234 OS::Print("! "); |
| 2221 comp->value()->Accept(this); | 2235 comp->value()->Accept(this); |
| 2222 } | 2236 } |
| 2223 | 2237 |
| 2224 | 2238 |
| 2225 void FlowGraphPrinter::VisitInstanceOf(InstanceOfComp* comp) { | 2239 void FlowGraphPrinter::VisitInstanceOf(InstanceOfComp* comp) { |
| 2226 comp->value()->Accept(this); | 2240 comp->value()->Accept(this); |
| 2227 OS::Print(" %s %s", | 2241 OS::Print(" %s %s", |
| 2228 comp->negate_result() ? "ISNOT" : "IS", | 2242 comp->negate_result() ? "ISNOT" : "IS", |
| 2229 String::Handle(comp->type().Name()).ToCString()); | 2243 String::Handle(comp->type().Name()).ToCString()); |
| 2244 if (comp->type_arguments() != NULL) { |
| 2245 OS::Print(" (type-arg:"); |
| 2246 comp->type_arguments()->Accept(this); |
| 2247 OS::Print(")"); |
| 2248 } |
| 2230 } | 2249 } |
| 2231 | 2250 |
| 2232 | 2251 |
| 2233 void FlowGraphPrinter::VisitAllocateObject(AllocateObjectComp* comp) { | 2252 void FlowGraphPrinter::VisitAllocateObject(AllocateObjectComp* comp) { |
| 2234 OS::Print("AllocateObject(%s", | 2253 OS::Print("AllocateObject(%s", |
| 2235 Class::Handle(comp->constructor().owner()).ToCString()); | 2254 Class::Handle(comp->constructor().owner()).ToCString()); |
| 2236 for (intptr_t i = 0; i < comp->arguments().length(); i++) { | 2255 for (intptr_t i = 0; i < comp->arguments().length(); i++) { |
| 2237 OS::Print(", "); | 2256 OS::Print(", "); |
| 2238 comp->arguments()[i]->Accept(this); | 2257 comp->arguments()[i]->Accept(this); |
| 2239 } | 2258 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2529 char* chars = reinterpret_cast<char*>( | 2548 char* chars = reinterpret_cast<char*>( |
| 2530 Isolate::Current()->current_zone()->Allocate(len)); | 2549 Isolate::Current()->current_zone()->Allocate(len)); |
| 2531 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2550 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2532 const Error& error = Error::Handle( | 2551 const Error& error = Error::Handle( |
| 2533 LanguageError::New(String::Handle(String::New(chars)))); | 2552 LanguageError::New(String::Handle(String::New(chars)))); |
| 2534 Isolate::Current()->long_jump_base()->Jump(1, error); | 2553 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2535 } | 2554 } |
| 2536 | 2555 |
| 2537 | 2556 |
| 2538 } // namespace dart | 2557 } // namespace dart |
| OLD | NEW |