Chromium Code Reviews| Index: runtime/vm/object.cc |
| =================================================================== |
| --- runtime/vm/object.cc (revision 25920) |
| +++ runtime/vm/object.cc (working copy) |
| @@ -1847,9 +1847,9 @@ |
| invocation.SetNumOptionalParameters(desc.NamedCount(), |
| false); // Not positional. |
| invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), |
| - Heap::kOld))); |
| + Heap::kOld))); |
| invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), |
| - Heap::kOld))); |
| + Heap::kOld))); |
| // Receiver. |
| invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); |
| invocation.SetParameterNameAt(0, Symbols::This()); |
| @@ -4622,6 +4622,63 @@ |
| } |
| +static RawFunction* CreateClosureEqualsFunction(const Class& owner) { |
| + Function& result = Function::Handle( |
| + Function::New(Symbols::EqualOperator(), |
| + RawFunction::kRegularFunction, |
| + false, // Not static. |
| + false, // Not const. |
| + false, // Not abstract. |
| + false, // Not external. |
| + owner, |
| + 0)); // No token position. |
| + const intptr_t num_args = 2; |
| + result.set_num_fixed_parameters(num_args); |
| + result.SetNumOptionalParameters(0, |
| + false); // Not positional. |
| + result.set_parameter_types(Array::Handle(Array::New(num_args, |
| + Heap::kOld))); |
| + result.set_parameter_names(Array::Handle(Array::New(num_args, |
| + Heap::kOld))); |
| + // Receiver. |
| + result.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); |
| + result.SetParameterNameAt(0, Symbols::This()); |
| + // Other. |
| + result.SetParameterTypeAt(1, Type::Handle(Type::DynamicType())); |
| + result.SetParameterNameAt(1, String::Handle(Symbols::New("other"))); |
| + |
| + result.set_result_type(Type::Handle(Type::BoolType())); |
| + return result.raw(); |
| +} |
| + |
| + |
| +static RawFunction* CreateClosureHashCodeFunction(const Class& owner) { |
| + Function& result = Function::Handle( |
| + Function::New(Symbols::HashCode(), |
| + RawFunction::kGetterFunction, |
| + false, // Not static. |
| + false, // Not const. |
| + false, // Not abstract. |
| + false, // Not external. |
| + owner, |
| + 0)); // No token position. |
| + const intptr_t num_args = 1; |
| + result.set_num_fixed_parameters(num_args); |
| + result.SetNumOptionalParameters(0, |
| + false); // Not positional. |
| + result.set_parameter_types(Array::Handle(Array::New(num_args, |
| + Heap::kOld))); |
| + result.set_parameter_names(Array::Handle(Array::New(num_args, |
| + Heap::kOld))); |
| + // Receiver. |
| + result.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); |
| + result.SetParameterNameAt(0, Symbols::This()); |
| + |
| + result.set_result_type(Type::Handle(Type::IntType())); |
| + return result.raw(); |
| +} |
| + |
| + |
| RawFunction* Function::ImplicitClosureFunction() const { |
| // Return the existing implicit closure function if any. |
| if (implicit_closure_function() != Function::null()) { |
| @@ -4691,6 +4748,15 @@ |
| closure_function, |
| script, |
| closure_function.token_pos()); |
| + // Add == function to implicit instance closures. |
|
Ivan Posva
2013/08/09 21:24:30
This will not work because f, g and h in the examp
Florian Schneider
2013/08/12 09:32:12
Done. You're right. I'll make sure that == and has
|
| + if (!closure_function.is_static()) { |
| + const Function& equals_function = |
| + Function::Handle(CreateClosureEqualsFunction(signature_class)); |
| + signature_class.AddFunction(equals_function); |
| + const Function& hash_code_function = |
| + Function::Handle(CreateClosureHashCodeFunction(signature_class)); |
| + signature_class.AddFunction(hash_code_function); |
| + } |
| library.AddClass(signature_class); |
| } else { |
| closure_function.set_signature_class(signature_class); |