Add Any-mutability for StackValues

This commit is contained in:
Sofia 2025-07-17 00:55:11 +03:00
parent 8abee593f0
commit 8ffb3baa8d

View File

@ -65,6 +65,7 @@ pub struct StackValue(StackValueKind, Type);
pub enum StackValueKind { pub enum StackValueKind {
Immutable(InstructionValue), Immutable(InstructionValue),
Mutable(InstructionValue), Mutable(InstructionValue),
Any(InstructionValue),
} }
impl StackValueKind { impl StackValueKind {
@ -72,6 +73,7 @@ impl StackValueKind {
match self { match self {
StackValueKind::Immutable(val) => val, StackValueKind::Immutable(val) => val,
StackValueKind::Mutable(val) => val, StackValueKind::Mutable(val) => val,
StackValueKind::Any(val) => val,
} }
} }
@ -79,6 +81,7 @@ impl StackValueKind {
match self { match self {
StackValueKind::Immutable(_) => StackValueKind::Immutable(instr), StackValueKind::Immutable(_) => StackValueKind::Immutable(instr),
StackValueKind::Mutable(_) => StackValueKind::Mutable(instr), StackValueKind::Mutable(_) => StackValueKind::Mutable(instr),
StackValueKind::Any(_) => StackValueKind::Any(instr),
} }
} }
} }
@ -346,6 +349,7 @@ impl mir::Expression {
val val
} }
} }
_ => panic!("Found an unknown-mutable variable!"),
}) })
} }
mir::ExprKind::Literal(lit) => Some(lit.as_const(&mut scope.block)), mir::ExprKind::Literal(lit) => Some(lit.as_const(&mut scope.block)),