From 30f2581f8b62cc7e736fd1aa53227c678164aa57 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Wulfman Date: Thu, 23 Apr 2020 17:53:10 +0200 Subject: [PATCH] done --- .../2-concrete_to_imperative/cameligo.ml | 2 +- .../2-concrete_to_imperative/pascaligo.ml | 4 ++-- .../imperative_to_sugar.ml | 20 +++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/passes/2-concrete_to_imperative/cameligo.ml b/src/passes/2-concrete_to_imperative/cameligo.ml index a0a8a55bd..c294e5eb8 100644 --- a/src/passes/2-concrete_to_imperative/cameligo.ml +++ b/src/passes/2-concrete_to_imperative/cameligo.ml @@ -649,7 +649,7 @@ let rec compile_expression : let%bind expr = compile_expression c.test in let%bind match_true = compile_expression c.ifso in let%bind match_false = compile_expression c.ifnot in - return @@ e_matching ~loc expr (Match_bool {match_true; match_false}) + return @@ e_cond ~loc expr match_true match_false ) and compile_fun lamb' : expr result = diff --git a/src/passes/2-concrete_to_imperative/pascaligo.ml b/src/passes/2-concrete_to_imperative/pascaligo.ml index 88127fc9c..ec0a7256a 100644 --- a/src/passes/2-concrete_to_imperative/pascaligo.ml +++ b/src/passes/2-concrete_to_imperative/pascaligo.ml @@ -398,7 +398,7 @@ let rec compile_expression (t:Raw.expr) : expr result = let%bind expr = compile_expression c.test in let%bind match_true = compile_expression c.ifso in let%bind match_false = compile_expression c.ifnot in - return @@ e_matching expr ~loc (Match_bool {match_true; match_false}) + return @@ e_cond ~loc expr match_true match_false | ECase c -> ( let (c , loc) = r_split c in @@ -860,7 +860,7 @@ and compile_single_instruction : Raw.instruction -> (_ -> expression result) res let%bind match_true = match_true None in let%bind match_false = match_false None in - return_statement @@ e_matching expr ~loc (Match_bool {match_true; match_false}) + return_statement @@ e_cond ~loc expr match_true match_false ) | Assign a -> ( let (a , loc) = r_split a in diff --git a/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml b/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml index 055f53ed4..359a3bb61 100644 --- a/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml +++ b/src/passes/4-imperative_to_sugar/imperative_to_sugar.ml @@ -52,8 +52,16 @@ let repair_mutable_variable_in_matching (match_body : O.expression) (element_nam | E_constant {cons_name=C_MAP_FOLD;arguments= _} | E_constant {cons_name=C_SET_FOLD;arguments= _} | E_constant {cons_name=C_LIST_FOLD;arguments= _} + | E_cond _ | E_matching _ -> ok @@ (false, (decl_var,free_var),ass_exp) - | _ -> ok (true, (decl_var, free_var),ass_exp) + | E_constant _ + | E_skip + | E_literal _ | E_variable _ + | E_application _ | E_lambda _| E_recursive _ + | E_constructor _ | E_record _| E_record_accessor _|E_record_update _ + | E_ascription _ | E_sequence _ | E_tuple _ | E_tuple_accessor _ | E_tuple_update _ + | E_map _ | E_big_map _ |E_list _ | E_set _ |E_look_up _ + -> ok (true, (decl_var, free_var),ass_exp) ) (element_names,[]) match_body in @@ -88,8 +96,16 @@ and repair_mutable_variable_in_loops (for_body : O.expression) (element_names : | E_constant {cons_name=C_MAP_FOLD;arguments= _} | E_constant {cons_name=C_SET_FOLD;arguments= _} | E_constant {cons_name=C_LIST_FOLD;arguments= _} + | E_cond _ | E_matching _ -> ok @@ (false,(decl_var,free_var),ass_exp) - | _ -> ok (true,(decl_var, free_var),ass_exp) + | E_constant _ + | E_skip + | E_literal _ | E_variable _ + | E_application _ | E_lambda _| E_recursive _ + | E_constructor _ | E_record _| E_record_accessor _|E_record_update _ + | E_ascription _ | E_sequence _ | E_tuple _ | E_tuple_accessor _ | E_tuple_update _ + | E_map _ | E_big_map _ |E_list _ | E_set _ |E_look_up _ + -> ok (true, (decl_var, free_var),ass_exp) ) (element_names,[]) for_body in