feat(ir, parser): Support if/while/break/logical expr/cmp in parser and ir generator

This commit is contained in:
2026-05-14 15:54:31 +08:00
parent 41284dc14e
commit 7b6eede961
10 changed files with 1260 additions and 357 deletions
+1 -6
View File
@@ -98,6 +98,7 @@ impl Generator {
self.instrs.push(SubInstr::new_sp(stack_size_needed as i32));
},
IRInstr::DefineFunc(_, _, _) => unreachable!(),
_ => unimplemented!(),
}
}
}
@@ -189,12 +190,6 @@ impl Generator {
self.instrs.push(MulInstr::new(temp_reg, temp_reg, RegisterOrImm::Reg(right_reg)));
self.instrs.push(SubInstr::new(dest_reg, left_reg, RegisterOrImm::Reg(temp_reg)));
},
IRBinaryOp::Le => todo!(),
IRBinaryOp::Lt => todo!(),
IRBinaryOp::Gt => todo!(),
IRBinaryOp::Ge => todo!(),
IRBinaryOp::Ne => todo!(),
IRBinaryOp::Eq => todo!(),
}
let dest_stack_offset = var_index_to_stack_offset.get(&dest.index).expect("Variable not declared");
self.instrs.push(StoreInstr::new_stack(dest_reg, *dest_stack_offset as i32));