who knows

This commit is contained in:
2024-11-26 22:42:39 -05:00
parent 87f755b763
commit 31c197e991
10 changed files with 17 additions and 3 deletions

56
src/ir/lvl1/func.rs Normal file
View File

@@ -0,0 +1,56 @@
use crate::compiler::riscv64::AsmInstruction;
use super::{FnIdent, VarIdent};
#[derive(Debug)]
pub struct Function {
instructions: Vec<Instruction>,
}
#[derive(Debug)]
pub enum Instruction {
Mv {
dest: VarIdent,
src: VarIdent,
},
Ref {
dest: VarIdent,
src: VarIdent,
},
Lf {
dest: VarIdent,
src: FnIdent,
},
Call {
dest: VarIdent,
f: FnIdent,
args: Vec<VarIdent>,
},
AsmBlock {
instructions: Vec<AsmInstruction>,
},
Ret {
src: VarIdent,
},
}
pub struct Instructions {
vec: Vec<Instruction>,
}
impl Function {
pub fn new(instructions: Instructions) -> Self {
Self {
instructions: instructions.vec,
}
}
}
impl Instructions {
pub fn new() -> Self {
Self { vec: Vec::new() }
}
pub fn push(&mut self, i: Instruction) {
self.vec.push(i);
}
}