Simplify a bit
This commit is contained in:
parent
d947f3b462
commit
c5361c57d4
@ -800,26 +800,18 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu
|
|||||||
| SetPatch patch -> (
|
| SetPatch patch -> (
|
||||||
let (setp, loc) = r_split patch in
|
let (setp, loc) = r_split patch in
|
||||||
let (name , access_path) = simpl_path setp.path in
|
let (name , access_path) = simpl_path setp.path in
|
||||||
let%bind inj = bind_list
|
let%bind inj =
|
||||||
@@ List.map (fun (x:Raw.expr) ->
|
bind_list @@
|
||||||
let%bind e = simpl_expression x
|
List.map simpl_expression @@
|
||||||
in ok e)
|
pseq_to_list setp.set_inj.value.elements in
|
||||||
@@ pseq_to_list setp.set_inj.value.elements in
|
let expr =
|
||||||
let%bind expr =
|
|
||||||
let rec chain_add = fun lst s : expression ->
|
|
||||||
match lst with
|
|
||||||
| [] -> s
|
|
||||||
| hd :: tl -> chain_add tl (e_constant "SET_ADD" [hd ; s]) in
|
|
||||||
let assigns =
|
|
||||||
match inj with
|
match inj with
|
||||||
| [] -> e_skip ~loc ()
|
| [] -> e_skip ~loc ()
|
||||||
| _ :: _ -> chain_add inj (e_variable name) in
|
| _ :: _ ->
|
||||||
match assigns with
|
let assigns = List.fold_right
|
||||||
| {expression = E_skip; _} -> ok @@ e_skip ~loc ()
|
(fun hd s -> e_constant "SET_ADD" [hd ; s])
|
||||||
| {expression = E_constant e; location = loc} ->
|
inj (e_variable name) in
|
||||||
ok @@ e_assign name access_path {expression = (E_constant e); location = loc}
|
e_assign ~loc name access_path assigns in
|
||||||
| _ -> fail @@ corner_case ~loc:__LOC__ "Unexpected expression type"
|
|
||||||
in
|
|
||||||
return_statement @@ expr
|
return_statement @@ expr
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user