Ejemplo n.º 1
0
static PyObject *SmtAstNode_getChilds(PyObject *self, PyObject *noarg) {
  PyObject *childs;
  smt2lib::smtAstAbstractNode *node = PySmtAstNode_AsSmtAstNode(self);

  uint64 size = node->getChilds().size();
  childs = xPyList_New(size);
  uint64 index = 0;
  for ( ; index < size; index++)
    PyList_SetItem(childs, index, PySmtAstNode(node->getChilds()[index]));

  return childs;
}
Ejemplo n.º 2
0
static PyObject *Triton_getFullExpression(PyObject *self, PyObject *node)
{
  smt2lib::smtAstAbstractNode *fullExpr;

  if (!PySmtAstNode_Check(node))
    return PyErr_Format(PyExc_TypeError, "getFullSymExpr(): expected an SmtAstNode node as argument");

  fullExpr = ap.getFullExpression(PySmtAstNode_AsSmtAstNode(node));
  if (fullExpr == nullptr)
    return Py_None;

  return PySmtAstNode(fullExpr);
}
Ejemplo n.º 3
0
static PyObject *smt2lib_bvlshr(PyObject *self, PyObject *args) {
  PyObject *op1 = nullptr;
  PyObject *op2 = nullptr;

  /* Extract arguments */
  PyArg_ParseTuple(args, "O|O", &op1, &op2);

  if (op1 == nullptr || !PySmtAstNode_Check(op1))
    return PyErr_Format(PyExc_TypeError, "bvlshr(): expected a SmtAstNode as first argument");

  if (op2 == nullptr || !PySmtAstNode_Check(op2))
    return PyErr_Format(PyExc_TypeError, "bvlshr(): expected a SmtAstNode as second argument");

  return PySmtAstNode(smt2lib::bvlshr(PySmtAstNode_AsSmtAstNode(op1), PySmtAstNode_AsSmtAstNode(op2)));
}
Ejemplo n.º 4
0
static PyObject *smt2lib_zx(PyObject *self, PyObject *args) {
  PyObject *op1;
  PyObject *op2 = nullptr;

  /* Extract arguments */
  PyArg_ParseTuple(args, "O|O", &op1, &op2);

  if (!PyLong_Check(op1) && !PyInt_Check(op1))
    return PyErr_Format(PyExc_TypeError, "zx(): expected an integer as first argument");

  if (op2 == nullptr || !PySmtAstNode_Check(op2))
    return PyErr_Format(PyExc_TypeError, "zx(): expected a SmtAstNode as second argument");

  return PySmtAstNode(smt2lib::zx(PyLong_AsLong(op2), PySmtAstNode_AsSmtAstNode(op2)));
}
Ejemplo n.º 5
0
static PyObject *smt2lib_bv(PyObject *self, PyObject *args) {
  PyObject *op1 = nullptr;
  PyObject *op2 = nullptr;

  /* Extract arguments */
  PyArg_ParseTuple(args, "|OO", &op1, &op2);

  if (op1 == nullptr || (!PyLong_Check(op1) && !PyInt_Check(op1)))
    return PyErr_Format(PyExc_TypeError, "bv(): expected an integer as first argument");

  if (op2 == nullptr || (!PyLong_Check(op2) && !PyInt_Check(op2)))
    return PyErr_Format(PyExc_TypeError, "bv(): expected an integer as second argument");

  return PySmtAstNode(smt2lib::bv(PyLongObjectToUint128(op1), PyLong_AsLongLong(op2)));
}
Ejemplo n.º 6
0
static PyObject *smt2lib_compound(PyObject *self, PyObject *exprsList) {
  std::vector<smt2lib::smtAstAbstractNode *> exprs;

  if (exprsList == nullptr || !PyList_Check(exprsList))
    return PyErr_Format(PyExc_TypeError, "compound(): expected a list of SmtAstNodes as first argument");

  /* Check if the mems list contains only integer item and craft a std::list */
  for (Py_ssize_t i = 0; i < PyList_Size(exprsList); i++){
    PyObject *item = PyList_GetItem(exprsList, i);

    if (!PySmtAstNode_Check(item))
      return PyErr_Format(PyExc_TypeError, "compound(): Each element from the list must be a SmtAstNode");

    exprs.push_back(PySmtAstNode_AsSmtAstNode(item));
  }

  return PySmtAstNode(smt2lib::compound(exprs));
}
Ejemplo n.º 7
0
static PyObject *smt2lib_extract(PyObject *self, PyObject *args) {
  PyObject *op1 = nullptr;
  PyObject *op2 = nullptr;
  PyObject *op3 = nullptr;

  /* Extract arguments */
  PyArg_ParseTuple(args, "|OOO", &op1, &op2, &op3);

  if (op1 == nullptr || (!PyLong_Check(op1) && !PyInt_Check(op1)))
    return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as first argument");

  if (op2 == nullptr || (!PyLong_Check(op2) && !PyInt_Check(op2)))
    return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as second argument");

  if (op3 == nullptr || !PySmtAstNode_Check(op3))
    return PyErr_Format(PyExc_TypeError, "extract(): expected a SmtAstNode as third argument");

  return PySmtAstNode(smt2lib::extract(PyLong_AsUint(op1), PyLong_AsUint(op2), PySmtAstNode_AsSmtAstNode(op3)));
}
Ejemplo n.º 8
0
static PyObject *SymbolicExpression_getNewAst(PyObject *self, PyObject *noarg) {
  SymbolicExpression *expression = PySymbolicExpression_AsSymbolicExpression(self);
  return PySmtAstNode(smt2lib::newInstance(expression->getExpression()));
}
Ejemplo n.º 9
0
static PyObject *SymbolicExpression_getAst(PyObject *self, PyObject *noarg) {
  SymbolicExpression *expression = PySymbolicExpression_AsSymbolicExpression(self);
  return PySmtAstNode(expression->getExpression());
}
Ejemplo n.º 10
0
static PyObject *smt2lib_bvfalse(PyObject *self, PyObject *args) {
  return PySmtAstNode(smt2lib::bvfalse());
}
Ejemplo n.º 11
0
static PyObject *smt2lib_variable(PyObject *self, PyObject *expr) {
  if (!PyString_Check(expr))
    return PyErr_Format(PyExc_TypeError, "string(): expected a string as first argument");

  return PySmtAstNode(smt2lib::variable(PyString_AsString(expr)));
}
Ejemplo n.º 12
0
static PyObject *smt2lib_smtAssert(PyObject *self, PyObject *expr) {
  if (!PySmtAstNode_Check(expr))
    return PyErr_Format(PyExc_TypeError, "smtAssert(): expected a SmtAstNode as first argument");

  return PySmtAstNode(smt2lib::smtAssert(PySmtAstNode_AsSmtAstNode(expr)));
}
Ejemplo n.º 13
0
static PyObject *smt2lib_bvnot(PyObject *self, PyObject *op1) {
  if (!PySmtAstNode_Check(op1))
    return PyErr_Format(PyExc_TypeError, "bvnot(): expected a SmtAstNode as first argument");

  return PySmtAstNode(smt2lib::bvnot(PySmtAstNode_AsSmtAstNode(op1)));
}