Skip to content

Commit

Permalink
Remove SubE in interpreter backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinWonho committed Feb 22, 2024
1 parent a9e3639 commit 4308124
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spectec/src/il2al/translate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,20 @@ let translate_helper partial_funcs def =
let name = id.it in
let unified_clauses = Il2il.unify_defs clauses in
let Il.DefD (_, args, _, _) = List.hd unified_clauses |> it in
let params' = translate_args args in
let params =
args
|> translate_args
|> List.map
Walk.(walk_expr { default_config with pre_expr = Transpile.remove_sub })
in
let blocks = List.map (translate_helper_body name) unified_clauses in
let body =
blocks
|> Transpile.merge_blocks
|> Transpile.enhance_readability
|> if List.mem id partial_funcs then Fun.id else Transpile.ensure_return in

Some (FuncA (name, params', body))
Some (FuncA (name, params, body))
| _ -> None


Expand Down Expand Up @@ -920,13 +925,19 @@ and translate_rgroup (instr_name, rgroup) =
get_params winstr |> List.map translate_exp
| Some params -> params
in
(* TODO: refactor transpiles *)
let al_params' =
List.map
Walk.(walk_expr { default_config with pre_expr = Transpile.remove_sub })
al_params
in
let body =
state_instr @ instrs
|> insert_nop
|> Transpile.enhance_readability
|> Transpile.infer_assert
in
RuleA (kwd, al_params, body)
RuleA (kwd, al_params', body)


let rule_to_tup rule =
Expand Down
1 change: 1 addition & 0 deletions spectec/src/il2al/transpile.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ val push_either :instr -> instr list
val simplify_record_concat : expr -> expr
val enhance_readability : instr list -> instr list
val remove_state : algorithm -> algorithm
val remove_sub : expr -> expr
val infer_assert : instr list -> instr list
val ensure_return : instr list -> instr list

0 comments on commit 4308124

Please sign in to comment.