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 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 getter_function = Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); | 2739 getter_function = Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); |
2740 if (getter_function.IsNull()) { | 2740 if (getter_function.IsNull()) { |
2741 // Resolve and call noSuchMethod. | 2741 // Resolve and call noSuchMethod. |
2742 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); | 2742 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
2743 arguments->Add(node->receiver()); | 2743 arguments->Add(node->receiver()); |
2744 StaticCallInstr* call = | 2744 StaticCallInstr* call = |
2745 BuildStaticNoSuchMethodCall(node->cls(), | 2745 BuildStaticNoSuchMethodCall(node->cls(), |
2746 node->receiver(), | 2746 node->receiver(), |
2747 getter_name, | 2747 getter_name, |
2748 arguments, | 2748 arguments, |
2749 false); // Don't save last argument. | 2749 false, // Don't save last argument. |
| 2750 true); // Super invocation. |
2750 ReturnDefinition(call); | 2751 ReturnDefinition(call); |
2751 return; | 2752 return; |
2752 } else { | 2753 } else { |
2753 ValueGraphVisitor receiver_value(owner(), temp_index()); | 2754 ValueGraphVisitor receiver_value(owner(), temp_index()); |
2754 node->receiver()->Visit(&receiver_value); | 2755 node->receiver()->Visit(&receiver_value); |
2755 Append(receiver_value); | 2756 Append(receiver_value); |
2756 arguments->Add(PushArgument(receiver_value.value())); | 2757 arguments->Add(PushArgument(receiver_value.value())); |
2757 } | 2758 } |
2758 } else { | 2759 } else { |
2759 getter_function = node->cls().LookupStaticFunction(getter_name); | 2760 getter_function = node->cls().LookupStaticFunction(getter_name); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 ASSERT(node->receiver() != NULL); | 2818 ASSERT(node->receiver() != NULL); |
2818 // Resolve and call noSuchMethod. | 2819 // Resolve and call noSuchMethod. |
2819 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); | 2820 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
2820 arguments->Add(node->receiver()); | 2821 arguments->Add(node->receiver()); |
2821 arguments->Add(node->value()); | 2822 arguments->Add(node->value()); |
2822 call = BuildStaticNoSuchMethodCall( | 2823 call = BuildStaticNoSuchMethodCall( |
2823 node->cls(), | 2824 node->cls(), |
2824 node->receiver(), | 2825 node->receiver(), |
2825 setter_name, | 2826 setter_name, |
2826 arguments, | 2827 arguments, |
2827 result_is_needed); // Save last arg if result is needed. | 2828 result_is_needed, // Save last arg if result is needed. |
| 2829 true); // Super invocation. |
2828 } else { | 2830 } else { |
2829 // Throw a NoSuchMethodError. | 2831 // Throw a NoSuchMethodError. |
2830 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); | 2832 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
2831 arguments->Add(node->value()); | 2833 arguments->Add(node->value()); |
2832 call = BuildThrowNoSuchMethodError( | 2834 call = BuildThrowNoSuchMethodError( |
2833 node->token_pos(), | 2835 node->token_pos(), |
2834 node->cls(), | 2836 node->cls(), |
2835 setter_name, | 2837 setter_name, |
2836 arguments, // Argument is the value passed to the setter. | 2838 arguments, // Argument is the value passed to the setter. |
2837 InvocationMirror::EncodeType( | 2839 InvocationMirror::EncodeType( |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 // Could not resolve super operator. Generate call noSuchMethod() of the | 3175 // Could not resolve super operator. Generate call noSuchMethod() of the |
3174 // super class instead. | 3176 // super class instead. |
3175 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); | 3177 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
3176 arguments->Add(node->array()); | 3178 arguments->Add(node->array()); |
3177 arguments->Add(node->index_expr()); | 3179 arguments->Add(node->index_expr()); |
3178 StaticCallInstr* call = | 3180 StaticCallInstr* call = |
3179 BuildStaticNoSuchMethodCall(node->super_class(), | 3181 BuildStaticNoSuchMethodCall(node->super_class(), |
3180 node->array(), | 3182 node->array(), |
3181 Symbols::IndexToken(), | 3183 Symbols::IndexToken(), |
3182 arguments, | 3184 arguments, |
3183 false); // Don't save last arg. | 3185 false, // Don't save last arg. |
| 3186 true); // Super invocation. |
3184 ReturnDefinition(call); | 3187 ReturnDefinition(call); |
3185 return; | 3188 return; |
3186 } | 3189 } |
3187 } | 3190 } |
3188 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 3191 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
3189 new ZoneGrowableArray<PushArgumentInstr*>(2); | 3192 new ZoneGrowableArray<PushArgumentInstr*>(2); |
3190 ValueGraphVisitor for_array(owner(), temp_index()); | 3193 ValueGraphVisitor for_array(owner(), temp_index()); |
3191 node->array()->Visit(&for_array); | 3194 node->array()->Visit(&for_array); |
3192 Append(for_array); | 3195 Append(for_array); |
3193 arguments->Add(PushArgument(for_array.value())); | 3196 arguments->Add(PushArgument(for_array.value())); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 // super class instead. | 3237 // super class instead. |
3235 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); | 3238 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); |
3236 arguments->Add(node->array()); | 3239 arguments->Add(node->array()); |
3237 arguments->Add(node->index_expr()); | 3240 arguments->Add(node->index_expr()); |
3238 arguments->Add(node->value()); | 3241 arguments->Add(node->value()); |
3239 StaticCallInstr* call = BuildStaticNoSuchMethodCall( | 3242 StaticCallInstr* call = BuildStaticNoSuchMethodCall( |
3240 node->super_class(), | 3243 node->super_class(), |
3241 node->array(), | 3244 node->array(), |
3242 Symbols::AssignIndexToken(), | 3245 Symbols::AssignIndexToken(), |
3243 arguments, | 3246 arguments, |
3244 result_is_needed); // Save last arg if result is needed. | 3247 result_is_needed, // Save last arg if result is needed. |
| 3248 true); // Super invocation. |
3245 if (result_is_needed) { | 3249 if (result_is_needed) { |
3246 Do(call); | 3250 Do(call); |
3247 // BuildStaticNoSuchMethodCall stores the value in expression_temp. | 3251 // BuildStaticNoSuchMethodCall stores the value in expression_temp. |
3248 return BuildLoadExprTemp(); | 3252 return BuildLoadExprTemp(); |
3249 } else { | 3253 } else { |
3250 return call; | 3254 return call; |
3251 } | 3255 } |
3252 } | 3256 } |
3253 } | 3257 } |
3254 | 3258 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3615 } | 3619 } |
3616 | 3620 |
3617 | 3621 |
3618 // Looks up dynamic method noSuchMethod in target_class | 3622 // Looks up dynamic method noSuchMethod in target_class |
3619 // (including its super class chain) and builds a static call to it. | 3623 // (including its super class chain) and builds a static call to it. |
3620 StaticCallInstr* EffectGraphVisitor::BuildStaticNoSuchMethodCall( | 3624 StaticCallInstr* EffectGraphVisitor::BuildStaticNoSuchMethodCall( |
3621 const Class& target_class, | 3625 const Class& target_class, |
3622 AstNode* receiver, | 3626 AstNode* receiver, |
3623 const String& method_name, | 3627 const String& method_name, |
3624 ArgumentListNode* method_arguments, | 3628 ArgumentListNode* method_arguments, |
3625 bool save_last_arg) { | 3629 bool save_last_arg, |
| 3630 bool is_super_invocation) { |
3626 intptr_t args_pos = method_arguments->token_pos(); | 3631 intptr_t args_pos = method_arguments->token_pos(); |
3627 LocalVariable* temp = NULL; | 3632 LocalVariable* temp = NULL; |
3628 if (save_last_arg) { | 3633 if (save_last_arg) { |
3629 temp = owner()->parsed_function()->EnsureExpressionTemp(); | 3634 temp = owner()->parsed_function()->EnsureExpressionTemp(); |
3630 } | 3635 } |
3631 ArgumentListNode* args = | 3636 ArgumentListNode* args = |
3632 Parser::BuildNoSuchMethodArguments(args_pos, | 3637 Parser::BuildNoSuchMethodArguments(args_pos, |
3633 method_name, | 3638 method_name, |
3634 *method_arguments, | 3639 *method_arguments, |
3635 temp); | 3640 temp, |
| 3641 is_super_invocation); |
3636 const Function& no_such_method_func = Function::ZoneHandle( | 3642 const Function& no_such_method_func = Function::ZoneHandle( |
3637 Resolver::ResolveDynamicAnyArgs(target_class, Symbols::NoSuchMethod())); | 3643 Resolver::ResolveDynamicAnyArgs(target_class, Symbols::NoSuchMethod())); |
3638 // We are guaranteed to find noSuchMethod of class Object. | 3644 // We are guaranteed to find noSuchMethod of class Object. |
3639 ASSERT(!no_such_method_func.IsNull()); | 3645 ASSERT(!no_such_method_func.IsNull()); |
3640 ZoneGrowableArray<PushArgumentInstr*>* push_arguments = | 3646 ZoneGrowableArray<PushArgumentInstr*>* push_arguments = |
3641 new ZoneGrowableArray<PushArgumentInstr*>(2); | 3647 new ZoneGrowableArray<PushArgumentInstr*>(2); |
3642 BuildPushArguments(*args, push_arguments); | 3648 BuildPushArguments(*args, push_arguments); |
3643 return new StaticCallInstr(args_pos, | 3649 return new StaticCallInstr(args_pos, |
3644 no_such_method_func, | 3650 no_such_method_func, |
3645 Object::null_array(), | 3651 Object::null_array(), |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3843 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3849 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
3844 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3850 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
3845 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3851 OS::SNPrint(chars, len, kFormat, function_name, reason); |
3846 const Error& error = Error::Handle( | 3852 const Error& error = Error::Handle( |
3847 LanguageError::New(String::Handle(String::New(chars)))); | 3853 LanguageError::New(String::Handle(String::New(chars)))); |
3848 Isolate::Current()->long_jump_base()->Jump(1, error); | 3854 Isolate::Current()->long_jump_base()->Jump(1, error); |
3849 } | 3855 } |
3850 | 3856 |
3851 | 3857 |
3852 } // namespace dart | 3858 } // namespace dart |
OLD | NEW |