WIP: Add Store instruction to MIR for variable assignments
- Added Store instruction generation in build_assignment() - This partially addresses the VM infinite loop issue - However, the loop still uses old values (%0) instead of updated values - Need to implement proper SSA phi nodes for loop variables The root cause: MIR generation doesn't properly track variable updates in loops. Current SSA implementation lacks phi nodes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -316,7 +316,15 @@ impl MirBuilder {
|
||||
let value_id = self.build_expression(value)?;
|
||||
|
||||
// In SSA form, each assignment creates a new value
|
||||
self.variable_map.insert(var_name, value_id);
|
||||
self.variable_map.insert(var_name.clone(), value_id);
|
||||
|
||||
// Generate a Store instruction to ensure VM can track the assignment
|
||||
// For now, we use the variable name as a simple pointer identifier
|
||||
let var_ptr = self.value_gen.next();
|
||||
self.emit_instruction(MirInstruction::Store {
|
||||
value: value_id,
|
||||
ptr: var_ptr,
|
||||
})?;
|
||||
|
||||
Ok(value_id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user