work
This commit is contained in:
@@ -9,6 +9,7 @@ pub struct Program<A: Arch> {
|
||||
pub ro_data: Vec<Data>,
|
||||
pub funcs: Vec<Func<A>>,
|
||||
pub entry: Option<Symbol>,
|
||||
pub external: Vec<External>,
|
||||
|
||||
sym_count: usize,
|
||||
}
|
||||
@@ -23,6 +24,11 @@ pub struct Func<A: Arch> {
|
||||
pub sym: Symbol,
|
||||
}
|
||||
|
||||
pub struct External {
|
||||
pub file: String,
|
||||
pub syms: Vec<Symbol>,
|
||||
}
|
||||
|
||||
pub enum Instr<A: Arch> {
|
||||
Set { dst: VarId, src: Vec<u8> },
|
||||
Call { dst: FnId, args: Vec<VarId> },
|
||||
@@ -56,6 +62,22 @@ impl<A: Arch> Program<A> {
|
||||
sym
|
||||
}
|
||||
|
||||
pub fn external<const LEN: usize>(
|
||||
&mut self,
|
||||
file: impl Into<String>,
|
||||
names: [impl Into<String>; LEN],
|
||||
) -> [Symbol; LEN] {
|
||||
let syms = names.map(|s| {
|
||||
let sym = self.reserve();
|
||||
sym
|
||||
});
|
||||
self.external.push(External {
|
||||
file: file.into(),
|
||||
syms: syms.to_vec(),
|
||||
});
|
||||
syms
|
||||
}
|
||||
|
||||
fn reserve(&mut self) -> Symbol {
|
||||
let res = Symbol(self.sym_count);
|
||||
self.sym_count += 1;
|
||||
@@ -78,6 +100,7 @@ impl<A: Arch> Default for Program<A> {
|
||||
funcs: Default::default(),
|
||||
entry: Default::default(),
|
||||
sym_count: Default::default(),
|
||||
external: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user