diff --git a/src/interpreter/callable.rs b/src/interpreter/callable.rs index d6f9e59..bb00afc 100644 --- a/src/interpreter/callable.rs +++ b/src/interpreter/callable.rs @@ -11,7 +11,7 @@ pub trait Callable: Debug + ToString { /// Run the callable in the execution environment with the specified /// arguments. - fn call(&self, environment: &mut InterpreterState, arguments: Vec) -> SloxResult; + fn call(&self, callee: &Value, environment: &mut InterpreterState, arguments: Vec) -> SloxResult; } /// A reference to a callable. diff --git a/src/interpreter/functions.rs b/src/interpreter/functions.rs index 826903e..d45c654 100644 --- a/src/interpreter/functions.rs +++ b/src/interpreter/functions.rs @@ -39,7 +39,12 @@ impl Callable for Function { self.params.len() } - fn call(&self, es: &mut InterpreterState, arguments: Vec) -> SloxResult { + fn call( + &self, + _callee: &Value, + es: &mut InterpreterState, + arguments: Vec, + ) -> SloxResult { assert_eq!(arguments.len(), self.arity()); let param_env = InterpreterState { environment: Environment::create_child(&self.env), diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index 7144a6b..c938077 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -505,7 +505,7 @@ impl ExprNode { ), )) } else { - Ok(callable.call(es, arg_values)?.into()) + Ok(callable.call(&callee, es, arg_values)?.into()) } } else { error(right_paren, "can only call functions and classes") diff --git a/src/interpreter/native_fn.rs b/src/interpreter/native_fn.rs index a0e8719..b868bd1 100644 --- a/src/interpreter/native_fn.rs +++ b/src/interpreter/native_fn.rs @@ -20,7 +20,12 @@ impl Callable for Clock { 0 } - fn call(&self, _environment: &mut InterpreterState, _arguments: Vec) -> SloxResult { + fn call( + &self, + _callee: &Value, + _environment: &mut InterpreterState, + _arguments: Vec, + ) -> SloxResult { let now = SystemTime::now(); let since_epoch = now .duration_since(UNIX_EPOCH)