本文整理汇总了C++中ASTNode::nodeprint方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::nodeprint方法的具体用法?C++ ASTNode::nodeprint怎么用?C++ ASTNode::nodeprint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::nodeprint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: symbolToString
// ABC doesn't like spaces, nor brackets. in variable names.
// TODO CHECK that this doesn't cause duplicate names
string symbolToString(const ASTNode& n)
{
assert(n.GetKind() == SYMBOL);
std::stringstream output;
n.nodeprint(output);
string result = output.str();
replace(result.begin(), result.end(), ' ', '_');
replace(result.begin(), result.end(), '(', '_');
replace(result.begin(), result.end(), ')', '_');
return result;
}
示例2: switch
void Dot_Print1(ostream &os, const ASTNode n, hash_set<int> *alreadyOutput)
{
// check if this node has already been printed. If so return.
if (alreadyOutput->find(n.GetNodeNum()) != alreadyOutput->end())
return;
alreadyOutput->insert(n.GetNodeNum());
os << "n" << n.GetNodeNum() << "[label =\"";
switch (n.GetKind())
{
case SYMBOL:
n.nodeprint(os);
break;
case BITVECTOR:
case BVCONST:
outputBitVec(n, os);
break;
default:
os << _kind_names[n.GetKind()];
}
os << "\"];" << endl;
// print the edges to each child.
ASTVec ch = n.GetChildren();
ASTVec::iterator itend = ch.end();
int i = 0;
for (ASTVec::iterator it = ch.begin(); it < itend; it++)
{
os << "n" << n.GetNodeNum()
<< " -> " << "n"
<< it->GetNodeNum()
<< "[label=" << i++
<< "];" << endl;
}
// print each of the children.
for (ASTVec::iterator it = ch.begin(); it < itend; it++)
{
Dot_Print1(os, *it, alreadyOutput);
}
}
示例3: C_Print1
// helper function for printing C code (copied from PL_Print1())
void C_Print1(ostream& os, const ASTNode n, int indentation, bool letize)
{
unsigned int upper, lower, num_bytes;
Kind LHSkind, RHSkind;
// os << spaces(indentation);
// os << endl << spaces(indentation);
if (!n.IsDefined())
{
os << "<undefined>";
return;
}
// if this node is present in the letvar Map, then print the letvar
STPMgr* bm = n.GetSTPMgr();
// this is to print letvars for shared subterms inside the printing
// of "(LET v0 = term1, [email protected],...
if ((bm->NodeLetVarMap1.find(n) != bm->NodeLetVarMap1.end()) && !letize)
{
C_Print1(os, (bm->NodeLetVarMap1[n]), indentation, letize);
return;
}
// this is to print letvars for shared subterms inside the actual
// term to be printed
if ((bm->NodeLetVarMap.find(n) != bm->NodeLetVarMap.end()) && letize)
{
C_Print1(os, (bm->NodeLetVarMap[n]), indentation, letize);
return;
}
// otherwise print it normally
Kind kind = n.GetKind();
const ASTVec& c = n.GetChildren();
switch (kind)
{
case BOOLEXTRACT:
FatalError("C_Print1: printing not implemented for this kind: ", n);
C_Print1(os, c[0], indentation, letize);
os << "{";
C_Print1(os, c[1], indentation, letize);
os << "}";
break;
case BITVECTOR:
FatalError("C_Print1: printing not implemented for this kind: ", n);
os << "BITVECTOR(";
unsigned char* str;
str = CONSTANTBV::BitVector_to_Hex(c[0].GetBVConst());
os << str << ")";
CONSTANTBV::BitVector_Dispose(str);
break;
case BOOLEAN:
FatalError("C_Print1: printing not implemented for this kind: ", n);
os << "BOOLEAN";
break;
case FALSE:
os << "0";
break;
case TRUE:
os << "1";
break;
case BVCONST:
case SYMBOL:
// print in C friendly format:
n.nodeprint(os, true);
break;
case READ:
C_Print1(os, c[0], indentation, letize);
os << "[";
C_Print1(os, c[1], indentation, letize);
os << "]";
break;
case WRITE:
os << "(";
C_Print1(os, c[0], indentation, letize);
os << " WITH [";
C_Print1(os, c[1], indentation, letize);
os << "] := ";
C_Print1(os, c[2], indentation, letize);
os << ")";
os << endl;
break;
case BVUMINUS:
os << kind << "( ";
C_Print1(os, c[0], indentation, letize);
os << ")";
break;
case NOT:
os << "!(";
C_Print1(os, c[0], indentation, letize);
os << ") " << endl;
break;
case BVNEG:
os << " ~(";
C_Print1(os, c[0], indentation, letize);
os << ")";
break;
//.........这里部分代码省略.........
示例4: FatalError
void SMTLIB2_Print1(ostream& os, const ASTNode n, int indentation, bool letize)
{
//os << spaces(indentation);
//os << endl << spaces(indentation);
if (!n.IsDefined())
{
FatalError("<undefined>");
return;
}
//if this node is present in the letvar Map, then print the letvar
//this is to print letvars for shared subterms inside the printing
//of "(LET v0 = term1, [email protected],...
if ((NodeLetVarMap1.find(n) != NodeLetVarMap1.end()) && !letize)
{
SMTLIB2_Print1(os, (NodeLetVarMap1[n]), indentation, letize);
return;
}
//this is to print letvars for shared subterms inside the actual
//term to be printed
if ((NodeLetVarMap.find(n) != NodeLetVarMap.end()) && letize)
{
SMTLIB2_Print1(os, (NodeLetVarMap[n]), indentation, letize);
return;
}
//otherwise print it normally
const Kind kind = n.GetKind();
const ASTVec &c = n.GetChildren();
switch (kind)
{
case BITVECTOR:
case BVCONST:
outputBitVecSMTLIB2(n, os);
break;
case SYMBOL:
os << "|";
n.nodeprint(os);
os << "|";
break;
case FALSE:
os << "false";
break;
case NAND: // No NAND, NOR in smtlib format.
case NOR:
assert(c.size() ==2);
os << "(" << "not ";
if (NAND == kind )
os << "(" << "and ";
else
os << "(" << "or ";
SMTLIB2_Print1(os, c[0], 0, letize);
os << " " ;
SMTLIB2_Print1(os, c[1], 0, letize);
os << "))";
break;
case TRUE:
os << "true";
break;
case BVSX:
case BVZX:
{
unsigned int amount = c[1].GetUnsignedConst();
if (BVZX == kind)
os << "((_ zero_extend ";
else
os << "((_ sign_extend ";
os << (amount - c[0].GetValueWidth()) << ") ";
SMTLIB2_Print1(os, c[0], indentation, letize);
os << ")";
}
break;
case BVEXTRACT:
{
unsigned int upper = c[1].GetUnsignedConst();
unsigned int lower = c[2].GetUnsignedConst();
assert(upper >= lower);
os << "((_ extract " << upper << " " << lower << ") ";
SMTLIB2_Print1(os, c[0], indentation, letize);
os << ")";
}
break;
default:
{
if ((kind == AND || kind == OR|| kind == XOR) && n.Degree() == 1)
{
FatalError("Wrong number of arguments to operation (must be >1).", n);
}
// SMT-LIB only allows these functions to have two parameters.
if ((kind == AND || kind == OR|| kind == XOR || BVPLUS == kind || kind == BVOR || kind == BVAND) && n.Degree() > 2)
{
string close = "";
for (long int i =0; i < (long int)c.size()-1; i++)
{
os << "(" << functionToSMTLIBName(kind,false);
os << " ";
//.........这里部分代码省略.........
示例5: GDL_Print1
void GDL_Print1(ostream& os, const ASTNode& n, hash_set<int>* alreadyOutput,
string (*annotate)(const ASTNode&))
{
// check if this node has already been printed. If so return.
if (alreadyOutput->find(n.GetNodeNum()) != alreadyOutput->end())
return;
alreadyOutput->insert(n.GetNodeNum());
os << "node: { title:\"n" << n.GetNodeNum() << "\" label: \"";
switch (n.GetKind())
{
case SYMBOL:
n.nodeprint(os);
break;
case BITVECTOR:
case BVCONST:
outputBitVec(n, os);
break;
default:
os << _kind_names[n.GetKind()];
}
os << annotate(n);
os << "\"}" << endl;
// print the edges to each child.
const ASTVec ch = n.GetChildren();
const ASTVec::const_iterator itend = ch.end();
// If a node has the child 'TRUE' twice, we only want to output one TRUE node.
ASTNodeSet constantOutput;
int i = 0;
for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
std::stringstream label;
if (!isCommutative(n.GetKind()))
label << " label:\"" << i << "\"";
if (it->isConstant())
{
std::stringstream ss;
ss << n.GetNodeNum() << "_" << it->GetNodeNum();
if (constantOutput.end() == constantOutput.find(*it))
{
os << "node: { title:\"n";
os << ss.str() << "\" label: \"";
if (it->GetType() == BEEV::BOOLEAN_TYPE)
os << _kind_names[it->GetKind()];
else
outputBitVec(*it, os);
os << "\"}" << endl;
constantOutput.insert(*it);
}
os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
<< "n" << ss.str() << "\"" << label.str() << "}" << endl;
}
else
os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
<< "n" << it->GetNodeNum() << "\"" << label.str() << "}" << endl;
i++;
}
// print each of the children.
for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
if (!it->isConstant())
GDL_Print1(os, *it, alreadyOutput, annotate);
}
}