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:
4
local_tests/test_phase5_mir.nyash
Normal file
4
local_tests/test_phase5_mir.nyash
Normal file
@ -0,0 +1,4 @@
|
||||
// Test that deprecated instructions are not generated
|
||||
local result = 42
|
||||
local text = new StringBox("Hello MIR")
|
||||
print(text.toString())
|
||||
@ -784,32 +784,33 @@ impl MirBuilder {
|
||||
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();
|
||||
self.emit_instruction(MirInstruction::RefNew {
|
||||
self.emit_instruction(MirInstruction::NewBox {
|
||||
dst: string_box_dst,
|
||||
box_val: dst,
|
||||
box_type: "StringBox".to_string(),
|
||||
args: vec![dst],
|
||||
})?;
|
||||
|
||||
return Ok(string_box_dst);
|
||||
}
|
||||
}
|
||||
|
||||
// For Phase 6.1, we'll create a simple RefNew without processing arguments
|
||||
// In a full implementation, arguments would be used for constructor calls
|
||||
// Phase 5-3: Create NewBox with processed arguments
|
||||
let dst = self.value_gen.next();
|
||||
|
||||
// For now, create a "box type" value representing the class
|
||||
let type_value = self.value_gen.next();
|
||||
self.emit_instruction(MirInstruction::Const {
|
||||
dst: type_value,
|
||||
value: ConstValue::String(class),
|
||||
})?;
|
||||
// Process all arguments
|
||||
let mut arg_values = Vec::new();
|
||||
for arg in arguments {
|
||||
let arg_value = self.build_expression(arg)?;
|
||||
arg_values.push(arg_value);
|
||||
}
|
||||
|
||||
// Create the reference using RefNew
|
||||
self.emit_instruction(MirInstruction::RefNew {
|
||||
// Create NewBox instruction
|
||||
self.emit_instruction(MirInstruction::NewBox {
|
||||
dst,
|
||||
box_val: type_value,
|
||||
box_type: class,
|
||||
args: arg_values,
|
||||
})?;
|
||||
|
||||
Ok(dst)
|
||||
|
||||
Reference in New Issue
Block a user