arbitrary addr
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user