diff --git a/src/protocol/parser/pass_symbols.rs b/src/protocol/parser/pass_symbols.rs index f24b8dade79eafdaac69877d885643a652015269..9f48caf8d41d83e2506044c5e009aeb63794dd96 100644 --- a/src/protocol/parser/pass_symbols.rs +++ b/src/protocol/parser/pass_symbols.rs @@ -64,10 +64,10 @@ impl PassSymbols { // Retrieve first range index, then make immutable borrow let mut range_idx = module_range.first_child_idx; - let module = &modules[module_idx]; // Visit token ranges to detect definitions and pragmas loop { + let module = &modules[module_idx]; let range_idx_usize = range_idx as usize; let cur_range = &module.tokens.ranges[range_idx_usize]; let next_sibling_idx = cur_range.next_sibling_idx; @@ -102,14 +102,15 @@ impl PassSymbols { root.pragmas.extend(self.pragmas.drain(..)); root.definitions.extend(self.definitions.drain(..)); + // Modify module let module = &mut modules[module_idx]; module.phase = ModuleCompilationPhase::SymbolsScanned; Ok(()) } - fn visit_pragma_range(&mut self, modules: &[Module], module_idx: usize, ctx: &mut PassCtx, range_idx: usize) -> Result<(), ParseError> { - let module = &modules[module_idx]; + fn visit_pragma_range(&mut self, modules: &mut [Module], module_idx: usize, ctx: &mut PassCtx, range_idx: usize) -> Result<(), ParseError> { + let module = &mut modules[module_idx]; let range = &module.tokens.ranges[range_idx]; let mut iter = module.tokens.iter_range(range); @@ -139,7 +140,7 @@ impl PassSymbols { })); self.pragmas.push(pragma_id); - if let Err(other_module_root_id) = ctx.symbols.insert_module(module_name, module.root_id) { + if let Err(other_module_root_id) = ctx.symbols.insert_module(module_name.clone(), module.root_id) { // Naming conflict let this_module = &modules[module_idx]; let other_module = seek_module(modules, other_module_root_id).unwrap(); @@ -151,6 +152,8 @@ impl PassSymbols { &other_module.source, other_pragma.span, "other module is defined here" )); } + + module.name = Some((pragma_id, module_name)); self.has_pragma_module = true; } else if pragma_section == b"#version" { // Check if version is defined twice within the same file @@ -166,6 +169,8 @@ impl PassSymbols { version, })); self.pragmas.push(pragma_id); + + module.version = Some((pragma_id, version as i64)); self.has_pragma_version = true; } else { // Custom pragma, maybe we support this in the future, but for now diff --git a/src/runtime2/runtime.rs b/src/runtime2/runtime.rs index 155dcd51e8311df571e18a31cb85c81134a37887..d8ea8d5960331c5e15062ebc667a7840f6991bfe 100644 --- a/src/runtime2/runtime.rs +++ b/src/runtime2/runtime.rs @@ -273,33 +273,6 @@ impl RuntimeInner { return (CompKey(index), component); } - /// Creates a new component. Note that the public part will be properly - /// initialized, but not all private fields are. - pub(crate) fn create_pdl_component(&self, comp: CompPDL, ctx: CompCtx, initially_sleeping: bool) -> (CompKey, &mut RuntimeComp) { - let inbox_queue = QueueDynMpsc::new(16); - let inbox_producer = inbox_queue.producer(); - let comp = RuntimeComp{ - public: CompPublic{ - sleeping: AtomicBool::new(initially_sleeping), - num_handles: AtomicU32::new(1), // the component itself acts like a handle - inbox: inbox_producer, - }, - code: comp, - ctx, - inbox: inbox_queue, - exiting: false, - }; - - let index = self.components.create(comp); - - // TODO: just do a reserve_index followed by a consume_index or something - self.increment_active_components(); - let component = self.components.get_mut(index); - component.ctx.id = CompId(index); - - return (CompKey(index), component); - } - pub(crate) fn get_component(&self, key: CompKey) -> &mut RuntimeComp { let component = self.components.get_mut(key.0); return component;