some cleaning
This commit is contained in:
parent
1d3d57c7c5
commit
536b5648c8
@ -969,12 +969,12 @@ and simpl_block : Raw.block -> (_ -> expression result) result = fun t ->
|
||||
|
||||
and simpl_for_int : Raw.for_int -> (_ -> expression result) result = fun fi ->
|
||||
(* cond part *)
|
||||
let%bind var = ok @@ e_variable fi.assign.value.name.value in
|
||||
let var = e_variable fi.assign.value.name.value in
|
||||
let%bind value = simpl_expression fi.assign.value.expr in
|
||||
let%bind bound = simpl_expression fi.bound in
|
||||
let%bind comp = match fi.down with
|
||||
| Some _ -> ok @@ e_annotation (e_constant "GE" [var ; bound]) t_bool
|
||||
| None -> ok @@ e_annotation (e_constant "LE" [var ; bound]) t_bool
|
||||
let comp = match fi.down with
|
||||
| Some _ -> e_annotation (e_constant "GE" [var ; bound]) t_bool
|
||||
| None -> e_annotation (e_constant "LE" [var ; bound]) t_bool
|
||||
in
|
||||
(* body part *)
|
||||
let%bind body = simpl_block fi.block.value in
|
||||
@ -982,32 +982,29 @@ and simpl_for_int : Raw.for_int -> (_ -> expression result) result = fun fi ->
|
||||
let%bind step = match fi.step with
|
||||
| Some (_,e) -> simpl_expression e
|
||||
| None -> ok (e_int 1) in
|
||||
let%bind ctrl = match fi.down with
|
||||
let ctrl = match fi.down with
|
||||
| Some _ ->
|
||||
let%bind _addi = ok @@ e_constant "SUB" [ var ; step ] in
|
||||
ok @@ e_assign fi.assign.value.name.value [] _addi
|
||||
let _addi = e_constant "SUB" [ var ; step ] in
|
||||
e_assign fi.assign.value.name.value [] _addi
|
||||
| None ->
|
||||
let%bind _subi = ok @@ e_constant "ADD" [ var ; step ] in
|
||||
ok @@ e_assign fi.assign.value.name.value [] _subi
|
||||
let _subi = e_constant "ADD" [ var ; step ] in
|
||||
e_assign fi.assign.value.name.value [] _subi
|
||||
in
|
||||
let rec add_to_seq expr = match expr.expression with
|
||||
| E_sequence (_,a) -> add_to_seq a
|
||||
| _ -> e_sequence body ctrl in
|
||||
let%bind body' = ok @@ add_to_seq body in
|
||||
let%bind loop = ok @@ e_loop comp body' in
|
||||
let body' = add_to_seq body in
|
||||
let loop = e_loop comp body' in
|
||||
return_statement @@ e_let_in (fi.assign.value.name.value, Some t_int) value loop
|
||||
|
||||
and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun fc ->
|
||||
let%bind col = simpl_expression fc.expr in
|
||||
|
||||
let%bind body = simpl_block fc.block.value in
|
||||
let%bind body = body None in
|
||||
|
||||
let%bind invar = ok @@ e_variable fc.var.value in
|
||||
let%bind letin = ok @@ e_let_in (fc.var.value, None) invar body in
|
||||
let%bind lambda = ok @@ e_lambda fc.var.value None (Some t_unit) letin in
|
||||
let invar = e_variable fc.var.value in
|
||||
let letin = e_let_in (fc.var.value, None) invar body in
|
||||
let lambda = e_lambda fc.var.value None (Some t_unit) letin in
|
||||
(* let%bind lambda = ok @@ e_lambda fc.var.value None (Some t_unit) body in *)
|
||||
|
||||
return_statement @@ e_constant "SET_ITER" [col ; lambda]
|
||||
|
||||
let simpl_program : Raw.ast -> program result = fun t ->
|
||||
|
Loading…
Reference in New Issue
Block a user