cvc5::Rational rMaxInt(cvc5::String::maxSize());
if (node[2].getConst<Rational>() > rMaxInt)
{
- // We know that, due to limitations on the size of string constants
- // in our implementation, that accessing a position greater than
- // rMaxInt is guaranteed to be out of bounds.
- Node negone = nm->mkConstInt(Rational(-1));
- return returnRewrite(node, negone, Rewrite::IDOF_MAX);
- }
- Assert(node[2].getConst<Rational>().sgn() >= 0);
- Node s = children0[0];
- Node t = node[1];
- uint32_t start =
- node[2].getConst<Rational>().getNumerator().toUnsignedInt();
- std::size_t ret = Word::find(s, t, start);
- if (ret != std::string::npos)
- {
- Node retv = nm->mkConstInt(Rational(static_cast<unsigned>(ret)));
- return returnRewrite(node, retv, Rewrite::IDOF_FIND);
+ if (node[0].isConst())
+ {
+ // We know that, due to limitations on the size of string constants
+ // in our implementation, that accessing a position greater than
+ // rMaxInt is guaranteed to be out of bounds.
+ Node negone = nm->mkConstInt(Rational(-1));
+ return returnRewrite(node, negone, Rewrite::IDOF_MAX);
+ }
}
- else if (children0.size() == 1)
+ else
{
- Node negone = nm->mkConstInt(Rational(-1));
- return returnRewrite(node, negone, Rewrite::IDOF_NFIND);
+ Assert(node[2].getConst<Rational>().sgn() >= 0);
+ Node s = children0[0];
+ Node t = node[1];
+ uint32_t start =
+ node[2].getConst<Rational>().getNumerator().toUnsignedInt();
+ std::size_t ret = Word::find(s, t, start);
+ if (ret != std::string::npos)
+ {
+ Node retv = nm->mkConstInt(Rational(static_cast<unsigned>(ret)));
+ return returnRewrite(node, retv, Rewrite::IDOF_FIND);
+ }
+ else if (children0.size() == 1)
+ {
+ Node negone = nm->mkConstInt(Rational(-1));
+ return returnRewrite(node, negone, Rewrite::IDOF_NFIND);
+ }
}
}