feat(phase-5.3): Complete frontend cleanup - stop generating deprecated instructions

Phase 5.3 of MIR 35→26 reduction project:
- Replace RefNew with NewBox in MIR builder
- Remove unnecessary Const generation for box types
- Process arguments properly for NewBox instruction
- StringBox special handling maintained with NewBox

Frontend now generates only 26-instruction set compliant MIR.
Build successful with expected deprecation warnings.
This commit is contained in:
Moe Charm
2025-08-17 14:11:51 +09:00
parent 5b7ef32277
commit 7b56f45852
2 changed files with 19 additions and 14 deletions

View File

@ -0,0 +1,4 @@
// Test that deprecated instructions are not generated
local result = 42
local text = new StringBox("Hello MIR")
print(text.toString())

View File

@ -784,32 +784,33 @@ impl MirBuilder {
value: ConstValue::String(s.clone()), value: ConstValue::String(s.clone()),
})?; })?;
// Create RefNew for the StringBox // Phase 5-3: RefNew is deprecated - use NewBox instead
let string_box_dst = self.value_gen.next(); let string_box_dst = self.value_gen.next();
self.emit_instruction(MirInstruction::RefNew { self.emit_instruction(MirInstruction::NewBox {
dst: string_box_dst, dst: string_box_dst,
box_val: dst, box_type: "StringBox".to_string(),
args: vec![dst],
})?; })?;
return Ok(string_box_dst); return Ok(string_box_dst);
} }
} }
// For Phase 6.1, we'll create a simple RefNew without processing arguments // Phase 5-3: Create NewBox with processed arguments
// In a full implementation, arguments would be used for constructor calls
let dst = self.value_gen.next(); let dst = self.value_gen.next();
// For now, create a "box type" value representing the class // Process all arguments
let type_value = self.value_gen.next(); let mut arg_values = Vec::new();
self.emit_instruction(MirInstruction::Const { for arg in arguments {
dst: type_value, let arg_value = self.build_expression(arg)?;
value: ConstValue::String(class), arg_values.push(arg_value);
})?; }
// Create the reference using RefNew // Create NewBox instruction
self.emit_instruction(MirInstruction::RefNew { self.emit_instruction(MirInstruction::NewBox {
dst, dst,
box_val: type_value, box_type: class,
args: arg_values,
})?; })?;
Ok(dst) Ok(dst)