Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# EBMC 5.9

* SMV: word constants
* SMV: IVAR declarations

# EBMC 5.8

Expand Down
9 changes: 6 additions & 3 deletions regression/smv/ivar/ivar1.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
CORE
ivar1.smv

^file .* line 3: No support for IVAR declarations$
^EXIT=1$
--bound 1
^\[.*\] some_input: REFUTED$
^\[.*\] !some_input: REFUTED$
^\[.*\] X some_input: REFUTED$
^\[.*\] X !some_input: REFUTED$
^EXIT=10$
^SIGNAL=0$
--
--
6 changes: 6 additions & 0 deletions regression/smv/ivar/ivar1.smv
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
MODULE main

IVAR some_input : boolean;

-- these should all fail
LTLSPEC some_input
LTLSPEC !some_input
LTLSPEC X some_input
LTLSPEC X !some_input
19 changes: 16 additions & 3 deletions src/smvlang/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,23 @@ var_declaration:
;

ivar_declaration:
IVAR_Token simple_var_list
IVAR_Token ivar_simple_var_list
;

ivar_simple_var_list:
identifier ':' simple_type_specifier ';'
{
yyerror("No support for IVAR declarations");
YYERROR;
irep_idt identifier = stack_expr($1).id();
stack_expr($1).id(ID_smv_identifier);
stack_expr($1).set(ID_identifier, identifier);
PARSER.module->add_ivar(stack_expr($1), stack_type($3));
}
| ivar_simple_var_list identifier ':' simple_type_specifier ';'
{
irep_idt identifier = stack_expr($2).id();
stack_expr($2).id(ID_smv_identifier);
stack_expr($2).set(ID_identifier, identifier);
PARSER.module->add_ivar(stack_expr($2), stack_type($4));
}
;

Expand Down
2 changes: 2 additions & 0 deletions src/smvlang/smv_parse_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ std::string to_string(smv_parse_treet::modulet::itemt::item_typet i)
return "DEFINE";
case smv_parse_treet::modulet::itemt::ENUM:
return "ENUM";
case smv_parse_treet::modulet::itemt::IVAR:
return "IVAR";
case smv_parse_treet::modulet::itemt::VAR:
return "VAR";

Expand Down
13 changes: 13 additions & 0 deletions src/smvlang/smv_parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class smv_parse_treet
FAIRNESS,
INIT,
INVAR,
IVAR,
LTLSPEC,
TRANS,
VAR
Expand Down Expand Up @@ -133,6 +134,11 @@ class smv_parse_treet
return item_type == ENUM;
}

bool is_ivar() const
{
return item_type == IVAR;
}

bool is_var() const
{
return item_type == VAR;
Expand Down Expand Up @@ -260,6 +266,13 @@ class smv_parse_treet
items.emplace_back(itemt::TRANS, std::move(expr), std::move(location));
}

void add_ivar(exprt expr, typet type)
{
expr.type() = std::move(type);
auto location = expr.source_location();
items.emplace_back(itemt::IVAR, std::move(expr), std::move(location));
}

void add_var(exprt expr, typet type)
{
expr.type() = std::move(type);
Expand Down
5 changes: 3 additions & 2 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,7 @@ void smv_typecheckt::typecheck(
return;

case smv_parse_treet::modulet::itemt::ENUM:
case smv_parse_treet::modulet::itemt::IVAR:
case smv_parse_treet::modulet::itemt::VAR:
return;
}
Expand Down Expand Up @@ -2075,7 +2076,7 @@ void smv_typecheckt::create_var_symbols(

for(const auto &item : items)
{
if(item.is_var())
if(item.is_var() || item.is_ivar())
{
irep_idt base_name = to_smv_identifier_expr(item.expr).identifier();
irep_idt identifier = module + "::var::" + id2string(base_name);
Expand Down Expand Up @@ -2318,7 +2319,7 @@ void smv_typecheckt::convert(smv_parse_treet::modulet &smv_module)

// non-variable items
for(auto &item : smv_module.items)
if(!item.is_var())
if(!item.is_var() && !item.is_ivar())
convert(item);

flatten_hierarchy(smv_module);
Expand Down
Loading