From 2b43706f82e2d9c71fa0ad9d5a2c8c97afbd3787 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Fri, 11 Oct 2024 22:20:05 -0400 Subject: [PATCH] feat: do not hardcode allocation type --- compiler/src/middle_end/matchcomp.re | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/middle_end/matchcomp.re b/compiler/src/middle_end/matchcomp.re index b3041a967..58f8d3bb2 100644 --- a/compiler/src/middle_end/matchcomp.re +++ b/compiler/src/middle_end/matchcomp.re @@ -1352,6 +1352,7 @@ module MatchTreeCompiler = { [BLet(match_jmp_name, match_mapped_cond, Nonglobal)], ); }; + let allocation_type = ref(Unmanaged(WasmI32)); let cases = List.map( ((tag, tree)) => { @@ -1366,15 +1367,16 @@ module MatchTreeCompiler = { helpI, helpConst, ); + allocation_type := tree_ans.comp_allocation_type; (tag - min, fold_tree(tree_setup, tree_ans)); }, cases, ); + assert(List.length(cases) != 0); let switch_body = Comp.switch_( ~loc=Location.dummy_loc, - // TODO: We should probably grab this from ~allocation_type=tree_ans.comp_allocation_type, - ~allocation_type=Unmanaged(WasmI32), + ~allocation_type=allocation_type^, match_cond_id, cases, Total,