HAPPY CLIPPY IS HAPPY!!!!
This commit is contained in:
parent
36c842d7ab
commit
db781ed00f
2 changed files with 8 additions and 8 deletions
|
@ -22,13 +22,13 @@ pub(crate) struct Function {
|
||||||
impl Function {
|
impl Function {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
name: Option<&Token>,
|
name: Option<&Token>,
|
||||||
params: &Vec<Token>,
|
params: &[Token],
|
||||||
body: &Vec<ast::StmtNode>,
|
body: &[ast::StmtNode],
|
||||||
) -> Rc<RefCell<Self>> {
|
) -> Rc<RefCell<Self>> {
|
||||||
let fun = Self {
|
let fun = Self {
|
||||||
name: name.map(|t| t.clone()),
|
name: name.cloned(),
|
||||||
params: params.clone(),
|
params: params.to_owned(),
|
||||||
body: body.clone(),
|
body: body.to_owned(),
|
||||||
};
|
};
|
||||||
Rc::new(RefCell::new(fun))
|
Rc::new(RefCell::new(fun))
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ impl Callable for Function {
|
||||||
let param_env = Environment::create_child(environment);
|
let param_env = Environment::create_child(environment);
|
||||||
for (arg, value) in izip!(self.params.iter(), arguments.into_iter()) {
|
for (arg, value) in izip!(self.params.iter(), arguments.into_iter()) {
|
||||||
// FIXME: duplicate parameter names should be detected in the parser
|
// FIXME: duplicate parameter names should be detected in the parser
|
||||||
param_env.borrow_mut().define(&arg, Some(value))?;
|
param_env.borrow_mut().define(arg, Some(value))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let child = Environment::create_child(¶m_env);
|
let child = Environment::create_child(¶m_env);
|
||||||
|
|
|
@ -157,8 +157,8 @@ impl ast::StmtNode {
|
||||||
&self,
|
&self,
|
||||||
environment: &EnvironmentRef,
|
environment: &EnvironmentRef,
|
||||||
name: &Token,
|
name: &Token,
|
||||||
params: &Vec<Token>,
|
params: &[Token],
|
||||||
body: &Vec<ast::StmtNode>,
|
body: &[ast::StmtNode],
|
||||||
) -> InterpreterResult {
|
) -> InterpreterResult {
|
||||||
let fun = Function::new(Some(name), params, body);
|
let fun = Function::new(Some(name), params, body);
|
||||||
environment
|
environment
|
||||||
|
|
Loading…
Reference in a new issue