本文整理汇总了C++中TypeNode::isBitVector方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeNode::isBitVector方法的具体用法?C++ TypeNode::isBitVector怎么用?C++ TypeNode::isBitVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeNode
的用法示例。
在下文中一共展示了TypeNode::isBitVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rewriteAs
Node ModelPostprocessor::rewriteAs(TNode n, TypeNode asType) {
if(n.getType().isSubtypeOf(asType)) {
// good to go, we have the right type
return n;
}
if(!n.isConst()) {
// we don't handle non-const right now
return n;
}
if(asType.isBoolean()) {
if(n.getType().isBitVector(1u)) {
// type mismatch: should only happen for Boolean-term conversion under
// datatype constructor applications; rewrite from BV(1) back to Boolean
bool tf = (n.getConst<BitVector>().getValue() == 1);
return NodeManager::currentNM()->mkConst(tf);
}
if(n.getType().isDatatype() && n.getType().hasAttribute(BooleanTermAttr())) {
// type mismatch: should only happen for Boolean-term conversion under
// datatype constructor applications; rewrite from datatype back to Boolean
Assert(n.getKind() == kind::APPLY_CONSTRUCTOR);
Assert(n.getNumChildren() == 0);
// we assume (by construction) false is first; see boolean_terms.cpp
bool tf = (Datatype::indexOf(n.getOperator().toExpr()) == 1);
Debug("boolean-terms") << "+++ rewriteAs " << n << " : " << asType << " ==> " << tf << endl;
return NodeManager::currentNM()->mkConst(tf);
}
}
if(n.getType().isBoolean()) {
bool tf = n.getConst<bool>();
if(asType.isBitVector(1u)) {
return NodeManager::currentNM()->mkConst(BitVector(1u, tf ? 1u : 0u));
}
if(asType.isDatatype() && asType.hasAttribute(BooleanTermAttr())) {
const Datatype& asDatatype = asType.getConst<Datatype>();
return NodeManager::currentNM()->mkNode(kind::APPLY_CONSTRUCTOR, (tf ? asDatatype[0] : asDatatype[1]).getConstructor());
}
}
if(n.getType().isRecord() && asType.isRecord()) {
Debug("boolean-terms") << "+++ got a record - rewriteAs " << n << " : " << asType << endl;
const Record& rec CVC4_UNUSED = n.getType().getConst<Record>();
const Record& asRec = asType.getConst<Record>();
Assert(rec.getNumFields() == asRec.getNumFields());
Assert(n.getNumChildren() == asRec.getNumFields());
NodeBuilder<> b(n.getKind());
b << asType;
for(size_t i = 0; i < n.getNumChildren(); ++i) {
b << rewriteAs(n[i], TypeNode::fromType(asRec[i].second));
}
Node out = b;
Debug("boolean-terms") << "+++ returning record " << out << endl;
return out;
}
示例2: getOrderKind
Kind SymmetryBreaker::getOrderKind(Node node)
{
TypeNode tn = node.getType();
if (tn.isBoolean())
{
return IMPLIES;
}
else if (tn.isReal())
{
return LEQ;
}
else if (tn.isBitVector())
{
return BITVECTOR_ULE;
}
if (tn.isFirstClass())
{
return EQUAL;
}
return UNDEFINED_KIND;
}
示例3: removeToFPGeneric
Node removeToFPGeneric (TNode node) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_GENERIC);
FloatingPointToFPGeneric info = node.getOperator().getConst<FloatingPointToFPGeneric>();
size_t children = node.getNumChildren();
Node op;
if (children == 1) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPIEEEBitVector(info.t.exponent(),
info.t.significand()));
return NodeManager::currentNM()->mkNode(op, node[0]);
} else {
Assert(children == 2);
Assert(node[0].getType().isRoundingMode());
TypeNode t = node[1].getType();
if (t.isFloatingPoint()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPFloatingPoint(info.t.exponent(),
info.t.significand()));
} else if (t.isReal()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPReal(info.t.exponent(),
info.t.significand()));
} else if (t.isBitVector()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPSignedBitVector(info.t.exponent(),
info.t.significand()));
} else {
throw TypeCheckingExceptionPrivate(node, "cannot rewrite to_fp generic due to incorrect type of second argument");
}
return NodeManager::currentNM()->mkNode(op, node[0], node[1]);
}
Unreachable("to_fp generic not rewritten");
}