summaryrefslogtreecommitdiff
path: root/cad/src/experimental/pyrex-atoms-bonds/iguana/ighelp.h
blob: 35572ea26e6747f96c5dc0651b4abbc2baef1542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2006-2007 Nanorex, Inc.  See LICENSE file for details. 

#define RETURN_STACK_SIZE 100

typedef union {
    int ival;
    double dval;
} program_entry;

typedef struct _ig_thread
{
    PyObject_HEAD struct _ig_thread *prev, *next;
    double *data_stack;
    unsigned int return_stack[RETURN_STACK_SIZE];
    int stacksize, dspointer, rspointer, program_counter, program_size, finished;
    program_entry *program;
    PyObject *memory;
} iguana_thread_object;

typedef int (*igverbfunc) (iguana_thread_object *, int);

#define ASSERT(cond) \
if (!(cond)) \
{ \
  PyErr_SetString(PyExc_AssertionError, #cond); \
  return EVILRETURN; \
}

#define CHECK_UNDERFLOW(n) \
    ASSERT(self->dspointer >= n)
#define CHECK_OVERFLOW(n) \
    ASSERT(self->dspointer < self->stacksize - n)
#define R_CHECK_UNDERFLOW(n) \
    ASSERT(self->rspointer >= n)
#define R_CHECK_OVERFLOW(n) \
    ASSERT(self->rspointer < RETURN_STACK_SIZE - n)