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 =
|
match inj with
|
||||||
let rec chain_add = fun lst s : expression ->
|
| [] -> e_skip ~loc ()
|
||||||
match lst with
|
| _ :: _ ->
|
||||||
| [] -> s
|
let assigns = List.fold_right
|
||||||
| hd :: tl -> chain_add tl (e_constant "SET_ADD" [hd ; s]) in
|
(fun hd s -> e_constant "SET_ADD" [hd ; s])
|
||||||
let assigns =
|
inj (e_variable name) in
|
||||||
match inj with
|
e_assign ~loc name access_path assigns in
|
||||||
| [] -> e_skip ~loc ()
|
|
||||||
| _ :: _ -> chain_add inj (e_variable name) in
|
|
||||||
match assigns with
|
|
||||||
| {expression = E_skip; _} -> ok @@ e_skip ~loc ()
|
|
||||||
| {expression = E_constant e; location = loc} ->
|
|
||||||
ok @@ e_assign name access_path {expression = (E_constant e); location = loc}
|
|
||||||
| _ -> fail @@ corner_case ~loc:__LOC__ "Unexpected expression type"
|
|
||||||
in
|
|
||||||
return_statement @@ expr
|
return_statement @@ expr
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user