rust-crafting-interpreters-.../src/interpreter/callable.rs
Emmanuel BENOîT d8dba3ac5f Rewrote value storage and implemented class instantiation
* Probably not the last time.
  * Object-like things (functions, classes, etc...) are stored as
    ref-counted cells.
  * Separate data structure for native functions.
  * with_callable() method on value to run specific code on objects
    that are callable
  * Instance type added.
  * Instance construction implemented
2023-01-08 10:40:36 +01:00

15 lines
469 B
Rust

use std::fmt::Debug;
use crate::errors::SloxResult;
use super::{InterpreterState, Value};
/// A callable is some object that supports being called.
pub trait Callable: Debug {
/// Return the amount of arguments supported by the callable.
fn arity(&self) -> usize;
/// Run the callable in the execution environment with the specified
/// arguments.
fn call(&self, itpr_state: &mut InterpreterState, arguments: Vec<Value>) -> SloxResult<Value>;
}