Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 23482004: Evaluates arguments before throwing a NoSuchMethodError in constructor (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 arguments->Add(node->receiver()); 2790 arguments->Add(node->receiver());
2791 arguments->Add(node->value()); 2791 arguments->Add(node->value());
2792 call = BuildStaticNoSuchMethodCall( 2792 call = BuildStaticNoSuchMethodCall(
2793 node->cls(), 2793 node->cls(),
2794 node->receiver(), 2794 node->receiver(),
2795 setter_name, 2795 setter_name,
2796 arguments, 2796 arguments,
2797 result_is_needed); // Save last arg if result is needed. 2797 result_is_needed); // Save last arg if result is needed.
2798 } else { 2798 } else {
2799 // Throw a NoSuchMethodError. 2799 // Throw a NoSuchMethodError.
2800 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos());
2801 arguments->Add(node->value());
2800 call = BuildThrowNoSuchMethodError( 2802 call = BuildThrowNoSuchMethodError(
2801 node->token_pos(), 2803 node->token_pos(),
2802 node->cls(), 2804 node->cls(),
2803 setter_name, 2805 setter_name,
2806 arguments,
2804 InvocationMirror::EncodeType( 2807 InvocationMirror::EncodeType(
2805 node->cls().IsTopLevel() ? 2808 node->cls().IsTopLevel() ?
2806 InvocationMirror::kTopLevel : 2809 InvocationMirror::kTopLevel :
2807 InvocationMirror::kStatic, 2810 InvocationMirror::kStatic,
2808 InvocationMirror::kGetter)); 2811 InvocationMirror::kGetter));
2809 } 2812 }
2810 } else { 2813 } else {
2811 if (is_super_setter) { 2814 if (is_super_setter) {
2812 // Add receiver of instance getter. 2815 // Add receiver of instance getter.
2813 ValueGraphVisitor for_receiver(owner(), temp_index()); 2816 ValueGraphVisitor for_receiver(owner(), temp_index());
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 Object::null_array(), 3562 Object::null_array(),
3560 push_arguments, 3563 push_arguments,
3561 owner()->ic_data_array()); 3564 owner()->ic_data_array());
3562 } 3565 }
3563 3566
3564 3567
3565 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( 3568 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
3566 intptr_t token_pos, 3569 intptr_t token_pos,
3567 const Class& function_class, 3570 const Class& function_class,
3568 const String& function_name, 3571 const String& function_name,
3572 ArgumentListNode* actuals,
regis 2013/08/28 21:10:54 function_arguments
zra 2013/08/28 22:47:00 Done.
3569 int invocation_type) { 3573 int invocation_type) {
3570 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3574 ZoneGrowableArray<PushArgumentInstr*>* arguments =
3571 new ZoneGrowableArray<PushArgumentInstr*>(); 3575 new ZoneGrowableArray<PushArgumentInstr*>();
3572 // Object receiver. 3576 // Object receiver.
3573 // TODO(regis): For now, we pass a class literal of the unresolved 3577 // 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. 3578 // method's owner, but this is not specified and will probably change.
3575 Type& type = Type::ZoneHandle( 3579 Type& type = Type::ZoneHandle(
3576 Type::New(function_class, 3580 Type::New(function_class,
3577 TypeArguments::Handle(), 3581 TypeArguments::Handle(),
3578 token_pos, 3582 token_pos,
3579 Heap::kOld)); 3583 Heap::kOld));
3580 type ^= ClassFinalizer::FinalizeType( 3584 type ^= ClassFinalizer::FinalizeType(
3581 function_class, type, ClassFinalizer::kCanonicalize); 3585 function_class, type, ClassFinalizer::kCanonicalize);
3582 Value* receiver_value = Bind(new ConstantInstr(type)); 3586 Value* receiver_value = Bind(new ConstantInstr(type));
3583 arguments->Add(PushArgument(receiver_value)); 3587 arguments->Add(PushArgument(receiver_value));
3584 // String memberName. 3588 // String memberName.
3585 const String& member_name = String::ZoneHandle(Symbols::New(function_name)); 3589 const String& member_name = String::ZoneHandle(Symbols::New(function_name));
3586 Value* member_name_value = Bind(new ConstantInstr(member_name)); 3590 Value* member_name_value = Bind(new ConstantInstr(member_name));
3587 arguments->Add(PushArgument(member_name_value)); 3591 arguments->Add(PushArgument(member_name_value));
3588 // Smi invocation_type. 3592 // Smi invocation_type.
3589 Value* invocation_type_value = Bind(new ConstantInstr( 3593 Value* invocation_type_value = Bind(new ConstantInstr(
3590 Smi::ZoneHandle(Smi::New(invocation_type)))); 3594 Smi::ZoneHandle(Smi::New(invocation_type))));
3591 arguments->Add(PushArgument(invocation_type_value)); 3595 arguments->Add(PushArgument(invocation_type_value));
3592 // List arguments. 3596 // List arguments.
3593 // TODO(regis): Pass arguments. 3597 if (actuals == NULL) {
3594 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle())); 3598 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle()));
3595 arguments->Add(PushArgument(arguments_value)); 3599 arguments->Add(PushArgument(arguments_value));
3600 } else {
3601 ValueGraphVisitor array_val(owner(), temp_index());
3602 ArrayNode* array = new ArrayNode(
3603 token_pos, Type::ZoneHandle(Type::ArrayType()), actuals->nodes());
3604 array->Visit(&array_val);
3605 Append(array_val);
3606 arguments->Add(PushArgument(array_val.value()));
3607 }
3596 // List argumentNames. 3608 // List argumentNames.
3597 Value* argument_names_value = 3609 if (actuals == NULL) {
3598 Bind(new ConstantInstr(Array::ZoneHandle())); 3610 Value* argument_names_value = Bind(new ConstantInstr(Array::ZoneHandle()));
3599 arguments->Add(PushArgument(argument_names_value)); 3611 arguments->Add(PushArgument(argument_names_value));
3612 } else {
3613 Value* argument_names_value = Bind(new ConstantInstr(actuals->names()));
3614 arguments->Add(PushArgument(argument_names_value));
3615 }
srdjan 2013/08/28 21:43:15 The code above could be: ConstantInstr* cinstr = n
zra 2013/08/28 22:47:00 Done.
3600 // List existingArgumentNames. 3616 // List existingArgumentNames.
3601 Value* existing_argument_names_value = 3617 Value* existing_argument_names_value =
3602 Bind(new ConstantInstr(Array::ZoneHandle())); 3618 Bind(new ConstantInstr(Array::ZoneHandle()));
3603 arguments->Add(PushArgument(existing_argument_names_value)); 3619 arguments->Add(PushArgument(existing_argument_names_value));
3604 // Resolve and call NoSuchMethodError._throwNew. 3620 // Resolve and call NoSuchMethodError._throwNew.
3605 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 3621 const Library& core_lib = Library::Handle(Library::CoreLibrary());
3606 const Class& cls = Class::Handle( 3622 const Class& cls = Class::Handle(
3607 core_lib.LookupClass(Symbols::NoSuchMethodError(), NULL)); 3623 core_lib.LookupClass(Symbols::NoSuchMethodError(), NULL));
3608 ASSERT(!cls.IsNull()); 3624 ASSERT(!cls.IsNull());
3609 const Function& func = Function::ZoneHandle( 3625 const Function& func = Function::ZoneHandle(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3744 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3760 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3745 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3761 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3746 OS::SNPrint(chars, len, kFormat, function_name, reason); 3762 OS::SNPrint(chars, len, kFormat, function_name, reason);
3747 const Error& error = Error::Handle( 3763 const Error& error = Error::Handle(
3748 LanguageError::New(String::Handle(String::New(chars)))); 3764 LanguageError::New(String::Handle(String::New(chars))));
3749 Isolate::Current()->long_jump_base()->Jump(1, error); 3765 Isolate::Current()->long_jump_base()->Jump(1, error);
3750 } 3766 }
3751 3767
3752 3768
3753 } // namespace dart 3769 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698