Skip to content

Commit f989306

Browse files
committed
SMV: set type
NuSMV 2.7 distinguishes four set types; this introduces a class for these.
1 parent d25b571 commit f989306

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

src/smvlang/smv_typecheck.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,16 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode, bool next)
15331533
for(auto &op : expr.operands())
15341534
typecheck_expr_rec(op, mode, next);
15351535
}
1536+
else if(expr.id() == ID_smv_union)
1537+
{
1538+
auto &lhs = to_binary_expr(expr).lhs();
1539+
auto &rhs = to_binary_expr(expr).rhs();
1540+
1541+
typecheck_expr_rec(lhs, mode, next);
1542+
typecheck_expr_rec(rhs, mode, next);
1543+
1544+
expr.type() = smv_set_typet{smv_enumeration_typet{}};
1545+
}
15361546
else
15371547
{
15381548
throw errort().with_location(expr.find_source_location())
@@ -1959,8 +1969,7 @@ void smv_typecheckt::convert(exprt &expr)
19591969
throw errort().with_location(expr.source_location())
19601970
<< "no support for self";
19611971
}
1962-
else if(expr.id()=="smv_nondet_choice" ||
1963-
expr.id()=="smv_union")
1972+
else if(expr.id() == "smv_nondet_choice")
19641973
{
19651974
if(expr.operands().size()==0)
19661975
{

src/smvlang/smv_types.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,42 @@ inline smv_enumeration_typet &to_smv_enumeration_type(typet &type)
7272
return static_cast<smv_enumeration_typet &>(type);
7373
}
7474

75+
/// The SMV set type -- NuSMV distinguishes the boolean set, the integer set,
76+
/// the symbolic set, and the integers-and-symbolic set.
77+
class smv_set_typet : public type_with_subtypet
78+
{
79+
public:
80+
explicit smv_set_typet(typet subtype)
81+
: type_with_subtypet(ID_smv_set, std::move(subtype))
82+
{
83+
}
84+
};
85+
86+
/*! \brief Cast a generic typet to a \ref smv_set_typet
87+
*
88+
* This is an unchecked conversion. \a type must be known to be \ref
89+
* smv_set_typet.
90+
*
91+
* \param type Source type
92+
* \return Object of type \ref smv_set_typet
93+
*
94+
* \ingroup gr_std_types
95+
*/
96+
inline const smv_set_typet &to_smv_set_type(const typet &type)
97+
{
98+
PRECONDITION(type.id() == ID_smv_set);
99+
return static_cast<const smv_set_typet &>(type);
100+
}
101+
102+
/*! \copydoc to_smv_set_type(const typet &)
103+
* \ingroup gr_std_types
104+
*/
105+
inline smv_set_typet &to_smv_set_type(typet &type)
106+
{
107+
PRECONDITION(type.id() == ID_smv_set);
108+
return static_cast<smv_set_typet &>(type);
109+
}
110+
75111
/// The type used for VAR declarations that are in fact module instantiations
76112
class smv_module_instance_typet : public typet
77113
{

0 commit comments

Comments
 (0)