Skip to main content

aver/interpreter/
api.rs

1use super::*;
2
3impl Interpreter {
4    pub fn callable_declared_effects(fn_val: &Value) -> Vec<String> {
5        match fn_val {
6            Value::Fn { effects, .. } => effects.clone(),
7            _ => vec![],
8        }
9    }
10
11    // Public wrapper so main.rs can call call_value
12    pub fn call_value_pub(
13        &mut self,
14        fn_val: Value,
15        args: Vec<Value>,
16    ) -> Result<Value, RuntimeError> {
17        self.call_value(fn_val, args)
18    }
19
20    pub fn call_value_with_effects_pub(
21        &mut self,
22        fn_val: Value,
23        args: Vec<Value>,
24        entry_name: &str,
25        allowed_effects: Vec<String>,
26    ) -> Result<Value, RuntimeError> {
27        self.call_stack.push(CallFrame {
28            name: entry_name.to_string(),
29            effects: allowed_effects,
30        });
31        let result = self.call_value(fn_val, args);
32        self.call_stack.pop();
33        result
34    }
35}