Implemented callable expressions in AST and Interpret

This commit is contained in:
Erin 2021-08-01 18:30:07 +02:00 committed by ondra05
parent 0c000337d2
commit 3df3cbbf6d
2 changed files with 3 additions and 3 deletions

View file

@ -69,7 +69,7 @@ pub enum StmtKind {
code: Vec<u8>, code: Vec<u8>,
}, },
Call { Call {
iden: Iden, expr: Expr,
args: Vec<Expr>, args: Vec<Expr>,
}, },
Print(Expr), Print(Expr),

View file

@ -267,8 +267,8 @@ impl ExecEnv {
return self.eval_stmts_hs(&body.block, true); return self.eval_stmts_hs(&body.block, true);
} }
} }
StmtKind::Call { iden, args } => { StmtKind::Call { expr, args } => {
let func = self.get_var(iden)?; let func = self.eval_expr(expr)?;
if let Value::Functio(func) = func { if let Value::Functio(func) = func {
self.fn_call(func, args, &stmt.span)?; self.fn_call(func, args, &stmt.span)?;