| Index: runtime/lib/function.cc
|
| ===================================================================
|
| --- runtime/lib/function.cc (revision 25920)
|
| +++ runtime/lib/function.cc (working copy)
|
| @@ -27,4 +27,35 @@
|
| return result.raw();
|
| }
|
|
|
| +
|
| +DEFINE_NATIVE_ENTRY(Closure_comparison, 2) {
|
| + GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0));
|
| + GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1));
|
| + if (a.raw() == b.raw()) return Bool::True().raw();
|
| + if (a.IsClosure() && b.IsClosure()) {
|
| + const Function& func_a = Function::Handle(Closure::function(a));
|
| + const Function& func_b = Function::Handle(Closure::function(b));
|
| + if (func_a.raw() == func_b.raw()) {
|
| + const Context& context_a = Context::Handle(Closure::context(a));
|
| + const Context& context_b = Context::Handle(Closure::context(b));
|
| + 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(Closure_hashCode, 1) {
|
| + GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0));
|
| + if (a.IsClosure()) {
|
| + const Function& func = Function::Handle(Closure::function(a));
|
| + intptr_t result = String::Handle(func.name()).Hash();
|
| + // TODO(fschneider): Also use receiver for hash.
|
| + return Smi::New(result);
|
| + }
|
| + return Object::null();
|
| +}
|
| +
|
| } // namespace dart
|
|
|