29 lines
733 B
Rust
29 lines
733 B
Rust
use cagire_forth::Forth;
|
|
|
|
pub use cagire_forth::{CcMemory, Dictionary, ExecutionTrace, Rng, SourceSpan, StepContext, Value, Variables};
|
|
|
|
pub struct ScriptEngine {
|
|
forth: Forth,
|
|
}
|
|
|
|
impl ScriptEngine {
|
|
pub fn new(vars: Variables, dict: Dictionary, rng: Rng) -> Self {
|
|
Self {
|
|
forth: Forth::new(vars, dict, rng),
|
|
}
|
|
}
|
|
|
|
pub fn evaluate(&self, script: &str, ctx: &StepContext) -> Result<Vec<String>, String> {
|
|
self.forth.evaluate(script, ctx)
|
|
}
|
|
|
|
pub fn evaluate_with_trace(
|
|
&self,
|
|
script: &str,
|
|
ctx: &StepContext,
|
|
trace: &mut ExecutionTrace,
|
|
) -> Result<Vec<String>, String> {
|
|
self.forth.evaluate_with_trace(script, ctx, trace)
|
|
}
|
|
}
|