diff --git a/src/twopass.rs b/src/twopass.rs index 83d6e16..2770c6e 100644 --- a/src/twopass.rs +++ b/src/twopass.rs @@ -293,8 +293,15 @@ impl Eval for ast::Constant { impl Eval for Location { fn eval(&self, ctx: &RunContext) -> types::Value { match self { - Location::Variable { id } => todo!(), - Location::Field { table, index } => todo!(), + Location::Variable { id } => ctx.var(*id).get(), + 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) + } } } }