| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 2730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 // However, if the field reference appears in a right hand side | 2741 // However, if the field reference appears in a right hand side |
| 2742 // expression, no such transformation occurs and we land here with a | 2742 // expression, no such transformation occurs and we land here with a |
| 2743 // StaticGetterNode missing a getter function, so we throw a | 2743 // StaticGetterNode missing a getter function, so we throw a |
| 2744 // NoSuchMethodError. | 2744 // NoSuchMethodError. |
| 2745 | 2745 |
| 2746 // Throw a NoSuchMethodError. | 2746 // Throw a NoSuchMethodError. |
| 2747 StaticCallInstr* call = BuildThrowNoSuchMethodError( | 2747 StaticCallInstr* call = BuildThrowNoSuchMethodError( |
| 2748 node->token_pos(), | 2748 node->token_pos(), |
| 2749 node->cls(), | 2749 node->cls(), |
| 2750 getter_name, | 2750 getter_name, |
| 2751 NULL, // No Arguments to getter. |
| 2751 InvocationMirror::EncodeType( | 2752 InvocationMirror::EncodeType( |
| 2752 node->cls().IsTopLevel() ? | 2753 node->cls().IsTopLevel() ? |
| 2753 InvocationMirror::kTopLevel : | 2754 InvocationMirror::kTopLevel : |
| 2754 InvocationMirror::kStatic, | 2755 InvocationMirror::kStatic, |
| 2755 InvocationMirror::kGetter)); | 2756 InvocationMirror::kGetter)); |
| 2756 ReturnDefinition(call); | 2757 ReturnDefinition(call); |
| 2757 return; | 2758 return; |
| 2758 } | 2759 } |
| 2759 } | 2760 } |
| 2760 ASSERT(!getter_function.IsNull()); | 2761 ASSERT(!getter_function.IsNull()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2790 arguments->Add(node->receiver()); | 2791 arguments->Add(node->receiver()); |
| 2791 arguments->Add(node->value()); | 2792 arguments->Add(node->value()); |
| 2792 call = BuildStaticNoSuchMethodCall( | 2793 call = BuildStaticNoSuchMethodCall( |
| 2793 node->cls(), | 2794 node->cls(), |
| 2794 node->receiver(), | 2795 node->receiver(), |
| 2795 setter_name, | 2796 setter_name, |
| 2796 arguments, | 2797 arguments, |
| 2797 result_is_needed); // Save last arg if result is needed. | 2798 result_is_needed); // Save last arg if result is needed. |
| 2798 } else { | 2799 } else { |
| 2799 // Throw a NoSuchMethodError. | 2800 // Throw a NoSuchMethodError. |
| 2801 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
| 2802 arguments->Add(node->value()); |
| 2800 call = BuildThrowNoSuchMethodError( | 2803 call = BuildThrowNoSuchMethodError( |
| 2801 node->token_pos(), | 2804 node->token_pos(), |
| 2802 node->cls(), | 2805 node->cls(), |
| 2803 setter_name, | 2806 setter_name, |
| 2807 arguments, // Argument is the value passed to the setter. |
| 2804 InvocationMirror::EncodeType( | 2808 InvocationMirror::EncodeType( |
| 2805 node->cls().IsTopLevel() ? | 2809 node->cls().IsTopLevel() ? |
| 2806 InvocationMirror::kTopLevel : | 2810 InvocationMirror::kTopLevel : |
| 2807 InvocationMirror::kStatic, | 2811 InvocationMirror::kStatic, |
| 2808 InvocationMirror::kGetter)); | 2812 InvocationMirror::kGetter)); |
| 2809 } | 2813 } |
| 2810 } else { | 2814 } else { |
| 2811 if (is_super_setter) { | 2815 if (is_super_setter) { |
| 2812 // Add receiver of instance getter. | 2816 // Add receiver of instance getter. |
| 2813 ValueGraphVisitor for_receiver(owner(), temp_index()); | 2817 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3559 Object::null_array(), | 3563 Object::null_array(), |
| 3560 push_arguments, | 3564 push_arguments, |
| 3561 owner()->ic_data_array()); | 3565 owner()->ic_data_array()); |
| 3562 } | 3566 } |
| 3563 | 3567 |
| 3564 | 3568 |
| 3565 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( | 3569 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( |
| 3566 intptr_t token_pos, | 3570 intptr_t token_pos, |
| 3567 const Class& function_class, | 3571 const Class& function_class, |
| 3568 const String& function_name, | 3572 const String& function_name, |
| 3573 ArgumentListNode* function_arguments, |
| 3569 int invocation_type) { | 3574 int invocation_type) { |
| 3570 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 3575 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 3571 new ZoneGrowableArray<PushArgumentInstr*>(); | 3576 new ZoneGrowableArray<PushArgumentInstr*>(); |
| 3572 // Object receiver. | 3577 // Object receiver. |
| 3573 // TODO(regis): For now, we pass a class literal of the unresolved | 3578 // TODO(regis): For now, we pass a class literal of the unresolved |
| 3574 // method's owner, but this is not specified and will probably change. | 3579 // method's owner, but this is not specified and will probably change. |
| 3575 Type& type = Type::ZoneHandle( | 3580 Type& type = Type::ZoneHandle( |
| 3576 Type::New(function_class, | 3581 Type::New(function_class, |
| 3577 TypeArguments::Handle(), | 3582 TypeArguments::Handle(), |
| 3578 token_pos, | 3583 token_pos, |
| 3579 Heap::kOld)); | 3584 Heap::kOld)); |
| 3580 type ^= ClassFinalizer::FinalizeType( | 3585 type ^= ClassFinalizer::FinalizeType( |
| 3581 function_class, type, ClassFinalizer::kCanonicalize); | 3586 function_class, type, ClassFinalizer::kCanonicalize); |
| 3582 Value* receiver_value = Bind(new ConstantInstr(type)); | 3587 Value* receiver_value = Bind(new ConstantInstr(type)); |
| 3583 arguments->Add(PushArgument(receiver_value)); | 3588 arguments->Add(PushArgument(receiver_value)); |
| 3584 // String memberName. | 3589 // String memberName. |
| 3585 const String& member_name = String::ZoneHandle(Symbols::New(function_name)); | 3590 const String& member_name = String::ZoneHandle(Symbols::New(function_name)); |
| 3586 Value* member_name_value = Bind(new ConstantInstr(member_name)); | 3591 Value* member_name_value = Bind(new ConstantInstr(member_name)); |
| 3587 arguments->Add(PushArgument(member_name_value)); | 3592 arguments->Add(PushArgument(member_name_value)); |
| 3588 // Smi invocation_type. | 3593 // Smi invocation_type. |
| 3589 Value* invocation_type_value = Bind(new ConstantInstr( | 3594 Value* invocation_type_value = Bind(new ConstantInstr( |
| 3590 Smi::ZoneHandle(Smi::New(invocation_type)))); | 3595 Smi::ZoneHandle(Smi::New(invocation_type)))); |
| 3591 arguments->Add(PushArgument(invocation_type_value)); | 3596 arguments->Add(PushArgument(invocation_type_value)); |
| 3592 // List arguments. | 3597 // List arguments. |
| 3593 // TODO(regis): Pass arguments. | 3598 if (function_arguments == NULL) { |
| 3594 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle())); | 3599 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle())); |
| 3595 arguments->Add(PushArgument(arguments_value)); | 3600 arguments->Add(PushArgument(arguments_value)); |
| 3601 } else { |
| 3602 ValueGraphVisitor array_val(owner(), temp_index()); |
| 3603 ArrayNode* array = |
| 3604 new ArrayNode(token_pos, Type::ZoneHandle(Type::ArrayType()), |
| 3605 function_arguments->nodes()); |
| 3606 array->Visit(&array_val); |
| 3607 Append(array_val); |
| 3608 arguments->Add(PushArgument(array_val.value())); |
| 3609 } |
| 3596 // List argumentNames. | 3610 // List argumentNames. |
| 3597 Value* argument_names_value = | 3611 ConstantInstr* cinstr = new ConstantInstr( |
| 3598 Bind(new ConstantInstr(Array::ZoneHandle())); | 3612 (function_arguments == NULL) ? Array::ZoneHandle() |
| 3613 : function_arguments->names()); |
| 3614 Value* argument_names_value = Bind(cinstr); |
| 3599 arguments->Add(PushArgument(argument_names_value)); | 3615 arguments->Add(PushArgument(argument_names_value)); |
| 3616 |
| 3600 // List existingArgumentNames. | 3617 // List existingArgumentNames. |
| 3601 Value* existing_argument_names_value = | 3618 Value* existing_argument_names_value = |
| 3602 Bind(new ConstantInstr(Array::ZoneHandle())); | 3619 Bind(new ConstantInstr(Array::ZoneHandle())); |
| 3603 arguments->Add(PushArgument(existing_argument_names_value)); | 3620 arguments->Add(PushArgument(existing_argument_names_value)); |
| 3604 // Resolve and call NoSuchMethodError._throwNew. | 3621 // Resolve and call NoSuchMethodError._throwNew. |
| 3605 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 3622 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 3606 const Class& cls = Class::Handle( | 3623 const Class& cls = Class::Handle( |
| 3607 core_lib.LookupClass(Symbols::NoSuchMethodError(), NULL)); | 3624 core_lib.LookupClass(Symbols::NoSuchMethodError(), NULL)); |
| 3608 ASSERT(!cls.IsNull()); | 3625 ASSERT(!cls.IsNull()); |
| 3609 const Function& func = Function::ZoneHandle( | 3626 const Function& func = Function::ZoneHandle( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3744 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3761 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3745 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3762 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3746 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3763 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3747 const Error& error = Error::Handle( | 3764 const Error& error = Error::Handle( |
| 3748 LanguageError::New(String::Handle(String::New(chars)))); | 3765 LanguageError::New(String::Handle(String::New(chars)))); |
| 3749 Isolate::Current()->long_jump_base()->Jump(1, error); | 3766 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3750 } | 3767 } |
| 3751 | 3768 |
| 3752 | 3769 |
| 3753 } // namespace dart | 3770 } // namespace dart |
| OLD | NEW |