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

Unified Diff: runtime/vm/code_generator.cc

Issue 11612002: Invoke noSuchMethod instead of immediately throwing NoSuchMethodError when (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/invocation_mirror_patch.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 16218)
+++ runtime/vm/code_generator.cc (working copy)
@@ -1139,6 +1139,55 @@
}
+static RawObject* InvokeNoSuchMethod(const Instance& receiver,
+ const String& target_name,
+ const Array& arguments_descriptor,
+ const Array& arguments) {
+ // Allocate an InvocationMirror object.
+ const Library& core_lib = Library::Handle(Library::CoreLibrary());
+ const String& invocation_mirror_name =
+ String::Handle(Symbols::InvocationMirror());
+ Class& invocation_mirror_class =
+ Class::Handle(core_lib.LookupClassAllowPrivate(invocation_mirror_name));
+ ASSERT(!invocation_mirror_class.IsNull());
+ const String& allocation_function_name =
+ String::Handle(Symbols::AllocateInvocationMirror());
+ const Function& allocation_function = Function::Handle(
+ Resolver::ResolveStaticByName(invocation_mirror_class,
+ allocation_function_name,
+ Resolver::kIsQualified));
+ ASSERT(!allocation_function.IsNull());
+ GrowableArray<const Object*> allocation_arguments(3);
+ allocation_arguments.Add(&target_name);
+ allocation_arguments.Add(&arguments_descriptor);
+ allocation_arguments.Add(&arguments);
+ const Array& kNoArgumentNames = Array::Handle();
+ const Object& invocation_mirror =
+ Object::Handle(DartEntry::InvokeStatic(allocation_function,
+ allocation_arguments,
+ kNoArgumentNames));
+
+ const String& function_name = String::Handle(Symbols::NoSuchMethod());
+ const int kNumArguments = 2;
+ const int kNumNamedArguments = 0;
+ const Function& function = Function::Handle(
+ Resolver::ResolveDynamic(receiver,
+ function_name,
+ kNumArguments,
+ kNumNamedArguments));
+ ASSERT(!function.IsNull());
+ GrowableArray<const Object*> invoke_arguments(1);
+ invoke_arguments.Add(&invocation_mirror);
+ const Object& result =
+ Object::Handle(DartEntry::InvokeDynamic(receiver,
+ function,
+ invoke_arguments,
+ kNoArgumentNames));
+ CheckResultError(result);
+ return result.raw();
+}
+
+
static RawObject* InvokeClosure(const Instance& closure,
const Array& arguments_descriptor,
const Array& arguments) {
@@ -1211,17 +1260,11 @@
current_class = current_class.SuperClass();
} while (!current_class.IsNull());
- const Object& null_object = Object::Handle();
- GrowableArray<const Object*> dart_arguments(5);
- dart_arguments.Add(&receiver);
- dart_arguments.Add(&call_symbol);
- dart_arguments.Add(&arguments);
- dart_arguments.Add(&null_object); // TODO(regis): Provide names.
- // If a function "call" with different arguments exists, it will have been
- // invoked above, so no need to handle this case here.
- Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments);
- UNREACHABLE();
- return Object::null();
+ // There is no 'call' method, so invoke noSuchMethod.
+ return InvokeNoSuchMethod(receiver,
+ call_symbol,
+ arguments_descriptor,
+ arguments);
}
@@ -1282,55 +1325,6 @@
}
-static RawObject* InvokeNoSuchMethod(const Instance& receiver,
- const String& target_name,
- const Array& arguments_descriptor,
- const Array& arguments) {
- // Allocate an InvocationMirror object.
- const Library& core_lib = Library::Handle(Library::CoreLibrary());
- const String& invocation_mirror_name =
- String::Handle(Symbols::InvocationMirror());
- Class& invocation_mirror_class =
- Class::Handle(core_lib.LookupClassAllowPrivate(invocation_mirror_name));
- ASSERT(!invocation_mirror_class.IsNull());
- const String& allocation_function_name =
- String::Handle(Symbols::AllocateInvocationMirror());
- const Function& allocation_function = Function::Handle(
- Resolver::ResolveStaticByName(invocation_mirror_class,
- allocation_function_name,
- Resolver::kIsQualified));
- ASSERT(!allocation_function.IsNull());
- GrowableArray<const Object*> allocation_arguments(3);
- allocation_arguments.Add(&target_name);
- allocation_arguments.Add(&arguments_descriptor);
- allocation_arguments.Add(&arguments);
- const Array& kNoArgumentNames = Array::Handle();
- const Object& invocation_mirror =
- Object::Handle(DartEntry::InvokeStatic(allocation_function,
- allocation_arguments,
- kNoArgumentNames));
-
- const String& function_name = String::Handle(Symbols::NoSuchMethod());
- const int kNumArguments = 2;
- const int kNumNamedArguments = 0;
- const Function& function = Function::Handle(
- Resolver::ResolveDynamic(receiver,
- function_name,
- kNumArguments,
- kNumNamedArguments));
- ASSERT(!function.IsNull());
- GrowableArray<const Object*> invoke_arguments(1);
- invoke_arguments.Add(&invocation_mirror);
- const Object& result =
- Object::Handle(DartEntry::InvokeDynamic(receiver,
- function,
- invoke_arguments,
- kNoArgumentNames));
- CheckResultError(result);
- return result.raw();
-}
-
-
// Invoke appropriate noSuchMethod function.
// Arg0: receiver.
// Arg1: ic-data.
« no previous file with comments | « runtime/lib/invocation_mirror_patch.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698