diff options
author | Guido van Rossum <guido@python.org> | 1998-10-07 19:42:25 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-07 19:42:25 (GMT) |
commit | d076c73cc81a974794c9aa7e812931b74d6e03c2 (patch) | |
tree | 55b5c7b6c145d5491c2dd63780c9654c51aa2306 /Python/ceval.c | |
parent | 437ff8600a2959e87194f1491ba99116d73ea543 (diff) | |
download | cpython-d076c73cc81a974794c9aa7e812931b74d6e03c2.zip cpython-d076c73cc81a974794c9aa7e812931b74d6e03c2.tar.gz cpython-d076c73cc81a974794c9aa7e812931b74d6e03c2.tar.bz2 |
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index b004c79..413b316 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); |