-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMV: set pretty names for top-level identifiers
Identifiers in module main now no longer carry the prefix main::var::.
- Loading branch information
Showing
20 changed files
with
87 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,23 @@ Author: Daniel Kroening, [email protected] | |
\*******************************************************************/ | ||
|
||
#include <cstring> | ||
//#include <cstring> | ||
|
||
#include "expr2smv.h" | ||
|
||
#include <util/lispexpr.h> | ||
#include <util/lispirep.h> | ||
#include <util/namespace.h> | ||
#include <util/std_expr.h> | ||
|
||
#include "expr2smv.h" | ||
#include <util/symbol.h> | ||
|
||
class expr2smvt | ||
{ | ||
public: | ||
explicit expr2smvt(const namespacet &__ns) : ns(__ns) | ||
{ | ||
} | ||
|
||
bool convert_nondet_choice(const exprt &src, std::string &dest, unsigned precedence); | ||
|
||
bool convert_binary(const exprt &src, std::string &dest, const std::string &symbol, unsigned precedence); | ||
|
@@ -34,7 +40,8 @@ class expr2smvt | |
|
||
bool convert(const exprt &src, std::string &dest); | ||
|
||
bool convert_symbol(const exprt &src, std::string &dest, unsigned &precedence); | ||
bool | ||
convert_symbol(const symbol_exprt &, std::string &dest, unsigned &precedence); | ||
|
||
bool convert_next_symbol(const exprt &src, std::string &dest, unsigned &precedence); | ||
|
||
|
@@ -45,6 +52,9 @@ class expr2smvt | |
bool convert_norep(const exprt &src, std::string &dest, unsigned &precedence); | ||
|
||
bool convert(const typet &src, std::string &dest); | ||
|
||
protected: | ||
const namespacet &ns; | ||
}; | ||
|
||
/* | ||
|
@@ -312,15 +322,15 @@ Function: expr2smvt::convert_symbol | |
\*******************************************************************/ | ||
|
||
bool expr2smvt::convert_symbol( | ||
const exprt &src, | ||
const symbol_exprt &src, | ||
std::string &dest, | ||
unsigned &precedence) | ||
{ | ||
precedence=SMV_MAX_PRECEDENCE; | ||
dest=src.get_string(ID_identifier); | ||
|
||
if(strncmp(dest.c_str(), "smv::", 5)==0) | ||
dest.erase(0, 5); | ||
|
||
auto &symbol = ns.lookup(src); | ||
|
||
dest = id2string(symbol.display_name()); | ||
|
||
return false; | ||
} | ||
|
@@ -343,7 +353,8 @@ bool expr2smvt::convert_next_symbol( | |
unsigned &precedence) | ||
{ | ||
std::string tmp; | ||
convert_symbol(src, tmp, precedence); | ||
convert_symbol( | ||
symbol_exprt{src.get(ID_identifier), src.type()}, tmp, precedence); | ||
|
||
dest="next("+tmp+")"; | ||
|
||
|
@@ -468,7 +479,7 @@ bool expr2smvt::convert( | |
to_unary_expr(src), dest, src.id_string() + " ", precedence = 7); | ||
|
||
else if(src.id()==ID_symbol) | ||
return convert_symbol(src, dest, precedence); | ||
return convert_symbol(to_symbol_expr(src), dest, precedence); | ||
|
||
else if(src.id()==ID_next_symbol) | ||
return convert_next_symbol(src, dest, precedence); | ||
|
@@ -527,9 +538,9 @@ Function: expr2smv | |
\*******************************************************************/ | ||
|
||
bool expr2smv(const exprt &expr, std::string &code) | ||
bool expr2smv(const exprt &expr, std::string &code, const namespacet &ns) | ||
{ | ||
expr2smvt expr2smv; | ||
expr2smvt expr2smv(ns); | ||
return expr2smv.convert(expr, code); | ||
} | ||
|
||
|
@@ -545,14 +556,14 @@ Function: type2smv | |
\*******************************************************************/ | ||
|
||
bool type2smv(const typet &type, std::string &code) | ||
bool type2smv(const typet &type, std::string &code, const namespacet &ns) | ||
{ | ||
if(type.id()==ID_bool) | ||
code="boolean"; | ||
else if(type.id()==ID_array) | ||
{ | ||
std::string tmp; | ||
if(type2smv(to_array_type(type).element_type(), tmp)) | ||
if(type2smv(to_array_type(type).element_type(), tmp, ns)) | ||
return true; | ||
code="array "; | ||
code+=".."; | ||
|
@@ -587,7 +598,7 @@ bool type2smv(const typet &type, std::string &code) | |
{ | ||
if(first) first=false; else code+=", "; | ||
std::string tmp; | ||
expr2smv(*it, tmp); | ||
expr2smv(*it, tmp, ns); | ||
code+=tmp; | ||
} | ||
code+=')'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/expr.h> | ||
|
||
bool expr2smv(const exprt &expr, std::string &code); | ||
bool type2smv(const typet &type, std::string &code); | ||
|
||
bool expr2smv(const exprt &, std::string &code, const namespacet &); | ||
bool type2smv(const typet &, std::string &code, const namespacet &); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,14 @@ Author: Daniel Kroening, [email protected] | |
\*******************************************************************/ | ||
|
||
#include "smv_language.h" | ||
#include "smv_typecheck.h" | ||
#include "smv_parser.h" | ||
#include "expr2smv.h" | ||
|
||
#include <util/namespace.h> | ||
#include <util/symbol_table.h> | ||
|
||
#include "expr2smv.h" | ||
#include "smv_parser.h" | ||
#include "smv_typecheck.h" | ||
|
||
/*******************************************************************\ | ||
Function: smv_languaget::parse | ||
|
@@ -153,7 +155,9 @@ void smv_languaget::show_parse(std::ostream &out, message_handlert &) | |
if(it->second.type.id()!="submodule") | ||
{ | ||
std::string msg; | ||
type2smv(it->second.type, msg); | ||
symbol_tablet symbol_table; | ||
namespacet ns(symbol_table); | ||
type2smv(it->second.type, msg, ns); | ||
out << " " << it->first << ": " | ||
<< msg << ";" << std::endl; | ||
} | ||
|
@@ -168,7 +172,9 @@ void smv_languaget::show_parse(std::ostream &out, message_handlert &) | |
if(it->second.type.id()=="submodule") | ||
{ | ||
std::string msg; | ||
type2smv(it->second.type, msg); | ||
symbol_tablet symbol_table; | ||
namespacet ns(symbol_table); | ||
type2smv(it->second.type, msg, ns); | ||
out << " " << it->first << ": " | ||
<< msg << ";" << std::endl; | ||
} | ||
|
@@ -201,7 +207,7 @@ Function: smv_languaget::from_expr | |
bool smv_languaget::from_expr(const exprt &expr, std::string &code, | ||
const namespacet &ns) | ||
{ | ||
return expr2smv(expr, code); | ||
return expr2smv(expr, code, ns); | ||
} | ||
|
||
/*******************************************************************\ | ||
|
@@ -221,7 +227,7 @@ bool smv_languaget::from_type( | |
std::string &code, | ||
const namespacet &ns) | ||
{ | ||
return type2smv(type, code); | ||
return type2smv(type, code, ns); | ||
} | ||
|
||
/*******************************************************************\ | ||
|
Oops, something went wrong.