|
|
@ -2,7 +2,7 @@ use crate::{ |
|
|
|
environment::lexical_environment::{new_function_environment, LexicalEnvironment}, |
|
|
|
environment::lexical_environment::{new_function_environment, LexicalEnvironment}, |
|
|
|
js::{ |
|
|
|
js::{ |
|
|
|
array, boolean, console, function, |
|
|
|
array, boolean, console, function, |
|
|
|
function::{Function, RegularFunction}, |
|
|
|
function::{create_unmapped_arguments_object, Function, RegularFunction}, |
|
|
|
json, math, object, |
|
|
|
json, math, object, |
|
|
|
object::{ObjectKind, INSTANCE_PROTOTYPE, PROTOTYPE}, |
|
|
|
object::{ObjectKind, INSTANCE_PROTOTYPE, PROTOTYPE}, |
|
|
|
regexp, string, |
|
|
|
regexp, string, |
|
|
@ -487,10 +487,18 @@ impl Interpreter { |
|
|
|
)); |
|
|
|
)); |
|
|
|
for i in 0..data.args.len() { |
|
|
|
for i in 0..data.args.len() { |
|
|
|
let name = data.args.get(i).unwrap(); |
|
|
|
let name = data.args.get(i).unwrap(); |
|
|
|
let expr = arguments_list.get(i).unwrap(); |
|
|
|
let expr: &Value = arguments_list.get(i).unwrap(); |
|
|
|
self.environment.create_mutable_binding(name.clone(), false); |
|
|
|
self.environment.create_mutable_binding(name.clone(), false); |
|
|
|
self.environment.initialize_binding(name, expr.to_owned()); |
|
|
|
self.environment.initialize_binding(name, expr.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add arguments object
|
|
|
|
|
|
|
|
let arguments_obj = create_unmapped_arguments_object(arguments_list); |
|
|
|
|
|
|
|
self.environment |
|
|
|
|
|
|
|
.create_mutable_binding("arguments".to_string(), false); |
|
|
|
|
|
|
|
self.environment |
|
|
|
|
|
|
|
.initialize_binding("arguments", arguments_obj); |
|
|
|
|
|
|
|
|
|
|
|
let result = self.run(&data.expr); |
|
|
|
let result = self.run(&data.expr); |
|
|
|
self.environment.pop(); |
|
|
|
self.environment.pop(); |
|
|
|
result |
|
|
|
result |
|
|
|