lookup variables

This commit is contained in:
numzero 2025-04-19 12:41:47 +03:00
parent d1e1d8ee5c
commit 9b0127f961

View File

@ -124,7 +124,21 @@ impl BuildContext<'_> {
} }
fn lookup(scope: &BuildContext<'_>, loc: &ast::Location) -> Location { 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 { fn build_expression(scope: &BuildContext<'_>, code: &ast::Expression) -> Expression {