Index: vm/parser.cc |
=================================================================== |
--- vm/parser.cc (revision 8699) |
+++ vm/parser.cc (working copy) |
@@ -143,9 +143,11 @@ |
const int fixed_parameter_count = function().num_fixed_parameters(); |
const int optional_parameter_count = function().num_optional_parameters(); |
const int parameter_count = fixed_parameter_count + optional_parameter_count; |
+ const bool is_implicit_native_closure = |
+ function().is_native() && function().IsImplicitClosureFunction(); |
regis
2012/06/15 17:13:34
ditto
siva
2012/06/16 00:25:43
Done.
|
// Compute start indices to parameters and locals, and the number of |
// parameters to copy. |
- if (optional_parameter_count == 0) { |
+ if (optional_parameter_count == 0 && !is_implicit_native_closure) { |
// Parameter i will be at fp[1 + parameter_count - i] and local variable |
// j will be at fp[kFirstLocalSlotIndex - j]. |
first_parameter_index_ = 1 + parameter_count; |
@@ -157,6 +159,9 @@ |
first_parameter_index_ = kFirstLocalSlotIndex; |
first_stack_local_index_ = first_parameter_index_ - parameter_count; |
copied_parameter_count_ = parameter_count; |
+ if (is_implicit_native_closure) { |
+ copied_parameter_count_ += 1; |
+ } |
} |
// Allocate parameters and local variables, either in the local frame or |
@@ -3954,18 +3959,23 @@ |
// Builds ReturnNode/NativeBodyNode for a native function. |
void Parser::ParseNativeFunctionBlock(const ParamList* params, |
const Function& func) { |
+ func.set_is_native(true); |
TRACE_PARSER("ParseNativeFunctionBlock"); |
const Class& cls = Class::Handle(func.owner()); |
const int num_parameters = params->parameters->length(); |
+ const bool is_implicit_closure = func.IsImplicitClosureFunction(); |
regis
2012/06/15 17:13:34
const bool is_instance_closure = func.IsImplicitIn
siva
2012/06/16 00:25:43
Done.
|
+ int num_params_for_resolution = num_parameters; |
// Parse the function name out. |
const intptr_t native_pos = token_index_; |
const String& native_name = ParseNativeDeclaration(); |
+ if (is_implicit_closure) { |
+ num_params_for_resolution += 1; // account for 'this' when resolving. |
+ } |
// Now resolve the native function to the corresponding native entrypoint. |
- NativeFunction native_function = NativeEntry::ResolveNative(cls, |
- native_name, |
- num_parameters); |
+ NativeFunction native_function = NativeEntry::ResolveNative( |
+ cls, native_name, num_params_for_resolution); |
if (native_function == NULL) { |
ErrorMsg(native_pos, "native function '%s' cannot be found", |
native_name.ToCString()); |
@@ -3979,7 +3989,8 @@ |
native_name, |
native_function, |
num_parameters, |
- has_opt_params))); |
+ has_opt_params, |
+ is_implicit_closure))); |
} |