#include <Python.h>
#include <inttypes.h>
#include <libtcc.h>
#include <stdint.h>
Go to the source code of this file.
typedef int(* jitted_func)(block_id *, PyObject *) |
PyMODINIT_FUNC initJittcc |
( |
void |
| ) |
|
Definition at line 279 of file Jittcc.c.
287 TccError = PyErr_NewException(
"tcc.error", NULL, NULL);
289 PyModule_AddObject(m,
"error",
TccError);
static PyObject * TccError
static PyMethodDef TccMethods[]
PyObject* tcc_compil |
( |
PyObject * |
self, |
|
|
PyObject * |
args |
|
) |
| |
Definition at line 180 of file Jittcc.c.
185 TCCState *tcc_state = NULL;
190 if (!PyArg_ParseTuple(args,
"ss", &func_name, &func_code))
193 if (tcc_compile_string(tcc_state, func_code) != 0) {
194 fprintf(stderr,
"Erreur de compilation !\n");
195 fprintf(stderr,
"%s\n", func_code);
199 if (tcc_relocate(tcc_state, TCC_RELOCATE_AUTO) < 0) {
200 fprintf(stderr,
"tcc relocate error\n");
203 entry = tcc_get_symbol(tcc_state, func_name);
205 fprintf(stderr,
"Erreur de symbole %s!\n", func_name);
206 fprintf(stderr,
"%s\n", func_name);
210 ret = PyTuple_New(2);
212 fprintf(stderr,
"Erreur alloc %s!\n", func_name);
213 fprintf(stderr,
"%s\n", func_name);
217 PyTuple_SetItem(ret, 0, PyLong_FromUnsignedLongLong((uint64_t)tcc_state));
218 PyTuple_SetItem(ret, 1, PyLong_FromUnsignedLongLong((uint64_t)entry));
TCCState * tcc_init_state(void)
PyObject* tcc_end |
( |
PyObject * |
self, |
|
|
PyObject * |
args |
|
) |
| |
Definition at line 60 of file Jittcc.c.
62 TCCState *tcc_state = NULL;
63 if (!PyArg_ParseTuple(args,
"K", &tcc_state))
65 tcc_delete(tcc_state);
PyObject* tcc_exec_bloc |
( |
PyObject * |
self, |
|
|
PyObject * |
args |
|
) |
| |
Definition at line 130 of file Jittcc.c.
136 PyObject* breakpoints;
137 PyObject* retaddr = NULL;
141 if (!PyArg_ParseTuple(args,
"OOOO", &retaddr, &jitcpu, &lbl2ptr, &breakpoints))
153 func_py = PyDict_GetItem(lbl2ptr, retaddr);
155 func = (
jitted_func) PyInt_AsLong((PyObject*) func_py);
158 fprintf(stderr,
"return on local label!\n");
166 status = func(&BlockDst, jitcpu);
168 retaddr = PyLong_FromUnsignedLongLong(BlockDst.
address);
175 if (PyDict_Contains(breakpoints, retaddr))
int(* jitted_func)(block_id *, PyObject *)
TCCState* tcc_init_state |
( |
void |
| ) |
|
Definition at line 37 of file Jittcc.c.
40 TCCState *tcc_state = NULL;
41 tcc_state = tcc_new();
43 fprintf(stderr,
"Impossible de creer un contexte TCC\n");
46 tcc_set_output_type(tcc_state, TCC_OUTPUT_MEMORY);
PyObject* tcc_loop_exec |
( |
PyObject * |
self, |
|
|
PyObject * |
args |
|
) |
| |
Definition at line 226 of file Jittcc.c.
236 if (!PyArg_ParseTuple(args,
"OKK", &func, &cpu, &vm))
240 if (!PyCallable_Check (func)) {
241 fprintf(stderr,
"function not callable!\n");
245 pArgs = PyTuple_New(2);
246 PyTuple_SetItem(pArgs, 0, PyLong_FromUnsignedLongLong((uint64_t)cpu));
247 PyTuple_SetItem(pArgs, 1, PyLong_FromUnsignedLongLong((uint64_t)vm));
248 ret = PyObject_CallObject(func, pArgs);
251 if (ret == Py_None) {
PyObject* tcc_set_emul_lib_path |
( |
PyObject * |
self, |
|
|
PyObject * |
args |
|
) |
| |
Definition at line 71 of file Jittcc.c.
76 char* str1, * str2, * init_ptr;
77 if (!PyArg_ParseTuple(args,
"ss",
82 init_ptr = str2 = strdup(include_arg);
84 str1 = strsep(&str2,
";");
96 init_ptr = str2 = strdup(lib_arg);
98 str1 = strsep(&str2,
";");
107 if (init_ptr != NULL)
char** include_array = NULL |
int include_array_count = 0 |
Initial value:= {
"init tcc path"},
"tcc exec bloc"},
"tcc compil"},
"tcc end"},
{NULL, NULL, 0, NULL}
}
PyObject * tcc_set_emul_lib_path(PyObject *self, PyObject *args)
PyObject * tcc_exec_bloc(PyObject *self, PyObject *args)
PyObject * tcc_end(PyObject *self, PyObject *args)
PyObject * tcc_compil(PyObject *self, PyObject *args)
Definition at line 266 of file Jittcc.c.