Eval location

This commit is contained in:
numzero 2025-04-19 13:50:16 +03:00
parent ad2044b81d
commit 6af1dff560

View File

@ -293,8 +293,15 @@ impl Eval for ast::Constant {
impl Eval for Location { impl Eval for Location {
fn eval(&self, ctx: &RunContext) -> types::Value { fn eval(&self, ctx: &RunContext) -> types::Value {
match self { match self {
Location::Variable { id } => todo!(), Location::Variable { id } => ctx.var(*id).get(),
Location::Field { table, index } => todo!(), Location::Field { table, index } => {
let table = table.eval(ctx).expect("attempt to index a nil value");
let index = index.eval(ctx).expect("attempt to index with a nil value");
let types::ValueInner::Table(table) = table else {
panic!("attempt to index a non-table");
};
table.get(index)
}
} }
} }
} }