From d076c73cc81a974794c9aa7e812931b74d6e03c2 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 7 Oct 1998 19:42:25 +0000 Subject: Changes to support other object types besides strings as the code string of code objects, as long as they support the (readonly) buffer interface. By Greg Stein. --- Python/ceval.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Python/ceval.c') diff --git a/Python/ceval.c b/Python/ceval.c index b004c79640..413b316dfd 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -366,6 +366,7 @@ eval_code2(co, globals, locals, register PyObject **fastlocals = NULL; PyObject *retval = NULL; /* Return value */ PyThreadState *tstate = PyThreadState_Get(); + unsigned char *first_instr; #ifdef LLTRACE int lltrace; #endif @@ -379,11 +380,10 @@ eval_code2(co, globals, locals, #define GETCONST(i) Getconst(f, i) #define GETNAME(i) Getname(f, i) #define GETNAMEV(i) Getnamev(f, i) -#define FIRST_INSTR() (GETUSTRINGVALUE(co->co_code)) -#define INSTR_OFFSET() (next_instr - FIRST_INSTR()) +#define INSTR_OFFSET() (next_instr - first_instr) #define NEXTOP() (*next_instr++) #define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) -#define JUMPTO(x) (next_instr = FIRST_INSTR() + (x)) +#define JUMPTO(x) (next_instr = first_instr + (x)) #define JUMPBY(x) (next_instr += (x)) /* Stack manipulation macros */ @@ -580,7 +580,8 @@ eval_code2(co, globals, locals, return NULL; } - next_instr = GETUSTRINGVALUE(co->co_code); + _PyCode_GETCODEPTR(co, &first_instr); + next_instr = first_instr; stack_pointer = f->f_valuestack; why = WHY_NOT; @@ -2801,7 +2802,9 @@ find_from_args(f, nexti) PyObject *list, *name; unsigned char *next_instr; - next_instr = GETUSTRINGVALUE(f->f_code->co_code) + nexti; + _PyCode_GETCODEPTR(f->f_code, &next_instr); + next_instr += nexti; + opcode = (*next_instr++); if (opcode != IMPORT_FROM) { Py_INCREF(Py_None); -- cgit v1.2.1