/* If for some reason the variable being created here is
* already declared by the user then the printed output will
* not be a legal input to the system. too bad. I refuse to
- * check for this. [Vijay is the author of this comment.]
+ * check for this.
*/
-
bm->NodeLetVarMap[ccc] = CurrentSymbol;
std::pair<ASTNode, ASTNode> node_letvar_pair(CurrentSymbol, ccc);
bm->NodeLetVarVec.push_back(node_letvar_pair);
return true;
}
+ // Create and return an ASTNode for a term
+ ASTNode BeevMgr::CreateTerm(Kind kind,
+ unsigned int width,
+ const ASTVec &children)
+ {
+ if (!is_Term_kind(kind))
+ FatalError("CreateTerm: Illegal kind to CreateTerm:",
+ ASTUndefined, kind);
+ ASTNode n = CreateNode(kind, children);
+ n.SetValueWidth(width);
+
+ //by default we assume that the term is a Bitvector. If
+ //necessary the indexwidth can be changed later
+ n.SetIndexWidth(0);
+ return n;
+ }
+
+ ASTNode BeevMgr::CreateTerm(Kind kind,
+ unsigned int width,
+ const ASTNode& child0,
+ const ASTVec &children)
+ {
+ if (!is_Term_kind(kind))
+ FatalError("CreateTerm: Illegal kind to CreateTerm:", ASTUndefined, kind);
+ ASTNode n = CreateNode(kind, child0, children);
+ n.SetValueWidth(width);
+ return n;
+ }
+
+ ASTNode BeevMgr::CreateTerm(Kind kind,
+ unsigned int width,
+ const ASTNode& child0,
+ const ASTNode& child1,
+ const ASTVec &children)
+ {
+ if (!is_Term_kind(kind))
+ FatalError("CreateTerm: Illegal kind to CreateTerm:", ASTUndefined, kind);
+ ASTNode n = CreateNode(kind, child0, child1, children);
+ n.SetValueWidth(width);
+ return n;
+ }
+
+ ASTNode BeevMgr::CreateTerm(Kind kind,
+ unsigned int width,
+ const ASTNode& child0,
+ const ASTNode& child1,
+ const ASTNode& child2,
+ const ASTVec &children)
+ {
+ if (!is_Term_kind(kind))
+ FatalError("CreateTerm: Illegal kind to CreateTerm:", ASTUndefined, kind);
+ ASTNode n = CreateNode(kind, child0, child1, child2, children);
+ n.SetValueWidth(width);
+ return n;
+ }
+
+
////////////////////////////////////////////////////////////////
//
// IO manipulators for Lisp format printing of AST.
_arrayread_ite.clear();
_arrayread_symbol.clear();
_introduced_symbols.clear();
- //TransformMap.clear();
- _letid_expr_map->clear();
CounterExampleMap.clear();
ComputeFormulaMap.clear();
StatInfoSet.clear();
_arrayread_ite.clear();
_arrayread_symbol.clear();
_introduced_symbols.clear();
- _letid_expr_map->clear();
CounterExampleMap.clear();
ComputeFormulaMap.clear();
StatInfoSet.clear();
delete SimplifyMap;
delete SimplifyNegMap;
- delete _letid_expr_map;
delete ReferenceCount;
}
// Check valuesize to see if it's a prop var. I don't like doing
// type determination in the lexer, but it's easier than rewriting
// the whole grammar to eliminate the term/formula distinction.
- cvclval.node = new BEEV::ASTNode(BEEV::GlobalBeevMgr->ResolveID(nptr));
+ cvclval.node = new BEEV::ASTNode(BEEV::GlobalBeevMgr->GetLetMgr()->ResolveID(nptr));
//cvclval.node = new BEEV::ASTNode(nptr);
if ((cvclval.node)->GetType() == BOOLEAN_TYPE)
return FORMID_TOK;
i->SetValueWidth($5->GetValueWidth());
i->SetIndexWidth($5->GetIndexWidth());
- GlobalBeevMgr->LetExprMgr(*i,*$5);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*i,*$5);
delete $5;
}
}
i->SetValueWidth($5->GetValueWidth());
i->SetIndexWidth($5->GetIndexWidth());
- GlobalBeevMgr->LetExprMgr(*i,*$5);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*i,*$5);
delete $5;
}
}
}
| FORMID_TOK
{
- $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1)); delete $1;
+ $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1)); delete $1;
}
| FORMID_TOK '(' Expr ')'
{
{
$$ = $4;
//Cleanup the LetIDToExprMap
- GlobalBeevMgr->CleanupLetIDMap();
+ GlobalBeevMgr->GetLetMgr()->CleanupLetIDMap();
}
;
;
/* Grammar for Expr */
-Expr : TERMID_TOK { $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1)); delete $1;}
+Expr : TERMID_TOK { $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1)); delete $1;}
| '(' Expr ')' { $$ = $2; }
| BVCONST_TOK { $$ = $1; }
| BOOL_TO_BV_TOK '(' Formula ')'
//
//2. Ensure that LET variables are not
//2. defined more than once
- GlobalBeevMgr->LetExprMgr(*$1,*$3);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$1,*$3);
delete $1;
delete $3;
}
$1->SetValueWidth($5->GetValueWidth());
$1->SetIndexWidth($5->GetIndexWidth());
- GlobalBeevMgr->LetExprMgr(*$1,*$5);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$1,*$5);
delete $1;
delete $5;
}
$1->SetIndexWidth($3->GetIndexWidth());
//Do LET-expr management
- GlobalBeevMgr->LetExprMgr(*$1,*$3);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$1,*$3);
delete $1;
delete $3;
}
$1->SetIndexWidth($5->GetIndexWidth());
//Do LET-expr management
- GlobalBeevMgr->LetExprMgr(*$1,*$5);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$1,*$5);
delete $1;
delete $5;
}
********************************************************************/
#include <stdlib.h>
-#include "../AST/AST.h"
-#include "../STPManager/STPManager.h"
+#include "let-funcs.h"
namespace BEEV {
//external parser table for declared symbols. Only symbols which are
//2. the function returns an error
//
//3. otherwise add the <var,letExpr> pair to the _letid_expr table.
- void BeevMgr::LetExprMgr(const ASTNode& var, const ASTNode& letExpr) {
+ void LETMgr::LetExprMgr(const ASTNode& var, const ASTNode& letExpr)
+ {
ASTNodeMap::iterator it;
if(((it = _letid_expr_map->find(var)) != _letid_expr_map->end()) &&
it->second != ASTUndefined) {
//this function looksup the "var to letexpr map" and returns the
//corresponding letexpr. if there is no letexpr, then it simply
//returns the var.
- ASTNode BeevMgr::ResolveID(const ASTNode& v) {
+ ASTNode LETMgr::ResolveID(const ASTNode& v)
+ {
if (_letid_expr_map == NULL)
InitializeLetIDMap();
//rid of this hack.
(*_letid_expr_map)[v] = ASTUndefined;
return v;
- }
+ }//End of ResolveID()
// This function simply cleans up the LetID -> LetExpr Map.
- void BeevMgr::CleanupLetIDMap(void) {
+ void LETMgr::CleanupLetIDMap(void)
+ {
// ext/hash_map::clear() is very expensive on big empty lists. shortcut.
if (_letid_expr_map->size() ==0)
return;
// May contain lots of buckets, so reset.
delete _letid_expr_map;
_letid_expr_map = new ASTNodeMap();
-
}//end of CleanupLetIDMap()
- void BeevMgr::InitializeLetIDMap(void)
+ void LETMgr::InitializeLetIDMap(void)
{
_letid_expr_map = new ASTNodeMap();
} //end of InitializeLetIDMap()
// Check valuesize to see if it's a prop var. I don't like doing
// type determination in the lexer, but it's easier than rewriting
// the whole grammar to eliminate the term/formula distinction.
- smtlval.node = new BEEV::ASTNode(BEEV::GlobalBeevMgr->ResolveID(nptr));
+ smtlval.node = new BEEV::ASTNode(BEEV::GlobalBeevMgr->GetLetMgr()->ResolveID(nptr));
//smtlval.node = new BEEV::ASTNode(nptr);
if ((smtlval.node)->GetType() == BOOLEAN_TYPE)
return FORMID_TOK;
{
$$ = $2;
//Cleanup the LetIDToExprMap
- GlobalBeevMgr->CleanupLetIDMap();
+ GlobalBeevMgr->GetLetMgr()->CleanupLetIDMap();
}
;
//
//2. Ensure that LET variables are not
//2. defined more than once
- GlobalBeevMgr->LetExprMgr(*$5,*$6);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$5,*$6);
delete $5;
delete $6;
}
$5->SetIndexWidth($6->GetIndexWidth());
//Do LET-expr management
- GlobalBeevMgr->LetExprMgr(*$5,*$6);
+ GlobalBeevMgr->GetLetMgr()->LetExprMgr(*$5,*$6);
delete $5;
delete $6;
}
BITCONST_TOK { $$ = $1; }
| var
{
- $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1));
+ $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1));
delete $1;
}
| LPAREN_TOK an_term RPAREN_TOK
var:
FORMID_TOK
{
- $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1));
+ $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1));
delete $1;
}
| TERMID_TOK
{
- $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1));
+ $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1));
delete $1;
}
| QUESTION_TOK TERMID_TOK
}
| FORMID_TOK
{
- $$ = new ASTNode(GlobalBeevMgr->ResolveID(*$1));
+ $$ = new ASTNode(GlobalBeevMgr->GetLetMgr()->ResolveID(*$1));
delete $1;
}
;