Browse Source

Make some test pass with CTurmit

Yann Weber 6 years ago
parent
commit
d01186c773
7 changed files with 320 additions and 57 deletions
  1. 10
    1
      gte/__init__.py
  2. 6
    6
      libs/Makefile
  3. 171
    2
      libs/cturmit.c
  4. 39
    18
      libs/cturmit.h
  5. 34
    14
      libs/turmit.c
  6. 56
    15
      libs/turmit.h
  7. 4
    1
      tests/test_turmit.py

+ 10
- 1
gte/__init__.py View File

@@ -1,4 +1,13 @@
1 1
 ##@brief GTE Genetic Turmits Evolver
2 2
 
3
-from . import turmit
3
+try:
4
+	import cturmit as turmit
5
+	print(turmit.CTurmit)
6
+	Turmit = turmit.CTurmit
7
+	print("WOO")
8
+except ImportError:
9
+	from . import turmit
10
+	from .turmit import Turmit
11
+
12
+
4 13
 from . import rpnlib

+ 6
- 6
libs/Makefile View File

@@ -1,15 +1,15 @@
1 1
 PYTHON=/usr/bin/python3
2
+CFLAGS=-Wall -Werror -O0 -g
3
+CC=gcc $(CFLAGS) 
4
+#CFLAGS=-Wall -Werror
2 5
 
3 6
 all: cturmit*.so
4 7
 
5
-turmit.o: turmit.c turmit.h
6
-	gcc -c turmit.c
7
-
8
-cturmit*.so: setup.py build/lib.*/cturmit*.so turmit.o
8
+cturmit*.so: setup.py build/lib.*/cturmit*.so
9 9
 	cp build/lib.*/cturmit*.so ./
10 10
 
11
-build/lib.*/cturmit*.so: cturmit.c cturmit.h
12
-	$(PYTHON) setup.py --verbose build
11
+build/lib.*/cturmit*.so: cturmit.c cturmit.h turmit.c turmit.h
12
+	make clean; CFLAGS="$(CFLAGS)" $(PYTHON) setup.py --verbose build
13 13
 
14 14
 .PHONY: clean
15 15
 

+ 171
- 2
libs/cturmit.c View File

@@ -18,16 +18,185 @@ PyInit_cturmit(void)
18 18
 	return m;
19 19
 }
20 20
 
21
-	void
21
+static int
22
+CTurmit_init(CTurmit *self, PyObject *args, PyObject *kwds)
23
+{
24
+	size_t sz;
25
+	char err_msg[128];
26
+	ssize_t arg_stk_sz, arg_int_max;
27
+	char *arg_expr;
28
+	PyObject *stack_size, *int_max, *expr;
29
+	PyObject *errtype, *errvalue, *errbck;
30
+	
31
+	PyErr_Fetch(&errtype, &errvalue, &errbck);
32
+
33
+	stack_size = int_max = expr = NULL;
34
+	self->turmit = NULL;
35
+
36
+	//Checking arguments
37
+	if((sz = PySequence_Length(args)) >= 0)
38
+	{
39
+		if(sz > 1)
40
+		{
41
+			PyErr_Restore(errtype, errvalue, errbck);
42
+			snprintf(err_msg, 128, "1 positional argument expected \
43
+but %ld found", sz);
44
+			PyErr_SetString(PyExc_TypeError, err_msg);
45
+			return -1;
46
+		}
47
+		stack_size = PySequence_GetItem(args, 0);
48
+	}
49
+	if(!stack_size)
50
+	{
51
+		stack_size = stack_size?stack_size:\
52
+			PyMapping_GetItemString(kwds, "stack_size");
53
+		if(stack_size && !PyLong_CheckExact(stack_size))
54
+		{
55
+			PyErr_Restore(errtype, errvalue, errbck);
56
+			PyErr_SetString(PyExc_TypeError,
57
+				"stack_size expected to be an integer");
58
+			return -1;
59
+		}
60
+	}
61
+	if(stack_size)
62
+	{
63
+		arg_stk_sz = PyLong_AsSize_t(stack_size);
64
+		if(arg_stk_sz == (size_t)-1 && PyErr_Occurred())
65
+		{
66
+			PyErr_Restore(errtype, errvalue, errbck);
67
+			PyErr_SetString(PyExc_TypeError,
68
+				"size_t overflow with stack_size");
69
+			return -1;
70
+		}
71
+	}
72
+	else
73
+	{
74
+		arg_stk_sz = 8;
75
+	}
76
+
77
+	int_max = PyMapping_GetItemString(kwds, "int_max");
78
+	if(int_max && !PyLong_CheckExact(int_max))
79
+	{
80
+		PyErr_Restore(errtype, errvalue, errbck);
81
+		PyErr_SetString(PyExc_TypeError,
82
+			"stack_size expected to be an integer");
83
+		return -1;
84
+	}
85
+	if(int_max)
86
+	{
87
+		arg_int_max = PyLong_AsSize_t(stack_size);
88
+		if(arg_int_max == (size_t)-1 && PyErr_Occurred())
89
+		{
90
+			PyErr_SetString(PyExc_TypeError,
91
+				"size_t overflow with stack_size");
92
+		}
93
+	}
94
+	else
95
+	{
96
+		arg_int_max = 0x100000;
97
+	}
98
+
99
+	expr = PyMapping_GetItemString(kwds, "prog");
100
+	if(expr && !PyUnicode_Check(expr))
101
+	{
102
+		PyErr_Restore(errtype, errvalue, errbck);
103
+		PyErr_SetString(PyExc_TypeError,
104
+			"prog expected to be a string");
105
+		return -1;
106
+	}
107
+	if(expr)
108
+	{
109
+		expr = PyUnicode_AsASCIIString(expr);
110
+		if(!expr)
111
+		{
112
+			PyErr_Restore(errtype, errvalue, errbck);
113
+			PyErr_SetString(PyExc_TypeError,
114
+				"prog expected to be an ASCII string");
115
+			return -1;
116
+		}
117
+		arg_expr = (char*)PyBytes_AsString(expr);
118
+		if(!arg_expr)
119
+		{
120
+			PyErr_Restore(errtype, errvalue, errbck);
121
+			PyErr_SetString(PyExc_TypeError,
122
+				"Unable to convert prog to Cstring");
123
+			return -1;
124
+		}
125
+	}
126
+	else
127
+	{
128
+		arg_expr = "";
129
+	}
130
+
131
+	PyErr_Restore(errtype, errvalue, errbck);
132
+	self->turmit = turmit_alloc(arg_stk_sz, arg_int_max, arg_expr,
133
+		TURMIT_AUTOCOMP);
134
+	return 0;
135
+}
136
+
137
+static PyObject *
138
+CTurmit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
139
+{
140
+	CTurmit *self;
141
+	self = (CTurmit *)type->tp_alloc(type, 0);
142
+	if(self != NULL) {
143
+		//do stuff
144
+	}
145
+	return (PyObject *)self;
146
+}
147
+
148
+void
22 149
 CTurmit_dealloc(CTurmit *self)
23 150
 {
151
+	if(self->turmit) { turmit_free(self->turmit); }
24 152
 	Py_TYPE(self)->tp_free((PyObject*)self);
25 153
 }
26 154
 
27
-	Py_ssize_t
155
+Py_ssize_t
28 156
 CTurmit_len(CTurmit *self)
29 157
 {
30 158
 	return self->len;
31 159
 }
32 160
 
161
+PyObject* CTurmit__push(CTurmit* self, PyObject *args)
162
+{
163
+	char err_msg[128];
164
+	size_t sz;
165
+	turmit_int ival;
166
+	PyObject *val;
167
+	PyObject *errtype, *errvalue, *errbck;
168
+
169
+	PyErr_Fetch(&errtype, &errvalue, &errbck);
170
+
171
+	if((sz = PySequence_Length(args)) >= 0)
172
+	{
173
+		if(sz > 1)
174
+		{
175
+			PyErr_Restore(errtype, errvalue, errbck);
176
+			snprintf(err_msg, 128, "1 positional argument expected \
177
+but %ld found", sz);
178
+			PyErr_SetString(PyExc_TypeError, err_msg);
179
+			Py_RETURN_NONE;
180
+		}
181
+		val = PySequence_GetItem(args, 0);
182
+	}
183
+	if(!val)
184
+	{
185
+		PyErr_Restore(errtype, errvalue, errbck);
186
+		PyErr_SetString(PyExc_TypeError,
187
+			"Argument val is missing");
188
+		Py_RETURN_NONE;
189
+
190
+	}
191
+	ival = PyLong_AsSize_t(val);
192
+	if(ival == (size_t)-1 && PyErr_Occurred()) { Py_RETURN_NONE; }
193
+	SPUSH(self->turmit, ival);
194
+	PyErr_Restore(errtype, errvalue, errbck);
195
+	Py_RETURN_NONE;
196
+}
197
+
198
+PyObject* CTurmit_get__cur(CTurmit *self, void *ref)
199
+{
200
+	return PyLong_FromSsize_t(self->turmit->stack_cur);
201
+}
33 202
 

+ 39
- 18
libs/cturmit.h View File

@@ -6,7 +6,9 @@
6 6
 typedef struct
7 7
 {
8 8
 	PyObject VAR_HEAD;
9
+	
9 10
 	Py_ssize_t len;
11
+	turmit_t *turmit;
10 12
 } CTurmit;
11 13
 
12 14
 static PyModuleDef cturmitmodule = {
@@ -28,38 +30,57 @@ static PyMemberDef CTurmit_members[] = {
28 30
 	{NULL}  /* Sentinel */
29 31
 };
30 32
 
33
+/*
34
+	Magic methods
35
+*/
31 36
 Py_ssize_t CTurmit_len(CTurmit*);
32 37
 
33 38
 static PyMappingMethods CTurmit_asmapping[] = {{
34 39
 	(void*)CTurmit_len,
35 40
 }};
36 41
 
42
+/*
43
+	Other methods
44
+*/
45
+#define TURMIT_PYOP(NAME) PyObject* CTurmit_op_##NAME(CTurmit* self) {\
46
+	turmit_op_##NAME(self->turmit);\
47
+	Py_RETURN_NONE;\
48
+}
49
+#define TURMIT_PYOPDEF(NAME) {#NAME, (PyCFunction)CTurmit_op_##NAME, \
50
+	METH_NOARGS, NULL}
51
+
52
+PyObject* CTurmit__push(CTurmit* self, PyObject *args);
53
+TURMIT_PYOP(add)
54
+
37 55
 static PyMethodDef CTurmit_methods[] = {
56
+	{"_push", (PyCFunction)CTurmit__push, METH_KEYWORDS | METH_VARARGS,
57
+		"Push a value on the stack"},
58
+	TURMIT_PYOPDEF(add),
38 59
 	{NULL}  /* Sentinel */
39 60
 };
40 61
 
62
+PyObject* CTurmit_get__cur(CTurmit *self, void *ref);
41 63
 
42
-	static PyObject *
43
-CTurmit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
44
-{
45
-	CTurmit *self;
46
-	self = (CTurmit *)type->tp_alloc(type, 0);
47
-	if(self != NULL) {
48
-		//do stuff
49
-	}
50
-	return (PyObject *)self;
51
-}
64
+static struct PyGetSetDef CTurmit_getset[] = {
65
+	{"_cur", (getter)CTurmit_get__cur, NULL, NULL, NULL},
66
+	{NULL}  /* Sentinel */
67
+};
68
+
69
+static PyObject *
70
+CTurmit_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
71
+
72
+/**@brief CTurmit __init__ function
73
+ * @param CTurmit* self
74
+ * @param PyObject* can contain an interger representing stack size
75
+ * @param Pyobject* contains kwargs. Can be : stack_size, max_int, prog
76
+ */
77
+static int
78
+CTurmit_init(CTurmit *self, PyObject *args, PyObject *kwds);
52 79
 
53 80
 void
54 81
 CTurmit_dealloc(CTurmit *self);
55 82
 
56
-	static int
57
-CTurmit_init(CTurmit *self, PyObject *args, PyObject *kwds)
58
-{
59
-	//Init attributes
60
-	self->len = 0;
61
-	return 0;
62
-}
83
+
63 84
 
64 85
 static PyTypeObject CTurmitType = {
65 86
 	PyVarObject_HEAD_INIT(NULL, 0)
@@ -91,7 +112,7 @@ static PyTypeObject CTurmitType = {
91 112
 	0,						/* tp_iternext */
92 113
 	CTurmit_methods,				/* tp_methods */
93 114
 	CTurmit_members,				/* tp_members */
94
-	0,						/* tp_getset */
115
+	CTurmit_getset,					/* tp_getset */
95 116
 	0,						/* tp_base */
96 117
 	0,						/* tp_dict */
97 118
 	0,						/* tp_descr_get */

+ 34
- 14
libs/turmit.c View File

@@ -10,6 +10,8 @@ TURMIT_OP(mem_sz)
10 10
 	new_sz = new_sz<2?2:new_sz;
11 11
 
12 12
 	new = realloc(turmit->stack, sizeof(turmit_int) * new_sz);
13
+	if(!new) { return; }
14
+	turmit->stack = new;
13 15
 	if(old_sz < new_sz)
14 16
 	{
15 17
 		bzero(turmit->stack + old_sz, new_sz - old_sz);
@@ -33,7 +35,8 @@ TURMIT_OP(bin_and)
33 35
 
34 36
 TURMIT_OP(dup)
35 37
 {
36
-	SPUSH(turmit, SCUR(turmit));
38
+	turmit_int a = SCUR(turmit);
39
+	SPUSH(turmit, a);
37 40
 }
38 41
 
39 42
 TURMIT_OP(lshift)
@@ -110,8 +113,8 @@ TURMIT_OP(jcmp)
110 113
 	cnd = SPOP(turmit);
111 114
 	b = SPOP(turmit);
112 115
 	a = SPOP(turmit);
113
-	if((cnd & 7 == 0 && a != b) || (cnd > 6) || (cnd & 1 && a == b) ||
114
-		(cnd & 7 > 2 && a < b) || (cnd & 7 > 4 && a > b))
116
+	if(((cnd & 7) == 0 && a != b) || (cnd > 6) || ((cnd & 1) && a == b) ||
117
+		((cnd & 7) > 2 && a < b) || ((cnd & 7) > 4 && a > b))
115 118
 	{
116 119
 		turmit->op_cur += offset - 1;
117 120
 	}
@@ -134,8 +137,6 @@ turmit_t *turmit_alloc(ssize_t stack_sz, ssize_t int_max, const char *expr,
134 137
 turmit_t *turmit_init(turmit_t *turmit, ssize_t stack_sz, ssize_t int_max,
135 138
 	const char *expr, unsigned char flags)
136 139
 {
137
-	int ret;
138
-
139 140
 	turmit->expr = strndup(expr, TURMIT_EXPR_MAX_SZ);
140 141
 	turmit->flags = flags;
141 142
 	turmit->int_max = int_max;
@@ -144,7 +145,7 @@ turmit_t *turmit_init(turmit_t *turmit, ssize_t stack_sz, ssize_t int_max,
144 145
 	turmit->op_cur = 0;
145 146
 	turmit->stack_sz = stack_sz;
146 147
 	turmit->stack = malloc(sizeof(turmit_int) * turmit->stack_sz);
147
-	turmit->stack_cur = 0;
148
+	turmit->stack_cur = turmit->stack_sz - 1;
148 149
 
149 150
 	if(turmit->flags & TURMIT_AUTOCOMP)
150 151
 	{
@@ -153,6 +154,19 @@ turmit_t *turmit_init(turmit_t *turmit, ssize_t stack_sz, ssize_t int_max,
153 154
 	return turmit;
154 155
 }
155 156
 
157
+void turmit_clean(turmit_t *turmit)
158
+{
159
+	if(turmit->expr) { free(turmit->expr); }
160
+	if(turmit->op_expr) { free(turmit->op_expr); }
161
+
162
+}
163
+
164
+void turmit_free(turmit_t *turmit)
165
+{
166
+	turmit_clean(turmit);
167
+	free(turmit);
168
+}
169
+
156 170
 turmit_int turmit_exec(turmit_t *turmit, const turmit_int args[5])
157 171
 {
158 172
 	turmit_op_t *op;
@@ -164,7 +178,7 @@ turmit_int turmit_exec(turmit_t *turmit, const turmit_int args[5])
164 178
 		switch(op->value)
165 179
 		{
166 180
 		case 1:
167
-			op->op.op(turmit, args);
181
+			op->op.op(turmit);
168 182
 			break;
169 183
 		case 2:
170 184
 			SPUSH(turmit, op->op.val);
@@ -185,8 +199,11 @@ turmit_int turmit_exec(turmit_t *turmit, const turmit_int args[5])
185 199
 
186 200
 int turmit_compile(turmit_t *turmit)
187 201
 {
188
-	char *cur, *endptr, *vptr;
202
+#pragma GCC diagnostic push
203
+#pragma GCC diagnostic ignored "-Wmissing-braces"
189 204
 	turmit_sym_t tsym[] = TURMIT_OP_LST;
205
+#pragma GCC diagnostic pop
206
+	char *cur, *endptr;
190 207
 	turmit_sym_t *isym;
191 208
 	ssize_t opcur;
192 209
 	turmit_op_t *pret;
@@ -194,7 +211,6 @@ int turmit_compile(turmit_t *turmit)
194 211
 	int err;
195 212
 	int i;
196 213
 
197
-
198 214
 	turmit->op_expr_sz = 64;
199 215
 	turmit->op_expr = malloc(sizeof(turmit_op_t) * turmit->op_expr_sz);
200 216
 	bzero(turmit->op_expr, sizeof(turmit_op_t) * turmit->op_expr_sz);
@@ -204,7 +220,7 @@ int turmit_compile(turmit_t *turmit)
204 220
 	while(*cur != '\0')
205 221
 	{
206 222
 		if(opcur >= turmit->op_expr_sz - 1)
207
-		{
223
+		{	//more space needed
208 224
 			turmit->op_expr_sz += 64;
209 225
 			pret = realloc(turmit->op_expr,
210 226
 				sizeof(turmit_op_t) * turmit->op_expr_sz);
@@ -218,10 +234,14 @@ int turmit_compile(turmit_t *turmit)
218 234
 			turmit->op_expr = pret;
219 235
 		}
220 236
 		//Checking for separators
221
-		if(*cur == ' ' || *cur == '\t' || *cur == ' ') { continue; }
237
+		if(*cur == ' ' || *cur == '\t' || *cur == ' ')
238
+		{
239
+			cur++;
240
+			continue;
241
+		}
222 242
 
223 243
 		//Checking for variables
224
-		for(vptr = TURMIT_VAR_L; *vptr != '\0'; vptr++)
244
+		for(i=0; TURMIT_VAR_L[i] != '\0'; i++)
225 245
 		{
226 246
 			if(tolower(*cur) == TURMIT_VAR_L[i])
227 247
 			{
@@ -232,7 +252,7 @@ int turmit_compile(turmit_t *turmit)
232 252
 				break;
233 253
 			}
234 254
 		}
235
-		if(*vptr != '\0') { continue; }
255
+		if(TURMIT_VAR_L[i] != '\0') { continue; }
236 256
 
237 257
 		//Checking for values
238 258
 		if(strcasecmp("0x", cur) == 0)
@@ -258,7 +278,7 @@ int turmit_compile(turmit_t *turmit)
258 278
 		while(isym->str != NULL)
259 279
 		{
260 280
 			if(strcasecmp(isym->str, cur) == 0 ||
261
-				isym->alias != '\0' && *cur == isym->alias)
281
+				(isym->alias && strncmp(cur, isym->alias,3)))
262 282
 			{
263 283
 				cur += strlen(isym->str);
264 284
 				turmit->op_expr[opcur].op.op = isym->op_fun;

+ 56
- 15
libs/turmit.h View File

@@ -1,3 +1,6 @@
1
+#ifndef _TURMIT_H_
2
+#define _TURMIT_H_
3
+
1 4
 #include <stdlib.h>
2 5
 #include <stdio.h>
3 6
 #include <string.h>
@@ -11,6 +14,7 @@ typedef unsigned long long int turmit_int;
11 14
 typedef struct turmit_op_s turmit_op_t;
12 15
 typedef struct turmit_s turmit_t;
13 16
 typedef struct turmit_sym_s turmit_sym_t;
17
+typedef void (*turmit_op_f)(turmit_t*);
14 18
 
15 19
 #define SCUR(t) (t->stack[t->stack_cur])
16 20
 #define SDEC(t) (t->stack_cur = (t->stack_cur>0?t->stack_cur:t->stack_sz) -1)
@@ -33,19 +37,21 @@ typedef struct turmit_sym_s turmit_sym_t;
33 37
 
34 38
 #define TURMIT_VAR_L		"xyrgb"
35 39
 
36
-#define TURMIT_OPSYM(NAME) {#NAME, '\0', op_##NAME}
37
-#define TURMIT_OPSYMALIAS(NAME, alias) {#NAME, alias, op_##NAME}
40
+#define TURMIT_OPSYM(NAME) {#NAME, NULL, turmit_op_##NAME}
41
+#define TURMIT_OPSYMALIAS(NAME, alias) {#NAME, alias, turmit_op_##NAME}
42
+
38 43
 
39 44
 // OPSYMALIAS has to be first !
40 45
 #define TURMIT_OP_LST {\
41
-	TURMIT_OPSYMALIAS(add, '+'),\
42
-	TURMIT_OPSYMALIAS(sub, '-'),\
43
-	TURMIT_OPSYMALIAS(mul, '*'),\
44
-	TURMIT_OPSYMALIAS(div, '/'),\
45
-	TURMIT_OPSYMALIAS(mod, '%'),\
46
-	TURMIT_OPSYMALIAS(bin_or, '|'),\
47
-	TURMIT_OPSYMALIAS(bin_and, '&'),\
48
-	TURMIT_OPSYMALIAS(bin_xor, '^'),\
46
+	TURMIT_OPSYMALIAS(add, "+"),\
47
+	TURMIT_OPSYMALIAS(sub, "-"),\
48
+	TURMIT_OPSYMALIAS(mul, "*"),\
49
+	TURMIT_OPSYMALIAS(div, "/"),\
50
+	TURMIT_OPSYMALIAS(mod, "%"),\
51
+	TURMIT_OPSYMALIAS(bin_or, "|"),\
52
+	TURMIT_OPSYMALIAS(bin_and, "&"),\
53
+	TURMIT_OPSYMALIAS(bin_xor, "^"),\
54
+	TURMIT_OPSYMALIAS(lshift, "<<"),\
49 55
 	TURMIT_OPSYM(mem_sz),\
50 56
 	TURMIT_OPSYM(dup),\
51 57
 	TURMIT_OPSYM(pop),\
@@ -59,13 +65,13 @@ typedef struct turmit_sym_s turmit_sym_t;
59 65
 struct turmit_sym_s
60 66
 {
61 67
 	char *str;
62
-	char alias;
63
-	void (*op_fun)(turmit_t*, const turmit_int[5]);
68
+	char *alias;
69
+	turmit_op_f op_fun;
64 70
 };
65 71
 
66 72
 union turmit_op_u
67 73
 {
68
-	void (*op)(turmit_t*, const turmit_int[5]);
74
+	turmit_op_f op;
69 75
 	turmit_int val;
70 76
 	short var; /*!< interpreted % 5 */
71 77
 };
@@ -99,8 +105,7 @@ inline static turmit_int __SPOP(turmit_t *t) {
99 105
 }
100 106
 
101 107
 
102
-#define TURMIT_OP(NAME) static void op_##NAME (turmit_t *turmit, \
103
-	const turmit_int args[5])
108
+#define TURMIT_OP(NAME) void turmit_op_##NAME (turmit_t *turmit)
104 109
 
105 110
 /**@brief Allocate memory and initialise a turmit
106 111
  * @param const char* The turmit expression
@@ -119,6 +124,8 @@ turmit_t *turmit_alloc(ssize_t stack_sz, ssize_t int_max, const char *expr,
119 124
 turmit_t *turmit_init(turmit_t *turmit, ssize_t stack_sz, ssize_t int_max,
120 125
 	const char *expr, unsigned char flags);
121 126
 
127
+void turmit_clean(turmit_t *turmit);
128
+
122 129
 /**@brief Free memory of a turmit
123 130
  * @param turmit the turmit to free
124 131
  */
@@ -136,3 +143,37 @@ turmit_int turmit_exec(turmit_t *turmit, const turmit_int args[5]);
136 143
  */
137 144
 int turmit_compile(turmit_t *turmit);
138 145
 
146
+TURMIT_OP(mem_sz);
147
+
148
+TURMIT_OP(add);
149
+
150
+TURMIT_OP(sub);
151
+
152
+TURMIT_OP(bin_and);
153
+
154
+TURMIT_OP(dup);
155
+
156
+TURMIT_OP(lshift);
157
+
158
+TURMIT_OP(mod);
159
+
160
+TURMIT_OP(mul);
161
+
162
+TURMIT_OP(div);
163
+
164
+TURMIT_OP(bin_or);
165
+
166
+TURMIT_OP(bin_xor);
167
+
168
+TURMIT_OP(pop);
169
+
170
+TURMIT_OP(swp);
171
+
172
+TURMIT_OP(jmp);
173
+
174
+TURMIT_OP(jz);
175
+
176
+TURMIT_OP(jcmp);
177
+
178
+#endif
179
+

+ 4
- 1
tests/test_turmit.py View File

@@ -1,7 +1,10 @@
1 1
 import unittest
2 2
 import inspect
3 3
 
4
-from gte.turmit import Turmit
4
+import gte
5
+Turmit = gte.Turmit
6
+#from gte import Turmit
7
+print(Turmit)
5 8
 from gte.rpnlib import _op_list
6 9
 
7 10
 class TurmitTestCase(unittest.TestCase):

Loading…
Cancel
Save