1pub use env::*;
16pub use eval::*;
17pub use interpreter_input::*;
18pub use interpreter_result::*;
19pub use literal::*;
20pub use rib_function_invoke::*;
21pub use rib_interpreter::*;
22pub use rib_runtime_error::*;
23pub use stack::*;
24
25mod env;
26mod eval;
27mod instruction_cursor;
28mod interpreter_input;
29mod interpreter_result;
30mod interpreter_stack_value;
31mod literal;
32mod rib_function_invoke;
33mod rib_interpreter;
34mod rib_runtime_error;
35mod stack;
36
37use crate::{DefaultWorkerNameGenerator, GenerateWorkerName, RibByteCode};
38use std::sync::Arc;
39
40pub async fn interpret(
41 rib: RibByteCode,
42 rib_input: RibInput,
43 function_invoke: Arc<dyn RibComponentFunctionInvoke + Sync + Send>,
44 generate_worker_name: Option<Arc<dyn GenerateWorkerName + Sync + Send>>,
45) -> Result<RibResult, RibRuntimeError> {
46 let mut interpreter = Interpreter::new(
47 rib_input,
48 function_invoke,
49 generate_worker_name.unwrap_or_else(|| Arc::new(DefaultWorkerNameGenerator)),
50 );
51 interpreter.run(rib).await
52}
53
54pub async fn interpret_pure(
58 rib: RibByteCode,
59 rib_input: RibInput,
60 generate_worker_name: Option<Arc<dyn GenerateWorkerName + Sync + Send>>,
61) -> Result<RibResult, RibRuntimeError> {
62 let mut interpreter = Interpreter::pure(
63 rib_input,
64 generate_worker_name.unwrap_or_else(|| Arc::new(DefaultWorkerNameGenerator)),
65 );
66 interpreter.run(rib.clone()).await
67}
68
69#[macro_export]
70macro_rules! internal_corrupted_state {
71 ($fmt:expr) => {{
72 $crate::interpreter::rib_runtime_error::RibRuntimeError::InvariantViolation($crate::interpreter::rib_runtime_error::InvariantViolation::InternalCorruptedState($fmt.to_string()))
73 }};
74
75 ($fmt:expr, $($arg:tt)*) => {{
76 $crate::interpreter::rib_runtime_error::RibRuntimeError::InvariantViolation($crate::interpreter::rib_runtime_error::InvariantViolation::InternalCorruptedState(format!($fmt, $($arg)*)))
77 }};
78}
79
80#[macro_export]
81macro_rules! bail_corrupted_state {
82 ($fmt:expr) => {{
83 return Err($crate::interpreter::rib_runtime_error::RibRuntimeError::InvariantViolation($crate::interpreter::rib_runtime_error::InvariantViolation::InternalCorruptedState($fmt.to_string())));
84 }};
85
86 ($fmt:expr, $($arg:tt)*) => {{
87 return Err($crate::interpreter::rib_runtime_error::RibRuntimeError::InvariantViolation($crate::interpreter::rib_runtime_error::InvariantViolation::InternalCorruptedState(format!($fmt, $($arg)*))));
88 }};
89}