Static allocations

This commit is contained in:
2023-11-22 23:40:25 -06:00
parent 640ef91306
commit 33c28ceb4a
9 changed files with 86 additions and 12 deletions
+8
View File
@@ -15,6 +15,8 @@ pub(crate) struct State {
pub functions: BTreeMap<String, CompiledFn>,
/// The string table
pub strings: Vec<(Label, String)>,
/// The statically-allocated buffers (size in bytes)
pub buffers: Vec<(Label, usize)>,
/// The functions that have been prototyped but not yet defined
pub prototypes: Scope,
}
@@ -52,6 +54,12 @@ impl State {
sym
}
pub(crate) fn add_buffer(&mut self, size: usize) -> Label {
let sym = self.gensym();
self.buffers.push((sym.clone(), size));
sym
}
pub(crate) fn declare_function(&mut self, name: &str, _args: Vec<String>) -> Result<(), CompileError> {
// If it's not already prototyped, gensym a label and put it in the list. If it is, just
// ignore this (we don't check arity so it's not like the arglist being different matters)