ralix 0.2.0

A simple, type-safe, tree walking interpreter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{EvalResult, Evaluator, Expression, Value, try_eval_result, types::Type};

impl Evaluator<'_> {
    pub fn evaluate_typeof_expression(&mut self, expr: Expression) -> EvalResult<Value> {
        if let Expression::Scope { statements } = &expr
            && statements.is_empty()
        {
            return EvalResult::Value(Value::Type(Type::Void));
        }

        let obj = try_eval_result!(self.evaluate_expression(expr));

        EvalResult::Value(Value::Type(obj.r#type(self.ctx.heap)))
    }
}