| 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/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 Value** instantiator_type_arguments_result) { | 587 Value** instantiator_type_arguments_result) { |
| 588 Value* instantiator = NULL; | 588 Value* instantiator = NULL; |
| 589 Value* instantiator_type_arguments = NULL; | 589 Value* instantiator_type_arguments = NULL; |
| 590 const Class& instantiator_class = Class::Handle( | 590 const Class& instantiator_class = Class::Handle( |
| 591 owner()->parsed_function().function().owner()); | 591 owner()->parsed_function().function().owner()); |
| 592 // Since called only when type tested against is not instantiated. | 592 // Since called only when type tested against is not instantiated. |
| 593 ASSERT(instantiator_class.NumTypeParameters() > 0); | 593 ASSERT(instantiator_class.NumTypeParameters() > 0); |
| 594 instantiator = BuildInstantiator(); | 594 instantiator = BuildInstantiator(); |
| 595 if (instantiator == NULL) { | 595 if (instantiator == NULL) { |
| 596 // No instantiator when inside factory. | 596 // No instantiator when inside factory. |
| 597 instantiator = BuildNullValue(); |
| 597 instantiator_type_arguments = | 598 instantiator_type_arguments = |
| 598 BuildInstantiatorTypeArguments(token_index, NULL); | 599 BuildInstantiatorTypeArguments(token_index, NULL); |
| 599 } else { | 600 } else { |
| 600 // Preserve instantiator. | 601 // Preserve instantiator. |
| 601 const LocalVariable& expr_temp = | 602 const LocalVariable& expr_temp = |
| 602 *owner()->parsed_function().expression_temp_var(); | 603 *owner()->parsed_function().expression_temp_var(); |
| 603 BindInstr* saved = | 604 BindInstr* saved = |
| 604 new BindInstr(BuildStoreLocal(expr_temp, instantiator)); | 605 new BindInstr(BuildStoreLocal(expr_temp, instantiator)); |
| 605 AddInstruction(saved); | 606 AddInstruction(saved); |
| 606 instantiator = new UseVal(saved); | 607 instantiator = new UseVal(saved); |
| 607 BindInstr* loaded = new BindInstr(BuildLoadLocal(expr_temp)); | 608 BindInstr* loaded = new BindInstr(BuildLoadLocal(expr_temp)); |
| 608 AddInstruction(loaded); | 609 AddInstruction(loaded); |
| 609 instantiator_type_arguments = | 610 instantiator_type_arguments = |
| 610 BuildInstantiatorTypeArguments(token_index, new UseVal(loaded)); | 611 BuildInstantiatorTypeArguments(token_index, new UseVal(loaded)); |
| 611 } | 612 } |
| 612 *instantiator_result = instantiator; | 613 *instantiator_result = instantiator; |
| 613 *instantiator_type_arguments_result = instantiator_type_arguments; | 614 *instantiator_type_arguments_result = instantiator_type_arguments; |
| 614 } | 615 } |
| 615 | 616 |
| 616 | 617 |
| 618 Value* EffectGraphVisitor::BuildNullValue() { |
| 619 BindInstr* instr = new BindInstr(new ConstantVal(Object::ZoneHandle())); |
| 620 AddInstruction(instr); |
| 621 return new UseVal(instr); |
| 622 } |
| 623 |
| 624 |
| 617 // Used for testing incoming arguments. | 625 // Used for testing incoming arguments. |
| 618 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable( | 626 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable( |
| 619 intptr_t token_index, | 627 intptr_t token_index, |
| 620 Value* value, | 628 Value* value, |
| 621 const AbstractType& dst_type, | 629 const AbstractType& dst_type, |
| 622 const String& dst_name) { | 630 const String& dst_name) { |
| 623 // Build the type check computation. | 631 // Build the type check computation. |
| 624 Value* instantiator = NULL; | 632 Value* instantiator = NULL; |
| 625 Value* instantiator_type_arguments = NULL; | 633 Value* instantiator_type_arguments = NULL; |
| 626 if (!dst_type.IsInstantiated()) { | 634 if (dst_type.IsInstantiated()) { |
| 635 instantiator = BuildNullValue(); |
| 636 instantiator_type_arguments = BuildNullValue(); |
| 637 } else { |
| 627 BuildTypecheckArguments(token_index, | 638 BuildTypecheckArguments(token_index, |
| 628 &instantiator, | 639 &instantiator, |
| 629 &instantiator_type_arguments); | 640 &instantiator_type_arguments); |
| 630 } | 641 } |
| 631 return new AssertAssignableComp(token_index, | 642 return new AssertAssignableComp(token_index, |
| 632 owner()->try_index(), | 643 owner()->try_index(), |
| 633 value, | 644 value, |
| 634 instantiator, | 645 instantiator, |
| 635 instantiator_type_arguments, | 646 instantiator_type_arguments, |
| 636 dst_type, | 647 dst_type, |
| (...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 char* chars = reinterpret_cast<char*>( | 2406 char* chars = reinterpret_cast<char*>( |
| 2396 Isolate::Current()->current_zone()->Allocate(len)); | 2407 Isolate::Current()->current_zone()->Allocate(len)); |
| 2397 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2408 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2398 const Error& error = Error::Handle( | 2409 const Error& error = Error::Handle( |
| 2399 LanguageError::New(String::Handle(String::New(chars)))); | 2410 LanguageError::New(String::Handle(String::New(chars)))); |
| 2400 Isolate::Current()->long_jump_base()->Jump(1, error); | 2411 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2401 } | 2412 } |
| 2402 | 2413 |
| 2403 | 2414 |
| 2404 } // namespace dart | 2415 } // namespace dart |
| OLD | NEW |