let crosscond_to_pred inv cross op_logic_var status_logic_var =
let rec convert : Promelaast.condition -> Bool3.t * Cil_types.predicate =
function
| POr (c1, c2) ->
begin
let (c1_val,c1_pred) = convert c1 in
match c1_val with
| Bool3.True -> (c1_val,c1_pred)
| Bool3.False -> convert c2
| Undefined ->
let (c2_val,c2_pred) = convert c2 in
match c2_val with
| Bool3.True -> (c2_val,c2_pred)
| Bool3.False -> (c1_val,c1_pred)
| Undefined -> (Undefined,Por(unamed c1_pred, unamed c2_pred))
end
| PAnd (c1, c2) ->
begin
let (c1_val,c1_pred) = convert c1 in
match c1_val with
| Bool3.True -> convert c2
| Bool3.False -> (c1_val,c1_pred)
| Undefined ->
let (c2_val,c2_pred) = convert c2 in
match c2_val with
| Bool3.True -> (c1_val,c1_pred)
| Bool3.False -> (c2_val,c2_pred)
| Undefined -> (Undefined,Pand(unamed c1_pred, unamed c2_pred))
end
| PNot (c1) ->
begin
let (c1_val,c1_pred) = convert c1 in
match c1_val with
| Bool3.True -> (Bool3.False,Pfalse)
| Bool3.False -> (Bool3.True,Ptrue)
| Undefined -> (c1_val,Pnot(unamed c1_pred))
end
| PFuncParam (_, s, _)
| PCall (s) when inv ->
(Undefined,
Pand(
unamed(
Prel(Req,
Logic_const.term
(TLval(TVar(op_logic_var),TNoOffset)) (Ctype Cil.intType),
Logic_const.term (TConst(func_to_cenum s))
(Ctype Cil.intType)
)
),
unamed (
Prel(Req,
Logic_const.term
(TLval(TVar(status_logic_var),TNoOffset))
(Ctype Cil.intType),
Logic_const.term
(TConst(op_status_to_cenum Promelaast.Call))
(Ctype Cil.intType)
)
)
)
)
| PFuncReturn (_, s) when inv ->
(Undefined,
Pand(
unamed(
Prel(Req,
Logic_const.term
(TLval(TVar(op_logic_var),TNoOffset)) (Ctype Cil.intType),
Logic_const.term (TConst(func_to_cenum s)) (Ctype Cil.intType)
)
),
unamed (
Prel(Req,
Logic_const.term
(TLval(TVar(status_logic_var),TNoOffset))
(Ctype Cil.intType),
Logic_const.term
(TConst(op_status_to_cenum Promelaast.Return))
(Ctype Cil.intType)
)
)
)
)
| PReturn (s) when inv ->
(Undefined,
Pand(
unamed(
Prel(Req,
Logic_const.term
(TLval(TVar(op_logic_var),TNoOffset))
(Ctype Cil.intType),
Logic_const.term
(TConst(func_to_cenum s))
(Ctype Cil.intType)
)
),
unamed (
Prel(Req,
Logic_const.term
(TLval(TVar(status_logic_var),TNoOffset))
(Ctype Cil.intType),
Logic_const.term
(TConst(op_status_to_cenum Promelaast.Return))
(Ctype Cil.intType)
)
)
)
)
| PCallOrReturn (s) when inv ->
(Undefined,
Prel(Req,
Logic_const.term
(TLval(TVar(op_logic_var),TNoOffset)) (Ctype Cil.intType),
Logic_const.term (TConst(func_to_cenum s))
(Ctype Cil.intType)
)
)
| PFuncParam (hash, _, _) ->
(Undefined, get_pred_from_tmpident hash)
| PFuncReturn (hash, f) ->
let vi = (get_returninfo f) in
(Undefined,
Cil_manipulation.predicate_substitution
(get_pred_from_tmpident hash)
[vi.vname]
[TResult (vi.vtype)])
| PCall (_)
| PReturn (_)
| PCallOrReturn (_) ->
(Bool3.True, Ptrue)
| PTrue -> (Bool3.True, Ptrue)
| PFalse -> (Bool3.False, Pfalse)
| PIndexedExp(s) -> (Undefined,get_pred_from_tmpident s)
in
try
let (_,res) = convert cross in
res
with
| _ ->
Aorai_option.fatal "Aorai plugin internal error. Status : Not_found exception during term conversion.\n"