Skip to content

Commit

Permalink
Add some comments to plan and panic on special_decl_init
Browse files Browse the repository at this point in the history
  • Loading branch information
ejrgilbert committed Nov 5, 2024
1 parent 19e3ce3 commit 175ef5d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/emitter/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ fn emit_report_decl_stmt<'a, T: Opcode<'a> + MacroOpcode<'a> + AddLocal>(
err_msg: &str,
err: &mut ErrorGen,
) -> bool {
// TODO(alloc)
// call lang_features.alloc_vars.rewriting IF doing rewriting...
// ...will need to thread injection method through
// (ignore this statement on wizard target since it's already handled)
if let Statement::AllocDecl { decl, .. } = stmt {
return match &**decl {
Statement::Decl { ty, var_id, .. } => {
Expand Down
4 changes: 4 additions & 0 deletions src/lang_features/alloc_vars/rewriting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ pub fn allocate_vars(_to_alloc: Vec<(String, DataType)>) -> HashMap<String, (Var
// Can now emit the rest of the probe body logic as normal.

// NOTE: `decl_init` statements should be run ONCE

// See utils.rs/`emit_report_decl_stmt`
// basically want to do just refactor to call out to THIS function instead (more modular)
// this function will also handle if the var is a report variable
todo!()
}
34 changes: 18 additions & 16 deletions src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,15 @@ wasm:opcode:br:before {
report bool b;
}
"#,
r#"
i32 a;
report i32 c;
wasm::br:before {
a = 1;
report bool b = true;
}
"#,
// TODO -- uncomment when we've supported special_decl_init
// r#"
// i32 a;
// report i32 c;
// wasm::br:before {
// a = 1;
// report bool b = true;
// }
// "#,
// alloc variables
r#"
i32 a;
Expand All @@ -205,14 +206,15 @@ wasm:opcode:br:before {
alloc bool b;
}
"#,
r#"
i32 a;
alloc i32 c;
wasm::br:before {
a = 1;
alloc bool b = true;
}
"#,
// TODO -- uncomment when we've supported special_decl_init
// r#"
// i32 a;
// alloc i32 c;
// wasm::br:before {
// a = 1;
// alloc bool b = true;
// }
// "#,
// special variables
r#"
alloc report i32 c;
Expand Down
5 changes: 4 additions & 1 deletion src/parser/whamm_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,10 @@ fn handle_decl_init(pair: Pair<Rule>, err: &mut ErrorGen) -> Vec<Statement> {
// create the decl
let decl_pair = pairs.next().unwrap();
let decls = match decl_pair.as_rule() {
Rule::special_decl => handle_special_decl(decl_pair, err),
Rule::special_decl => {
// handle_special_decl(decl_pair, err)
unimplemented!("Declaring a special variable and initializing is not currently supported (e.g. `report i32 i = 0;`).");
}
Rule::decl => handle_decl(&mut decl_pair.into_inner(), err),
rule => {
err.parse_error(
Expand Down

0 comments on commit 175ef5d

Please sign in to comment.