From 3df3cbbf6d927e96fda73c4acd30bdb70f1fe6db Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 1 Aug 2021 18:30:07 +0200 Subject: [PATCH] Implemented callable expressions in AST and Interpret --- src/ast.rs | 2 +- src/interpret.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 3fede855..04a884d0 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -69,7 +69,7 @@ pub enum StmtKind { code: Vec, }, Call { - iden: Iden, + expr: Expr, args: Vec, }, Print(Expr), diff --git a/src/interpret.rs b/src/interpret.rs index bf3e49e5..1f0f0f65 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -267,8 +267,8 @@ impl ExecEnv { return self.eval_stmts_hs(&body.block, true); } } - StmtKind::Call { iden, args } => { - let func = self.get_var(iden)?; + StmtKind::Call { expr, args } => { + let func = self.eval_expr(expr)?; if let Value::Functio(func) = func { self.fn_call(func, args, &stmt.span)?;