summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKshitij Bansal <kshitij@cs.nyu.edu>2012-11-29 06:59:21 +0000
committerKshitij Bansal <kshitij@cs.nyu.edu>2012-11-29 06:59:21 +0000
commit8f6b53a5328e34ed3f22c67aad6a5ab73bb6fa8b (patch)
tree277d4cefb81445d0f3975382f053d224437c6118 /src
parentff6ac38127fbb03e6c11a210b6b16d647b8785ea (diff)
Hack to support global variables for CVC language extended to export mechanism.
- Adds GlobalVarAttr node attribute (this commit was certified error- and warning-free by the test-and-commit script.)
Diffstat (limited to 'src')
-rw-r--r--src/expr/expr_template.cpp7
-rw-r--r--src/expr/node_manager.h6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/expr/expr_template.cpp b/src/expr/expr_template.cpp
index ed643b830..a3204f00f 100644
--- a/src/expr/expr_template.cpp
+++ b/src/expr/expr_template.cpp
@@ -138,12 +138,15 @@ Node exportInternal(TNode n, ExprManager* from, ExprManager* to, ExprManagerMapC
if(Node::fromExpr(from_e).getAttribute(VarNameAttr(), name)) {
// temporarily set the node manager to NULL; this gets around
// a check that mkVar isn't called internally
- NodeManagerScope nullScope(NULL);
if(n.getKind() == kind::BOUND_VAR_LIST || n.getKind() == kind::BOUND_VARIABLE) {
+ NodeManagerScope nullScope(NULL);
to_e = to->mkBoundVar(name, type);// FIXME thread safety
} else if(n.getKind() == kind::VARIABLE) {
- to_e = to->mkVar(name, type);// FIXME thread safety
+ bool isGlobal;
+ Node::fromExpr(from_e).getAttribute(GlobalVarAttr(), isGlobal);
+ NodeManagerScope nullScope(NULL);
+ to_e = to->mkVar(name, type, isGlobal);// FIXME thread safety
} else if(n.getKind() == kind::SKOLEM) {
// skolems are only available at the Node level (not the Expr level)
TypeNode typeNode = TypeNode::fromType(type);
diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h
index 5cf591f9d..2cda23f2d 100644
--- a/src/expr/node_manager.h
+++ b/src/expr/node_manager.h
@@ -52,12 +52,14 @@ class TypeChecker;
// TODO: hide this attribute behind a NodeManager interface.
namespace attr {
struct VarNameTag { };
+ struct GlobalVarTag { };
struct SortArityTag { };
struct DatatypeTupleTag { };
struct DatatypeRecordTag { };
}/* CVC4::expr::attr namespace */
typedef Attribute<attr::VarNameTag, std::string> VarNameAttr;
+typedef Attribute<attr::GlobalVarTag(), bool> GlobalVarAttr;
typedef Attribute<attr::SortArityTag, uint64_t> SortArityAttr;
/** Attribute true for datatype types that are replacements for tuple types */
typedef expr::Attribute<expr::attr::DatatypeTupleTag, TypeNode> DatatypeTupleAttr;
@@ -1479,6 +1481,7 @@ inline Node NodeManager::mkVar(const std::string& name, const TypeNode& type, bo
setAttribute(n, TypeAttr(), type);
setAttribute(n, TypeCheckedAttr(), true);
setAttribute(n, expr::VarNameAttr(), name);
+ setAttribute(n, expr::GlobalVarAttr(), isGlobal);
for(std::vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
(*i)->nmNotifyNewVar(n, isGlobal);
}
@@ -1491,6 +1494,7 @@ inline Node* NodeManager::mkVarPtr(const std::string& name,
setAttribute(*n, TypeAttr(), type);
setAttribute(*n, TypeCheckedAttr(), true);
setAttribute(*n, expr::VarNameAttr(), name);
+ setAttribute(*n, expr::GlobalVarAttr(), isGlobal);
for(std::vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
(*i)->nmNotifyNewVar(*n, isGlobal);
}
@@ -1514,6 +1518,7 @@ inline Node NodeManager::mkVar(const TypeNode& type, bool isGlobal) {
Node n = NodeBuilder<0>(this, kind::VARIABLE);
setAttribute(n, TypeAttr(), type);
setAttribute(n, TypeCheckedAttr(), true);
+ setAttribute(n, expr::GlobalVarAttr(), isGlobal);
for(std::vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
(*i)->nmNotifyNewVar(n, isGlobal);
}
@@ -1524,6 +1529,7 @@ inline Node* NodeManager::mkVarPtr(const TypeNode& type, bool isGlobal) {
Node* n = NodeBuilder<0>(this, kind::VARIABLE).constructNodePtr();
setAttribute(*n, TypeAttr(), type);
setAttribute(*n, TypeCheckedAttr(), true);
+ setAttribute(*n, expr::GlobalVarAttr(), isGlobal);
for(std::vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
(*i)->nmNotifyNewVar(*n, isGlobal);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback