* 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
15 lines
469 B
Rust
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>;
|
|
}
|