added returning & more asm instructions
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// TODO: move this into ir, not parser
|
||||
use super::{IRUProgram, Type};
|
||||
use crate::common::CompilerOutput;
|
||||
use crate::common::{CompilerMsg, CompilerOutput};
|
||||
|
||||
impl IRUProgram {
|
||||
pub fn validate(&self) -> CompilerOutput {
|
||||
let mut output = CompilerOutput::new();
|
||||
for f in self.fns.iter().flatten() {
|
||||
for (f, fd) in self.fns.iter().flatten().zip(&self.fn_defs) {
|
||||
for i in &f.instructions {
|
||||
match &i.i {
|
||||
super::IRUInstruction::Mv { dest, src } => {
|
||||
@@ -35,6 +35,12 @@ impl IRUProgram {
|
||||
todo!()
|
||||
};
|
||||
output.check_assign(self, ret, destty, dest.span);
|
||||
if args.len() != argtys.len() {
|
||||
output.err(CompilerMsg {
|
||||
msg: "Wrong number of arguments to function".to_string(),
|
||||
spans: vec![dest.span],
|
||||
});
|
||||
}
|
||||
for (argv, argt) in args.iter().zip(argtys) {
|
||||
let dest = self.get_var(argv.id);
|
||||
output.check_assign(self, argt, &dest.ty, argv.span);
|
||||
@@ -43,7 +49,10 @@ impl IRUProgram {
|
||||
super::IRUInstruction::AsmBlock { instructions, args } => {
|
||||
// TODO
|
||||
}
|
||||
super::IRUInstruction::Ret { src } => todo!(),
|
||||
super::IRUInstruction::Ret { src } => {
|
||||
let srcty = &self.get_var(src.id).ty;
|
||||
output.check_assign(self, srcty, &fd.ret, src.span);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user