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

Unified Diff: runtime/vm/object.cc

Issue 11564029: Implement Function.apply in vm (issue 5670). (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/vm/object.h ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 16173)
+++ runtime/vm/object.cc (working copy)
@@ -8507,6 +8507,37 @@
}
+bool Instance::IsCallable(Function* function, Context* context) const {
+ Class& cls = Class::Handle(clazz());
+ if (cls.IsSignatureClass()) {
+ if (function != NULL) {
+ *function = Closure::function(*this);
+ }
+ if (context != NULL) {
+ *context = Closure::context(*this);
+ }
+ return true;
+ }
+ // Try to resolve a "call" method.
+ const String& call_symbol = String::Handle(Symbols::Call());
+ Function& call_function = Function::Handle();
+ do {
+ call_function = cls.LookupDynamicFunction(call_symbol);
+ if (!call_function.IsNull()) {
+ if (function != NULL) {
+ *function = call_function.raw();
+ }
+ if (context != NULL) {
+ *context = Isolate::Current()->object_store()->empty_context();
+ }
+ return true;
+ }
+ cls = cls.SuperClass();
+ } while (!cls.IsNull());
+ return false;
+}
+
+
RawInstance* Instance::New(const Class& cls, Heap::Space space) {
Instance& result = Instance::Handle();
{
« no previous file with comments | « runtime/vm/object.h ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698