Commit 40e467c3 authored by clean's avatar clean
Browse files

fix another bug in boolean cases that may fail

parent df4792dc
......@@ -707,16 +707,12 @@ where
*/
// convert_boolean_case_into_guard bound_vars group_index common_defs default_ptr guard [ alt : alts ] case_default case_info_ptr ci
convert_boolean_case_into_guard bound_vars group_index common_defs has_default guard [ alt : alts ] case_default case_info_ptr ci
convert_boolean_case_into_guard bound_vars group_index common_defs has_default guard [ alt=:{bp_value=BVB sign_of_then_part,bp_expr} : alts ] case_default case_info_ptr ci
# (guard, ci) = convertRootExpression bound_vars group_index common_defs cHasNoDefault guard ci
/* JVG: changed 13-6-2000
# (sign_of_then_part, then_part, ci) = convert_boolean_guard bound_vars group_index common_defs alt ci
(opt_else_part, ci) = convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part alts case_default ci
*/
# sign_of_then_part = case alt of ({bp_value=BVB bool}) -> bool
# (opt_else_part, ci) = convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part alts case_default ci
# (sign_of_then_part, then_part, ci) = convert_boolean_case_then_part bound_vars group_index common_defs default_ptr alt opt_else_part has_default ci
/**/
# (EI_CaseTypeAndRefCounts case_type _, ci_expr_heap) = readPtr case_info_ptr ci.ci_expr_heap
# (default_ptr, ci_expr_heap) = makePtrToDefault case_default case_type.ct_result_type has_default ci_expr_heap
# (then_part, ci) = convertRootExpression bound_vars group_index common_defs default_ptr bp_expr {ci &ci_expr_heap=ci_expr_heap}
# (opt_else_part, ci) = convert_to_else_part bound_vars group_index common_defs default_ptr sign_of_then_part alts case_default ci
// = (Conditional { if_cond = { con_positive = sign_of_then_part, con_expression = guard }, if_then = then_part, if_else = opt_else_part }, ci)
= (build_conditional sign_of_then_part guard then_part opt_else_part, ci)
where
......@@ -726,28 +722,18 @@ where
= Conditional { if_cond = guard, if_then = else_expr, if_else = Yes then_expr }
build_conditional false guard then_expr No
= Conditional { if_cond = Conditional { if_cond = guard, if_then = BasicExpr (BVB False) BT_Bool, if_else = Yes (BasicExpr (BVB True) BT_Bool) },
if_then = then_expr, if_else = No }
convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part [ alt : alts ] case_default ci
# (sign_of_else_part, else_part, ci) = convert_boolean_guard bound_vars group_index common_defs alt ci
| sign_of_then_part == sign_of_else_part
= convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part alts case_default ci
if_then = then_expr, if_else = No }
convert_to_else_part bound_vars group_index common_defs default_ptr sign_of_then_part [ alt=:{bp_value=BVB sign_of_else_part,bp_expr} : alts ] case_default ci
# (else_part, ci) = convertRootExpression bound_vars group_index common_defs default_ptr bp_expr ci
| sign_of_then_part == sign_of_else_part
= convert_to_else_part bound_vars group_index common_defs default_ptr sign_of_then_part alts case_default ci
= (Yes else_part, ci)
convert_to_else_part bound_vars group_index common_defs default_ptr sign_of_then_part [ ] (Yes else_part) ci
# (else_part, ci) = convertRootExpression bound_vars group_index common_defs has_default else_part ci
= (Yes else_part, ci)
convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part [ ] (Yes else_part) ci
# (else_part, ci) = convertRootExpression bound_vars group_index common_defs has_default else_part ci
= (Yes else_part, ci)
convert_to_else_part bound_vars group_index common_defs has_default sign_of_then_part [ ] No ci
= (No, ci)
convert_boolean_guard bound_vars group_index common_defs {bp_value=BVB bool,bp_expr} ci
# (bp_expr, ci) = convertRootExpression bound_vars group_index common_defs cHasNoDefault bp_expr ci
= (bool, bp_expr, ci)
convert_boolean_case_then_part bound_vars group_index common_defs default_ptr {bp_value=BVB bool,bp_expr} opt_else_part has_default ci=:{ci_expr_heap}
# (EI_CaseTypeAndRefCounts case_type _, ci_expr_heap) = readPtr case_info_ptr ci_expr_heap
# (default_ptr, ci_expr_heap) = makePtrToDefault opt_else_part case_type.ct_result_type has_default ci_expr_heap
# (bp_expr, ci) = convertRootExpression bound_vars group_index common_defs default_ptr bp_expr {ci & ci_expr_heap=ci_expr_heap}
= (bool, bp_expr, ci)
convert_to_else_part bound_vars group_index common_defs default_ptr sign_of_then_part [ ] No ci
= (No, ci)
convertRootExpression bound_vars group_index common_defs _ expr ci
= convertCases bound_vars group_index common_defs expr ci
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment