|
|
@ -94,18 +94,23 @@ impl Executable for FunctionDecl { |
|
|
|
|
|
|
|
|
|
|
|
// Set the name and assign it in the current environment
|
|
|
|
// Set the name and assign it in the current environment
|
|
|
|
val.set_field("name", self.name(), context)?; |
|
|
|
val.set_field("name", self.name(), context)?; |
|
|
|
context |
|
|
|
|
|
|
|
.realm_mut() |
|
|
|
|
|
|
|
.environment |
|
|
|
|
|
|
|
.create_mutable_binding(self.name().to_owned(), false, VariableScope::Function) |
|
|
|
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context |
|
|
|
let environment = &mut context.realm_mut().environment; |
|
|
|
.realm_mut() |
|
|
|
if environment.has_binding(self.name()) { |
|
|
|
.environment |
|
|
|
environment |
|
|
|
.initialize_binding(self.name(), val) |
|
|
|
.set_mutable_binding(self.name(), val, true) |
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
environment |
|
|
|
|
|
|
|
.create_mutable_binding(self.name().to_owned(), false, VariableScope::Function) |
|
|
|
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context |
|
|
|
|
|
|
|
.realm_mut() |
|
|
|
|
|
|
|
.environment |
|
|
|
|
|
|
|
.initialize_binding(self.name(), val) |
|
|
|
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
} |
|
|
|
Ok(Value::undefined()) |
|
|
|
Ok(Value::undefined()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|