arbitrary addr

This commit is contained in:
2026-06-06 21:19:09 -04:00
parent 4587f687b9
commit ef35509c98
8 changed files with 35 additions and 18 deletions
+5 -3
View File
@@ -1,4 +1,6 @@
mod addr;
mod symbol;
pub use addr::*;
pub use symbol::*;
use crate::{arch::Arch, backend::LinkedProgram, io::CompilerMsg};
@@ -30,9 +32,9 @@ pub type VarId = usize;
pub type FnId = usize;
impl<A: Arch> Program<A> {
pub fn encode_data(&self, data: &mut Vec<u8>, sym_tab: &mut SymTable) {
pub fn encode_data(&self, data: &mut Vec<u8>, sym_tab: &mut SymTable<A::Addr>) {
for d in &self.ro_data {
let addr = data.len() as u64;
let addr = A::Addr::from_len(data.len());
data.extend(&d.bytes);
sym_tab.insert(d.sym, addr);
}
@@ -58,7 +60,7 @@ impl<A: Arch> Program<A> {
res
}
pub fn compile(&self) -> Result<LinkedProgram, CompilerMsg> {
pub fn compile(&self) -> Result<LinkedProgram<A::Addr>, CompilerMsg> {
A::compile(self)
}