From 0054a2305b30139604e74d970e4b4793b98ce9b8 Mon Sep 17 00:00:00 2001 From: Elizabeth Gilbert Date: Tue, 5 Nov 2024 17:03:53 -0500 Subject: [PATCH] add some more todos --- src/emitter/module_emitter.rs | 2 ++ src/generator/wizard/metadata_collector.rs | 2 ++ src/generator/wizard/mod.rs | 2 +- src/lang_features/alloc_vars/wizard.rs | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/emitter/module_emitter.rs b/src/emitter/module_emitter.rs index 6f4aed8e..4c155616 100644 --- a/src/emitter/module_emitter.rs +++ b/src/emitter/module_emitter.rs @@ -137,6 +137,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> ModuleEmitter<'a, 'b, 'c, 'd, 'e, 'f> { let func = FunctionBuilder::new(params, results); self.emitting_func = Some(func); + // TODO(alloc) -- load alloc vars if self.map_lib_adapter.is_used { let fid = self.map_lib_adapter.get_map_init_fid(self.app_wasm, err); if let Some(func) = &mut self.emitting_func { @@ -147,6 +148,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> ModuleEmitter<'a, 'b, 'c, 'd, 'e, 'f> { // emit the function body self.emit_body(&[], block, err); + // TODO(alloc) -- save alloc vars // emit the function if let Some(func) = self.emitting_func.take() { let fid = func.finish_module(self.app_wasm); diff --git a/src/generator/wizard/metadata_collector.rs b/src/generator/wizard/metadata_collector.rs index fc0a64b8..66d7a3a9 100644 --- a/src/generator/wizard/metadata_collector.rs +++ b/src/generator/wizard/metadata_collector.rs @@ -238,6 +238,8 @@ impl WhammVisitor<()> for WizardProbeMetadataCollector<'_, '_, '_> { if *is_report { self.curr_probe.incr_reports(); } + // change this to save off data to allocate + todo!() } Statement::Assign { var_id, expr, .. } => { if let Expr::VarId { name, .. } = var_id { diff --git a/src/generator/wizard/mod.rs b/src/generator/wizard/mod.rs index 5578994d..9b721157 100644 --- a/src/generator/wizard/mod.rs +++ b/src/generator/wizard/mod.rs @@ -121,6 +121,7 @@ impl WizardGenerator<'_, '_, '_, '_, '_, '_, '_, '_, '_> { let mut params = vec![]; let mut param_str = "".to_string(); + // TODO(alloc) -- handle $alloc param (if there are alloc vars) for (local_id, (param_name, param_ty)) in param_reqs.iter().enumerate() { // handle param list params.push(whamm_type_to_wasm_type(param_ty)); @@ -168,7 +169,6 @@ impl WizardGenerator<'_, '_, '_, '_, '_, '_, '_, '_, '_> { } fn visit_wiz_probe(&mut self, probe: &mut WizardProbe) { - // TODO -- handle provided functions (provider, package, event, probe) self.set_curr_loc(self.create_curr_loc(probe)); let (pred_fid, pred_param_str) = if let Some(pred) = &mut probe.predicate { diff --git a/src/lang_features/alloc_vars/wizard.rs b/src/lang_features/alloc_vars/wizard.rs index be6835cd..e66286f0 100644 --- a/src/lang_features/alloc_vars/wizard.rs +++ b/src/lang_features/alloc_vars/wizard.rs @@ -21,11 +21,16 @@ pub fn load_alloc_vars( _alloc_mem_offset: VarAddr, _alloc_vars: Vec<(String, DataType)>, ) -> HashMap { + // increment by bytes used by each var's DataType as we load them + // will be used to load the next variable AND to save in the VarAddr! + let _used_bytes = 0; + // alloc_mem_offset: parameter that specifies the result of calling $alloc (should be wasm local var) // alloc_vars: Vec<(var_name, var_ty)>, in the order they should appear in memory starting at // the offset `alloc_mem_offset` // result: The new local variables: name -> (addr, ty) // as a hashmap to enable caller to place in SymbolTable and handle report variables + // the new VarAddr will be a pointer into memory with an offset (real addr should be alloc_mem_offset + len_of_prev_vars) // At start of probe logic, pull the current values of the 'alloc' variables from memory. // Add these VarAddrs to the symbol table.