Eval location
This commit is contained in:
parent
ad2044b81d
commit
6af1dff560
|
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user