|
|
|
@ -94,18 +94,23 @@ impl Executable for FunctionDecl {
|
|
|
|
|
|
|
|
|
|
// Set the name and assign it in the current environment
|
|
|
|
|
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 |
|
|
|
|
.realm_mut() |
|
|
|
|
.environment |
|
|
|
|
.initialize_binding(self.name(), val) |
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
let environment = &mut context.realm_mut().environment; |
|
|
|
|
if environment.has_binding(self.name()) { |
|
|
|
|
environment |
|
|
|
|
.set_mutable_binding(self.name(), val, true) |
|
|
|
|
.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()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|