|
|
@ -192,21 +192,20 @@ impl Function { |
|
|
|
let local_env = new_function_environment( |
|
|
|
let local_env = new_function_environment( |
|
|
|
function, |
|
|
|
function, |
|
|
|
None, |
|
|
|
None, |
|
|
|
Some(self.environment.as_ref().unwrap().clone()), |
|
|
|
self.environment.as_ref().cloned(), |
|
|
|
BindingStatus::Uninitialized, |
|
|
|
BindingStatus::Uninitialized, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Add argument bindings to the function environment
|
|
|
|
// Add argument bindings to the function environment
|
|
|
|
for i in 0..self.params.len() { |
|
|
|
for (i, param) in self.params.iter().enumerate() { |
|
|
|
let param = self.params.get(i).expect("Could not get param"); |
|
|
|
|
|
|
|
// Rest Parameters
|
|
|
|
// Rest Parameters
|
|
|
|
if param.is_rest_param() { |
|
|
|
if param.is_rest_param() { |
|
|
|
self.add_rest_param(param, i, args_list, interpreter, &local_env); |
|
|
|
self.add_rest_param(param, i, args_list, interpreter, &local_env); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let value = args_list.get(i).expect("Could not get value"); |
|
|
|
let value = args_list.get(i).cloned().unwrap_or_else(Value::undefined); |
|
|
|
self.add_arguments_to_environment(param, value.clone(), &local_env); |
|
|
|
self.add_arguments_to_environment(param, value, &local_env); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add arguments object
|
|
|
|
// Add arguments object
|
|
|
@ -253,7 +252,7 @@ impl Function { |
|
|
|
let local_env = new_function_environment( |
|
|
|
let local_env = new_function_environment( |
|
|
|
function, |
|
|
|
function, |
|
|
|
Some(this.clone()), |
|
|
|
Some(this.clone()), |
|
|
|
Some(self.environment.as_ref().unwrap().clone()), |
|
|
|
self.environment.as_ref().cloned(), |
|
|
|
BindingStatus::Initialized, |
|
|
|
BindingStatus::Initialized, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
@ -265,8 +264,8 @@ impl Function { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let value = args_list.get(i).expect("Could not get value"); |
|
|
|
let value = args_list.get(i).cloned().unwrap_or_else(Value::undefined); |
|
|
|
self.add_arguments_to_environment(param, value.clone(), &local_env); |
|
|
|
self.add_arguments_to_environment(param, value, &local_env); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add arguments object
|
|
|
|
// Add arguments object
|
|
|
|