Chromium Code Reviews| Index: runtime/lib/function.cc |
| =================================================================== |
| --- runtime/lib/function.cc (revision 26064) |
| +++ runtime/lib/function.cc (working copy) |
| @@ -27,4 +27,41 @@ |
| return result.raw(); |
| } |
| + |
| +DEFINE_NATIVE_ENTRY(Function_equals, 2) { |
|
Ivan Posva
2013/08/13 17:58:49
FunctionImpl_equals
Florian Schneider
2013/08/14 09:07:49
Done.
|
| + const Instance& receiver = Instance::CheckedHandle( |
|
Ivan Posva
2013/08/13 17:58:49
Instance::CheckedHandle should really be a Closure
Florian Schneider
2013/08/14 09:07:49
Ok, I'll make a separate CL.
|
| + isolate, arguments->NativeArgAt(0)); |
| + ASSERT(receiver.IsClosure()); |
| + GET_NATIVE_ARGUMENT(Instance, other, arguments->NativeArgAt(1)); |
| + if (receiver.raw() == other.raw()) return Bool::True().raw(); |
| + if (other.IsClosure()) { |
| + const Function& func_a = Function::Handle(Closure::function(receiver)); |
| + const Function& func_b = Function::Handle(Closure::function(other)); |
| + if (func_a.raw() == func_b.raw()) { |
| + ASSERT(!func_a.IsImplicitStaticClosureFunction()); |
|
Ivan Posva
2013/08/13 17:58:49
Please add a comment why this assertion is here.
Florian Schneider
2013/08/14 09:07:49
Done.
|
| + if (func_a.IsImplicitInstanceClosureFunction()) { |
| + const Context& context_a = Context::Handle(Closure::context(receiver)); |
| + const Context& context_b = Context::Handle(Closure::context(other)); |
| + const Instance& receiver_a = Instance::Handle(context_a.At(0)); |
| + const Instance& receiver_b = Instance::Handle(context_b.At(0)); |
| + if (receiver_a.raw() == receiver_b.raw()) return Bool::True().raw(); |
| + } |
| + } |
| + } |
| + return Bool::False().raw(); |
| +} |
| + |
| + |
| +DEFINE_NATIVE_ENTRY(Function_hashCode, 1) { |
|
Ivan Posva
2013/08/13 17:58:49
ditto
Florian Schneider
2013/08/14 09:07:49
Done.
|
| + const Instance& receiver = Instance::CheckedHandle( |
|
Ivan Posva
2013/08/13 17:58:49
Same here about the Closure::CheckedHandle, which
Florian Schneider
2013/08/14 09:07:49
Will do in a separate CL.
|
| + isolate, arguments->NativeArgAt(0)); |
| + if (receiver.IsClosure()) { |
| + const Function& func = Function::Handle(Closure::function(receiver)); |
| + intptr_t result = String::Handle(func.name()).Hash(); |
|
Ivan Posva
2013/08/13 17:58:49
How about hashing both the function name, the clas
Florian Schneider
2013/08/14 09:07:49
Done.
|
| + return Smi::New(result); |
| + } |
| + UNREACHABLE(); |
| + return Object::null(); |
| +} |
| + |
| } // namespace dart |