<commit_before>// This code is GPLed by <NAME>

#include <Python.h>
#include <structmember.h>
#include <libvex.h>

#include "pyvex_enums.h"
#include "pyvex_types.h"
#include "pyvex_macros.h"
#include "pyvex_logging.h"

#ifdef PYVEX_STATIC
	#include "pyvex_static.h"
	#include "pyvex_deepcopy.h"
#endif

///////////////////////
// IRExpr base class //
///////////////////////

PYMARE_NEW(IRExpr)
PYMARE_DEALLOC(IRExpr)
PYVEX_METH_STANDARD(IRExpr)

static int
pyIRExpr_init(pyIRExpr *self, PyObject *args, PyObject *kwargs)
{
	PYMARE_WRAP_CONSTRUCTOR(IRExpr);
	PyErr_SetString(PyVEXError, "Base IRExpr creation not supported..");
	return -1;
}

PYMARE_ACCESSOR_WRAPPED(IRExpr, IRExpr, self->wrapped, wrapped, IRExpr)
PYMARE_ACCESSOR_ENUM(IRExpr, IRExpr, self->wrapped->tag, tag, IRExprTag)

static PyGetSetDef pyIRExpr_getseters[] =
{
	PYMARE_ACCESSOR_DEF(IRExpr, wrapped),
	PYMARE_ACCESSOR_DEF(IRExpr, tag),
	{NULL}
};

static PyObject *pyIRExpr_atomic(pyIRExpr* self)
{
	if (isIRAtom(self->wrapped)) { Py_RETURN_TRUE; }
	Py_RETURN_FALSE;
}

static PyMethodDef pyIRExpr_methods[] =
{
	PYVEX_METHDEF_STANDARD(IRExpr),
	{"atomic", (PyCFunction)pyIRExpr_atomic, METH_NOARGS, "Returns true if IRExpr is atomic (RdTmp or Const), false otherwise."},
	{NULL}
};

static PyMemberDef pyIRExpr_members[] = { {NULL} };
PYMARE_TYPEOBJECT("pyvex", IRExpr);

// wrap functionality
PyObject *wrap_IRExpr(IRExpr *i)
{
	PyTypeObject *t = NULL;
  if (i == NULL) { Py_RETURN_NONE; }
	switch (i->tag)
	{
		PYVEX_WRAPCASE(IRExpr, Iex_, Binder)
		PYVEX_WRAPCASE(IRExpr, Iex_, Get)
		PYVEX_WRAPCASE(IRExpr, Iex_, GetI)
		PYVEX_WRAPCASE(IRExpr, Iex_, RdTmp)
		PYVEX_WRAPCASE(IRExpr, Iex_, Qop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Triop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Binop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Unop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Load)
		PYVEX_WRAPCASE(IRExpr, Iex_, Const)
		PYVEX_WRAPCASE(IRExpr, Iex_, ITE)
		PYVEX_WRAPCASE(IRExpr, Iex_, CCall)
		PYVEX_WRAPCASE(IRExpr, Iex_, BBPTR)
		PYVEX_WRAPCASE(IRExpr, Iex_, VECRET)
		default:
			error("PyVEX: Unknown/unsupported IRExprTag %s\n", IRExprTag_to_str(i->tag));
			t = &pyIRExprType;
	}

	PyObject *args = Py_BuildValue("");
	PyObject *kwargs = Py_BuildValue("{s:O}", "wrap", PyCapsule_New(i, "IRExpr", NULL));
	PyObject *o = PyObject_Call((PyObject *)t, args, kwargs);<commit_msg>fixed indent<commit_after>// This code is GPLed by <NAME>

#include <Python.h>
#include <structmember.h>
#include <libvex.h>

#include "pyvex_enums.h"
#include "pyvex_types.h"
#include "pyvex_macros.h"
#include "pyvex_logging.h"

#ifdef PYVEX_STATIC
	#include "pyvex_static.h"
	#include "pyvex_deepcopy.h"
#endif

///////////////////////
// IRExpr base class //
///////////////////////

PYMARE_NEW(IRExpr)
PYMARE_DEALLOC(IRExpr)
PYVEX_METH_STANDARD(IRExpr)

static int
pyIRExpr_init(pyIRExpr *self, PyObject *args, PyObject *kwargs)
{
	PYMARE_WRAP_CONSTRUCTOR(IRExpr);
	PyErr_SetString(PyVEXError, "Base IRExpr creation not supported..");
	return -1;
}

PYMARE_ACCESSOR_WRAPPED(IRExpr, IRExpr, self->wrapped, wrapped, IRExpr)
PYMARE_ACCESSOR_ENUM(IRExpr, IRExpr, self->wrapped->tag, tag, IRExprTag)

static PyGetSetDef pyIRExpr_getseters[] =
{
	PYMARE_ACCESSOR_DEF(IRExpr, wrapped),
	PYMARE_ACCESSOR_DEF(IRExpr, tag),
	{NULL}
};

static PyObject *pyIRExpr_atomic(pyIRExpr* self)
{
	if (isIRAtom(self->wrapped)) { Py_RETURN_TRUE; }
	Py_RETURN_FALSE;
}

static PyMethodDef pyIRExpr_methods[] =
{
	PYVEX_METHDEF_STANDARD(IRExpr),
	{"atomic", (PyCFunction)pyIRExpr_atomic, METH_NOARGS, "Returns true if IRExpr is atomic (RdTmp or Const), false otherwise."},
	{NULL}
};

static PyMemberDef pyIRExpr_members[] = { {NULL} };
PYMARE_TYPEOBJECT("pyvex", IRExpr);

// wrap functionality
PyObject *wrap_IRExpr(IRExpr *i)
{
	PyTypeObject *t = NULL;
	if (i == NULL) { Py_RETURN_NONE; }
	switch (i->tag)
	{
		PYVEX_WRAPCASE(IRExpr, Iex_, Binder)
		PYVEX_WRAPCASE(IRExpr, Iex_, Get)
		PYVEX_WRAPCASE(IRExpr, Iex_, GetI)
		PYVEX_WRAPCASE(IRExpr, Iex_, RdTmp)
		PYVEX_WRAPCASE(IRExpr, Iex_, Qop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Triop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Binop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Unop)
		PYVEX_WRAPCASE(IRExpr, Iex_, Load)
		PYVEX_WRAPCASE(IRExpr, Iex_, Const)
		PYVEX_WRAPCASE(IRExpr, Iex_, ITE)
		PYVEX_WRAPCASE(IRExpr, Iex_, CCall)
		PYVEX_WRAPCASE(IRExpr, Iex_, BBPTR)
		PYVEX_WRAPCASE(IRExpr, Iex_, VECRET)
		default:
			error("PyVEX: Unknown/unsupported IRExprTag %s\n", IRExprTag_to_str(i->tag));
			t = &pyIRExprType;
	}

	PyObject *args = Py_BuildValue("");
	PyObject *kwargs = Py_BuildValue("{s:O}", "wrap", PyCapsule_New(i, "IRExpr", NULL));
	PyObject *o = PyObject_Call((PyObject *)t, args, kwargs);
{'fraction_non_alphanumeric': 0.15012942191544434, 'fraction_numerical': 0.0004314063848144953, 'mean_word_length': 5.467224546722455, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5860251', 'n_tokens_mistral': 2182, 'n_tokens_neox': 1953, 'n_words': 364}