From: Tim King Date: Wed, 3 Feb 2010 19:23:45 +0000 (+0000) Subject: Within node I added printAst(..) for general purpose debugging use throughout the... X-Git-Tag: cvc5-1.0.0~9305 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=480b791976b2916148ef95c48c00280b404c32e2;p=cvc5.git Within node I added printAst(..) for general purpose debugging use throughout the code. I also added debugPrint() to Node for use within gdb. --- diff --git a/src/expr/node.cpp b/src/expr/node.cpp index b87acb1f2..0212b4fdd 100644 --- a/src/expr/node.cpp +++ b/src/expr/node.cpp @@ -116,4 +116,30 @@ Node Node::xorExpr(const Node& right) const { return NodeManager::currentNM()->mkNode(XOR, *this, right); } +void indent(ostream & o, int indent){ + for(int i=0; i < indent; i++) + o << ' '; +} + +void Node::printAst(ostream & o, int ind) const{ + indent(o, ind); + o << '('; + o << getKind(); + if(getKind() == VARIABLE){ + o << ' ' << getId(); + + }else if(getNumChildren() > 1){ + for(Node::iterator child = begin(); child != end(); ++child){ + (*child).printAst(o, ind+1); + } + indent(o, ind); + } + o << ')'; +} + +void Node::debugPrint(){ + printAst(Warning(), 0); + Warning().flush(); +} + }/* CVC4 namespace */ diff --git a/src/expr/node.h b/src/expr/node.h index 67af6aa18..ab5007a34 100644 --- a/src/expr/node.h +++ b/src/expr/node.h @@ -154,6 +154,11 @@ public: bool isNull() const; + void printAst(std::ostream & o, int indent = 0) const; + +private: + void debugPrint(); + };/* class Node */ }/* CVC4 namespace */