diff --git a/src/twopass.rs b/src/twopass.rs index a8ec575..5a6cc04 100644 --- a/src/twopass.rs +++ b/src/twopass.rs @@ -124,7 +124,21 @@ impl BuildContext<'_> { } fn lookup(scope: &BuildContext<'_>, loc: &ast::Location) -> Location { - todo!() + match loc { + ast::Location::Variable { name } => { + if let Some(id) = scope.request(name) { + return Location::Variable { id }; + }; + let env = scope + .request(&"_ENV".into()) + .expect("_ENV must be always available"); + Location::Field { + table: Box::new(Location::Variable { id: env }), + index: Box::new(Expression::Constant(ast::Constant::String(name.clone()))), + } + } + ast::Location::Field { table, index } => todo!(), + } } fn build_expression(scope: &BuildContext<'_>, code: &ast::Expression) -> Expression {