interpreter/runtime/
mod.rs

1use std::collections::HashMap;
2
3use crate::types::{Args, Heap, HeapWrapper, Options};
4
5pub type PackageCallback = fn(Args, &mut Heap, HeapWrapper, &String, &mut Options) -> ();
6pub type RuntimeMethodRes = HashMap<&'static str, (&'static str, PackageCallback)>;
7
8pub mod _root_syntax;
9
10#[derive(Debug)]
11pub struct RuntimeValue {
12  pub r#type: String,
13  pub _inner: Heap,
14  pub fn_ptr: RuntimeMethodRes,
15}
16
17impl RuntimeValue {
18  pub fn new(r#type: &str, fn_ptr: RuntimeMethodRes) -> Self {
19    Self {
20      r#type: format!("{}", r#type),
21      _inner: Heap::new(),
22      fn_ptr,
23    }
24  }
25
26  pub fn call_ptr(
27    &mut self,
28    caller: &str,
29    v: *const [*const str],
30    a: HeapWrapper,
31    c: &String,
32    o: &mut Options,
33  ) -> Option<()> {
34    let (_, f) = self.fn_ptr.get(caller)?;
35
36    f(v, &mut self._inner, a, c, o);
37    Some(())
38  }
39}