This commit is contained in:
Nilton Constantino
2026-01-31 20:39:05 +00:00
parent 83e24920b4
commit ff4dcad5dc
42 changed files with 2941 additions and 603 deletions
+11 -6
View File
@@ -51,6 +51,9 @@ mod tests {
functions: vec![Function {
id: FunctionId(1),
name: "main".to_string(),
param_slots: 0,
local_slots: 0,
return_slots: 0,
params: vec![],
return_type: Type::Null,
body: vec![
@@ -99,7 +102,10 @@ mod tests {
"kind": "Ret",
"span": null
}
]
],
"param_slots": 0,
"local_slots": 0,
"return_slots": 0
}
],
"globals": []
@@ -122,6 +128,9 @@ mod tests {
functions: vec![ir_core::Function {
id: FunctionId(10),
name: "start".to_string(),
param_slots: 0,
local_slots: 0,
return_slots: 0,
params: vec![],
return_type: ir_core::Type::Void,
blocks: vec![ir_core::Block {
@@ -146,7 +155,7 @@ mod tests {
assert_eq!(func.name, "start");
assert_eq!(func.id, FunctionId(10));
assert_eq!(func.body.len(), 4);
assert_eq!(func.body.len(), 3);
match &func.body[0].kind {
InstrKind::Label(Label(l)) => assert!(l.contains("block_0")),
_ => panic!("Expected label"),
@@ -156,10 +165,6 @@ mod tests {
_ => panic!("Expected PushConst"),
}
match &func.body[2].kind {
InstrKind::PushNull => (),
_ => panic!("Expected PushNull"),
}
match &func.body[3].kind {
InstrKind::Ret => (),
_ => panic!("Expected Ret"),
}
@@ -40,6 +40,10 @@ pub struct Function {
pub return_type: Type,
/// The sequence of instructions that make up the function's logic.
pub body: Vec<Instruction>,
pub param_slots: u16,
pub local_slots: u16,
pub return_slots: u16,
}
/// A parameter passed to a function.