Files
@ 41b1cad0b9fe
Branch filter:
Location: CSY/reowolf/src/protocol/parser/pass_stack_size.rs - annotation
41b1cad0b9fe
1.3 KiB
application/rls-services+xml
Integrated rewrite pass into compiler
41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe 41b1cad0b9fe | use crate::collections::*;
use crate::protocol::*;
use super::visitor::*;
// Will get a rename. Will probably become bytecode emitter or something. For
// now it just scans the scopes and assigns a unique number for each variable
// such that, at any point in the program's execution, all accessible in-scope
// variables will have a unique position "on the stack".
pub(crate) struct PassStackSize {
definition_buffer: ScopedBuffer<DefinitionId>,
}
impl PassStackSize {
pub(crate) fn new() -> Self {
return Self{
definition_buffer: ScopedBuffer::with_capacity(BUFFER_INIT_CAP_LARGE),
}
}
}
impl Visitor for PassStackSize {
fn visit_module(&mut self, ctx: &mut Ctx) -> VisitorResult {
let module = ctx.module();
debug_assert_eq!(module.phase, ModuleCompilationPhase::Rewritten);
let root_id = module.root_id;
let root = &ctx.heap[root_id];
let definition_section = self.definition_buffer.start_section_initialized(&root.definitions);
for definition_index in 0..definition_section.len() {
let definition_id = definition_section[definition_index];
self.visit_definition(ctx, definition_id)?
}
definition_section.forget();
// ctx.module_mut().phase = ModuleCompilationPhase::StackSizeStuffAndStuff;
return Ok(())
}
}
|