OLD | NEW |
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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 if ((receiver_a.raw() == receiver_b.raw()) && | 61 if ((receiver_a.raw() == receiver_b.raw()) && |
62 (func_a.name() == func_b.name()) && | 62 (func_a.name() == func_b.name()) && |
63 (func_a.Owner() == func_b.Owner())) { | 63 (func_a.Owner() == func_b.Owner())) { |
64 return Bool::True().raw(); | 64 return Bool::True().raw(); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 return Bool::False().raw(); | 68 return Bool::False().raw(); |
69 } | 69 } |
70 | 70 |
71 DEFINE_NATIVE_ENTRY(Closure_computeHash, 1) { | 71 DEFINE_NATIVE_ENTRY(Closure_hashCode, 1) { |
72 const Closure& receiver = | 72 const Closure& receiver = |
73 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); | 73 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); |
74 return Smi::New(receiver.ComputeHash()); | 74 const Function& func = Function::Handle(zone, receiver.function()); |
| 75 return func.GetClosureHashCode(); |
75 } | 76 } |
76 | 77 |
77 DEFINE_NATIVE_ENTRY(Closure_clone, 1) { | 78 DEFINE_NATIVE_ENTRY(Closure_clone, 1) { |
78 const Closure& receiver = | 79 const Closure& receiver = |
79 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); | 80 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); |
80 const TypeArguments& instantiator_type_arguments = | 81 const TypeArguments& instantiator_type_arguments = |
81 TypeArguments::Handle(zone, receiver.instantiator_type_arguments()); | 82 TypeArguments::Handle(zone, receiver.instantiator_type_arguments()); |
82 const TypeArguments& function_type_arguments = | 83 const TypeArguments& function_type_arguments = |
83 TypeArguments::Handle(zone, receiver.function_type_arguments()); | 84 TypeArguments::Handle(zone, receiver.function_type_arguments()); |
84 const Function& function = Function::Handle(zone, receiver.function()); | 85 const Function& function = Function::Handle(zone, receiver.function()); |
85 const Context& context = Context::Handle(zone, receiver.context()); | 86 const Context& context = Context::Handle(zone, receiver.context()); |
86 Context& cloned_context = | 87 Context& cloned_context = |
87 Context::Handle(zone, Context::New(context.num_variables())); | 88 Context::Handle(zone, Context::New(context.num_variables())); |
88 cloned_context.set_parent(Context::Handle(zone, context.parent())); | 89 cloned_context.set_parent(Context::Handle(zone, context.parent())); |
89 Object& instance = Object::Handle(zone); | 90 Object& instance = Object::Handle(zone); |
90 for (int i = 0; i < context.num_variables(); i++) { | 91 for (int i = 0; i < context.num_variables(); i++) { |
91 instance = context.At(i); | 92 instance = context.At(i); |
92 cloned_context.SetAt(i, instance); | 93 cloned_context.SetAt(i, instance); |
93 } | 94 } |
94 return Closure::New(instantiator_type_arguments, function_type_arguments, | 95 return Closure::New(instantiator_type_arguments, function_type_arguments, |
95 function, cloned_context); | 96 function, cloned_context); |
96 } | 97 } |
97 | 98 |
98 } // namespace dart | 99 } // namespace dart |
OLD | NEW |