simplify scopes

This commit is contained in:
numzero 2025-04-11 19:54:10 +03:00
parent fa808478ab
commit 291333444f

View File

@ -32,7 +32,7 @@ impl Debug for Function {
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct Scope { pub struct Scope {
pub variables: HashMap<String, Value>, pub variables: HashMap<String, ValueInner>,
pub functions: HashMap<String, Function>, pub functions: HashMap<String, Function>,
} }
@ -54,7 +54,7 @@ impl Eval for Constant {
impl Eval for Location { impl Eval for Location {
fn eval(&self, scope: &mut Scope) -> Value { fn eval(&self, scope: &mut Scope) -> Value {
match self { match self {
Location::Variable { name } => scope.variables.get(name).cloned().flatten(), Location::Variable { name } => scope.variables.get(name).cloned(),
Location::Field { table, index } => { Location::Field { table, index } => {
let table = table.eval(scope); let table = table.eval(scope);
let Some(ValueInner::Table(table)) = table else { let Some(ValueInner::Table(table)) = table else {