This commit is contained in:
2025-11-22 22:23:42 +01:00
parent b24bfc0241
commit 7855e5b092
7 changed files with 72 additions and 42 deletions

View File

@@ -6,7 +6,6 @@ use crate::{
};
pub struct Var {
// pub var_type: String,
pub stack_offset: usize,
}
@@ -105,7 +104,7 @@ section .text
"
);
for name in &["malloc", "realloc", "free", "system", "gethostbyname"] {
for name in &["malloc", "realloc", "free", "gethostbyname"] {
emit!(&mut self.output, "extern {}", name);
emit!(&mut self.output, "c.{} equ {}", name, name);
}
@@ -156,6 +155,12 @@ _builtin_syscall:
mov r9, [rsp+8]
syscall
ret
section .text._builtin_environ
_builtin_environ:
extern environ
mov rax, [rel environ]
ret
"
);
Ok(())
@@ -303,7 +308,7 @@ _builtin_syscall:
emit!(&mut self.output, " jmp {}", env.loop_begin_label);
}
Stmt::Extern(name) => {
emit!(&mut self.output, " extern {}", name.lexeme);
emit!(&mut self.output, "extern {}", name.lexeme);
}
}
Ok(())