From 74e6f0b1ec3937f409ea5108fc7fb47ffc732f64 Mon Sep 17 00:00:00 2001 From: Tim King Date: Wed, 8 Feb 2012 00:31:00 +0000 Subject: [PATCH] Number of changes to cvc_printer.cpp. Specialized the printing for BVPLUS, BVSUB, and BVMULT. Fixed a bug in printing on PREFIX operators. Added parenthsis for POSTFIX operators. Passing the ouroborous test now. --- src/printer/cvc/cvc_printer.cpp | 62 +++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/src/printer/cvc/cvc_printer.cpp b/src/printer/cvc/cvc_printer.cpp index 26616259c..283cdd725 100644 --- a/src/printer/cvc/cvc_printer.cpp +++ b/src/printer/cvc/cvc_printer.cpp @@ -143,6 +143,9 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo POSTFIX } opType; + //The default operation type is PREFIX + opType = PREFIX; + stringstream op; // operation (such as '+') switch(n.getKind()) { @@ -215,8 +218,9 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo // UF case kind::APPLY_UF: - toStream(op, n.getOperator(), depth, types, true); + toStream(op, n.getOperator(), depth, types, false); break; + case kind::FUNCTION_TYPE: if (n.getNumChildren() > 1) { if (n.getNumChildren() > 2) { @@ -280,7 +284,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo case kind::SELECT: toStream(out, n[0], depth, types, false); out << '['; - toStream(out, n[0], depth, types, false); + toStream(out, n[1], depth, types, false); out << ']'; return; break; @@ -354,12 +358,6 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo break; // BITVECTORS - case kind::BITVECTOR_PLUS: - op << "BVPLUS"; - break; - case kind::BITVECTOR_SUB: - op << "BVSUB"; - break; case kind::BITVECTOR_XOR: op << "BVXOR"; break; @@ -375,9 +373,6 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo case kind::BITVECTOR_COMP: op << "BVCOMP"; break; - case kind::BITVECTOR_MULT: - op << "BVMULT"; - break; case kind::BITVECTOR_UDIV: op << "BVUDIV"; break; @@ -444,6 +439,40 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo op << "@"; opType = INFIX; break; + case kind::BITVECTOR_PLUS: + //This interprets a BITVECTOR_PLUS as a bvadd in SMT-LIB + out << "BVPLUS("; + Assert(n.getType().isBitVector()); + out << BitVectorType(n.getType().toType()).getSize(); + out << ','; + toStream(out, n[0], depth, types, false); + out << ','; + toStream(out, n[1], depth, types, false); + out << ')'; + return; + break; + case kind::BITVECTOR_SUB: + out << "BVSUB("; + Assert(n.getType().isBitVector()); + out << BitVectorType(n.getType().toType()).getSize(); + out << ','; + toStream(out, n[0], depth, types, false); + out << ','; + toStream(out, n[1], depth, types, false); + out << ')'; + return; + break; + case kind::BITVECTOR_MULT: + out << "BVMULT("; + Assert(n.getType().isBitVector()); + out << BitVectorType(n.getType().toType()).getSize(); + out << ','; + toStream(out, n[0], depth, types, false); + out << ','; + toStream(out, n[1], depth, types, false); + out << ')'; + return; + break; case kind::BITVECTOR_EXTRACT: op << n.getOperator().getConst(); opType = POSTFIX; @@ -485,9 +514,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo switch (opType) { case PREFIX: - if (bracket) { - out << op.str() << '('; - } + out << op.str() << '('; break; case INFIX: if (bracket) { @@ -495,6 +522,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo } break; case POSTFIX: + out << '('; break; } @@ -511,9 +539,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo switch (opType) { case PREFIX: - if (bracket) { - out << ')'; - } + out << ')'; break; case INFIX: if (bracket) { @@ -521,7 +547,7 @@ void CvcPrinter::toStream(std::ostream& out, TNode n, int depth, bool types, boo } break; case POSTFIX: - out << op.str(); + out << ')' << op.str(); break; } -- 2.30.2