Mercurial > cpython-lru_cache-weakref
annotate Python/ceval.c @ 708:8bcb50f436fa legacy-trunk
New trace implementation; and profile (in a similat vein).
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 23 Mar 1992 18:19:28 +0000 |
| parents | 5b71863c801d |
| children | 6c0f16008bd9 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
1 /*********************************************************** |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
2 Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
3 Netherlands. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
4 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
5 All Rights Reserved |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
6 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
14 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
22 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
23 ******************************************************************/ |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
24 |
| 86 | 25 /* Execute compiled code */ |
| 69 | 26 |
| 86 | 27 #include "allobjects.h" |
| 28 | |
| 69 | 29 #include "import.h" |
| 30 #include "sysmodule.h" | |
| 31 #include "compile.h" | |
| 86 | 32 #include "frameobject.h" |
| 33 #include "ceval.h" | |
| 69 | 34 #include "opcode.h" |
| 119 | 35 #include "bltinmodule.h" |
| 86 | 36 #include "traceback.h" |
| 69 | 37 |
| 86 | 38 #ifndef NDEBUG |
| 567 | 39 /* For debugging the interpreter: */ |
| 40 #define LLTRACE 1 /* Low-level trace feature */ | |
| 41 #define CHECKEXC 1 /* Double-check exception checking */ | |
| 69 | 42 #endif |
| 43 | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
44 /* Forward declarations */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
45 /* XXX Need prototypes */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
46 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
47 void flushline(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
48 static object *add(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
49 static object *sub(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
50 static object *mul(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
51 static object *divide(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
52 static object *rem(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
53 static object *neg(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
54 static object *pos(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
55 static object *not(); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
56 static object *invert(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
57 static object *lshift(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
58 static object *rshift(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
59 static object *and(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
60 static object *xor(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
61 static object *or(); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
62 static object *call_builtin(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
63 static object *call_function(); |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
64 object *call_object(); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
65 static object *apply_subscript(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
66 static object *loop_subscript(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
67 static object *apply_slice(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
68 static object *cmp_outcome(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
69 static object *build_class(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
70 static int testbool(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
71 static int assign_subscript PROTO((object *, object *, object *)); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
72 static int assign_slice PROTO((object *, object *, object *, object *)); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
73 static int import_from PROTO((object *, object *, object *)); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
74 static void call_exc_trace PROTO((object **, object**, frameobject *)); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
75 static int call_trace |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
76 PROTO((object **, object **, frameobject *, char *, object *)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
77 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
78 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
79 static frameobject *current_frame; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
80 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
81 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
82 /* Status code for main loop (reason for stack unwind) */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
83 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
84 enum why_code { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
85 WHY_NOT, /* No error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
86 WHY_EXCEPTION, /* Exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
87 WHY_RERAISE, /* Exception re-raised by 'finally' */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
88 WHY_RETURN, /* 'return' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
89 WHY_BREAK /* 'break' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
90 }; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
91 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
92 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
93 /* Interpreter main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
94 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
95 object * |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
96 eval_code(co, globals, locals, arg) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
97 codeobject *co; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
98 object *globals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
99 object *locals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
100 object *arg; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
101 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
102 register unsigned char *next_instr; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
103 register int opcode; /* Current opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
104 register int oparg; /* Current opcode argument, if any */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
105 register object **stack_pointer; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
106 register enum why_code why; /* Reason for block stack unwind */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
107 register int err; /* Error status -- nonzero if error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
108 register object *x; /* Result object -- NULL if error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
109 register object *v; /* Temporary objects popped off stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
110 register object *w; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
111 register object *u; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
112 register object *t; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
113 register frameobject *f; /* Current frame */ |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
114 object *trace = NULL; /* Trace function or NULL */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
115 object *retval; /* Return value iff why == WHY_RETURN */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
116 char *name; /* Name used by some instructions */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
117 FILE *fp; /* Used by print operations */ |
| 567 | 118 #ifdef LLTRACE |
| 119 int lltrace = dictlookup(globals, "__lltrace__") != NULL; | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
120 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
121 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
122 /* Code access macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
123 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
124 #define GETCONST(i) Getconst(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
125 #define GETNAME(i) Getname(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
126 #define GETNAMEV(i) Getnamev(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
127 #define FIRST_INSTR() (GETUSTRINGVALUE(f->f_code->co_code)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
128 #define INSTR_OFFSET() (next_instr - FIRST_INSTR()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
129 #define NEXTOP() (*next_instr++) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
130 #define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
131 #define JUMPTO(x) (next_instr = FIRST_INSTR() + (x)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
132 #define JUMPBY(x) (next_instr += (x)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
133 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
134 /* Stack manipulation macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
135 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
136 #define STACK_LEVEL() (stack_pointer - f->f_valuestack) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
137 #define EMPTY() (STACK_LEVEL() == 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
138 #define TOP() (stack_pointer[-1]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
139 #define BASIC_PUSH(v) (*stack_pointer++ = (v)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
140 #define BASIC_POP() (*--stack_pointer) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
141 |
| 567 | 142 #ifdef LLTRACE |
| 143 #define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) | |
| 144 #define POP() (lltrace && prtrace(TOP(), "pop"), BASIC_POP()) | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
145 #else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
146 #define PUSH(v) BASIC_PUSH(v) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
147 #define POP() BASIC_POP() |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
148 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
149 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
150 f = newframeobject( |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
151 current_frame, /*back*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
152 co, /*code*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
153 globals, /*globals*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
154 locals, /*locals*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
155 50, /*nvalues*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
156 20); /*nblocks*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
157 if (f == NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
158 return NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
159 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
160 current_frame = f; |
| 567 | 161 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
162 if (sys_trace != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
163 /* sys_trace, if defined, is a function that will |
| 567 | 164 be called on *every* entry to a code block. |
| 165 Its return value, if not None, is a function that | |
| 166 will be called at the start of each executed line | |
| 167 of code. (Actually, the function must return | |
| 168 itself in order to continue tracing.) | |
| 169 The trace functions are called with three arguments: | |
| 170 a pointer to the current frame, a string indicating | |
| 171 why the function is called, and an argument which | |
| 172 depends on the situation. The global trace function | |
| 173 (sys.trace) is also called whenever an exception | |
| 174 is detected. */ | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
175 if (call_trace(&sys_trace, &trace, f, "call", arg)) { |
| 567 | 176 /* Trace function raised an error */ |
| 177 current_frame = f->f_back; | |
| 178 DECREF(f); | |
| 179 return NULL; | |
| 180 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
181 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
182 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
183 if (sys_profile != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
184 /* Similar for sys_profile, except it needn't return |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
185 itself and isn't called for "line" events */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
186 if (call_trace(&sys_profile, (object**)0, f, "call", arg)) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
187 current_frame = f->f_back; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
188 DECREF(f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
189 return NULL; |
| 567 | 190 } |
| 191 } | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
192 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
193 next_instr = GETUSTRINGVALUE(f->f_code->co_code); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
194 stack_pointer = f->f_valuestack; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
195 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
196 if (arg != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
197 INCREF(arg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
198 PUSH(arg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
199 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
200 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
201 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
202 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
203 x = None; /* Not a reference, just anything non-NULL */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
204 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
205 for (;;) { |
|
237
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
206 static int ticker; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
207 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
208 /* Do periodic things */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
209 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
210 if (--ticker < 0) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
211 ticker = 100; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
212 if (intrcheck()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
213 err_set(KeyboardInterrupt); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
214 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
215 goto on_error; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
216 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
217 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
218 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
219 /* Extract opcode and argument */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
220 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
221 opcode = NEXTOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
222 if (HAS_ARG(opcode)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
223 oparg = NEXTARG(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
224 |
| 567 | 225 #ifdef LLTRACE |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
226 /* Instruction tracing */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
227 |
| 567 | 228 if (lltrace) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
229 if (HAS_ARG(opcode)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
230 printf("%d: %d, %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
231 (int) (INSTR_OFFSET() - 3), |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
232 opcode, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
233 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
234 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
235 printf("%d: %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
236 (int) (INSTR_OFFSET() - 1), opcode); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
237 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
238 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
239 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
240 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
241 /* Main switch on opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
242 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
243 switch (opcode) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
244 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
245 /* BEWARE! |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
246 It is essential that any operation that fails sets either |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
247 x to NULL, err to nonzero, or why to anything but WHY_NOT, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
248 and that no operation that succeeds does this! */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
249 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
250 /* case STOP_CODE: this is an error! */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
251 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
252 case POP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
253 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
254 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
255 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
256 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
257 case ROT_TWO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
258 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
259 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
260 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
261 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
262 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
263 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
264 case ROT_THREE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
265 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
266 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
267 x = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
268 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
269 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
270 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
271 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
272 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
273 case DUP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
274 v = TOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
275 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
276 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
277 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
278 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
279 case UNARY_POSITIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
280 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
281 x = pos(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
282 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
283 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
284 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
285 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
286 case UNARY_NEGATIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
287 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
288 x = neg(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
289 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
290 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
291 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
292 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
293 case UNARY_NOT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
294 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
295 x = not(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
296 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
297 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
298 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
299 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
300 case UNARY_CONVERT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
301 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
302 x = reprobject(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
303 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
304 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
305 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
306 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
307 case UNARY_CALL: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
308 v = POP(); |
| 567 | 309 f->f_lasti = INSTR_OFFSET() - 1; /* For tracing */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
310 x = call_object(v, (object *)NULL); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
311 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
312 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
313 break; |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
314 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
315 case UNARY_INVERT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
316 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
317 x = invert(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
318 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
319 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
320 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
321 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
322 case BINARY_MULTIPLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
323 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
324 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
325 x = mul(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
326 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
327 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
328 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
329 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
330 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
331 case BINARY_DIVIDE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
332 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
333 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
334 x = divide(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
335 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
336 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
337 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
338 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
339 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
340 case BINARY_MODULO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
341 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
342 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
343 x = rem(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
344 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
345 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
346 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
347 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
348 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
349 case BINARY_ADD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
350 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
351 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
352 x = add(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
353 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
354 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
355 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
356 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
357 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
358 case BINARY_SUBTRACT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
359 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
360 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
361 x = sub(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
362 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
363 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
364 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
365 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
366 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
367 case BINARY_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
368 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
369 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
370 x = apply_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
371 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
372 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
373 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
374 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
375 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
376 case BINARY_CALL: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
377 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
378 v = POP(); |
| 567 | 379 f->f_lasti = INSTR_OFFSET() - 1; /* For tracing */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
380 x = call_object(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
381 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
382 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
383 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
384 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
385 |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
386 case BINARY_LSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
387 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
388 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
389 x = lshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
390 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
391 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
392 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
393 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
394 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
395 case BINARY_RSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
396 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
397 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
398 x = rshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
399 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
400 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
401 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
402 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
403 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
404 case BINARY_AND: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
405 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
406 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
407 x = and(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
408 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
409 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
410 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
411 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
412 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
413 case BINARY_XOR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
414 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
415 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
416 x = xor(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
417 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
418 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
419 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
420 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
421 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
422 case BINARY_OR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
423 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
424 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
425 x = or(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
426 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
427 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
428 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
429 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
430 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
431 case SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
432 case SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
433 case SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
434 case SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
435 if ((opcode-SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
436 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
437 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
438 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
439 if ((opcode-SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
440 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
441 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
442 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
443 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
444 x = apply_slice(u, v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
445 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
446 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
447 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
448 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
449 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
450 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
451 case STORE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
452 case STORE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
453 case STORE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
454 case STORE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
455 if ((opcode-STORE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
456 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
457 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
458 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
459 if ((opcode-STORE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
460 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
461 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
462 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
463 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
464 t = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
465 err = assign_slice(u, v, w, t); /* u[v:w] = t */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
466 DECREF(t); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
467 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
468 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
469 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
470 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
471 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
472 case DELETE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
473 case DELETE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
474 case DELETE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
475 case DELETE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
476 if ((opcode-DELETE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
477 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
478 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
479 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
480 if ((opcode-DELETE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
481 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
482 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
483 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
484 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
485 err = assign_slice(u, v, w, (object *)NULL); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
486 /* del u[v:w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
487 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
488 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
489 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
490 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
491 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
492 case STORE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
493 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
494 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
495 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
496 /* v[w] = u */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
497 err = assign_subscript(v, w, u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
498 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
499 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
500 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
501 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
502 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
503 case DELETE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
504 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
505 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
506 /* del v[w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
507 err = assign_subscript(v, w, (object *)NULL); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
508 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
509 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
510 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
511 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
512 case PRINT_EXPR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
513 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
514 fp = sysgetfile("stdout", stdout); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
515 /* Print value except if procedure result */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
516 if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
517 flushline(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
518 softspace(sysget("stdout"), 1); |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
519 err = printobject(v, fp, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
520 flushline(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
521 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
522 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
523 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
524 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
525 case PRINT_ITEM: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
526 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
527 fp = sysgetfile("stdout", stdout); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
528 if (softspace(sysget("stdout"), 1)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
529 fprintf(fp, " "); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
530 if (is_stringobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
531 char *s = getstringvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
532 int len = getstringsize(v); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
533 fwrite(s, 1, len, fp); |
|
688
5b71863c801d
Tighten error handling of string printing.
Guido van Rossum <guido@python.org>
parents:
671
diff
changeset
|
534 if (ferror(fp)) { |
|
5b71863c801d
Tighten error handling of string printing.
Guido van Rossum <guido@python.org>
parents:
671
diff
changeset
|
535 err_errno(IOError); |
|
5b71863c801d
Tighten error handling of string printing.
Guido van Rossum <guido@python.org>
parents:
671
diff
changeset
|
536 err = -1; |
|
5b71863c801d
Tighten error handling of string printing.
Guido van Rossum <guido@python.org>
parents:
671
diff
changeset
|
537 } |
|
5b71863c801d
Tighten error handling of string printing.
Guido van Rossum <guido@python.org>
parents:
671
diff
changeset
|
538 else if (len > 0 && s[len-1] == '\n') |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
539 softspace(sysget("stdout"), 0); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
540 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
541 else { |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
542 err = printobject(v, fp, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
543 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
544 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
545 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
546 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
547 case PRINT_NEWLINE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
548 fp = sysgetfile("stdout", stdout); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
549 fprintf(fp, "\n"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
550 softspace(sysget("stdout"), 0); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
551 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
552 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
553 case BREAK_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
554 why = WHY_BREAK; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
555 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
556 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
557 case RAISE_EXCEPTION: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
558 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
559 w = POP(); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
560 /* A tuple is equivalent to its first element here */ |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
561 while (is_tupleobject(w)) { |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
562 u = w; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
563 w = gettupleitem(u, 0); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
564 DECREF(u); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
565 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
566 if (!is_stringobject(w)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
567 err_setstr(TypeError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
568 "exceptions must be strings"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
569 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
570 err_setval(w, v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
571 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
572 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
573 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
574 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
575 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
576 case LOAD_LOCALS: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
577 v = f->f_locals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
578 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
579 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
580 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
581 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
582 case RETURN_VALUE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
583 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
584 why = WHY_RETURN; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
585 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
586 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
587 case BUILD_FUNCTION: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
588 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
589 x = newfuncobject(v, f->f_globals); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
590 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
591 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
592 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
593 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
594 case POP_BLOCK: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
595 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
596 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
597 while (STACK_LEVEL() > b->b_level) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
598 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
599 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
600 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
601 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
602 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
603 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
604 case END_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
605 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
606 if (is_intobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
607 why = (enum why_code) getintvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
608 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
609 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
610 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
611 else if (is_stringobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
612 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
613 err_setval(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
614 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
615 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
616 tb_store(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
617 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
618 why = WHY_RERAISE; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
619 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
620 else if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
621 err_setstr(SystemError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
622 "'finally' pops bad exception"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
623 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
624 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
625 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
626 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
627 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
628 case BUILD_CLASS: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
629 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
630 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
631 x = build_class(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
632 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
633 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
634 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
635 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
636 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
637 case STORE_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
638 w = GETNAMEV(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
639 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
640 err = dict2insert(f->f_locals, w, v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
641 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
642 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
643 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
644 case DELETE_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
645 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
646 if ((err = dict2remove(f->f_locals, w)) != 0) |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
647 err_setstr(NameError, getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
648 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
649 |
|
581
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
650 case UNPACK_VARARG: |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
651 if (EMPTY()) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
652 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
653 "no argument list"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
654 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
655 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
656 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
657 v = POP(); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
658 if (!is_tupleobject(v)) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
659 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
660 "bad argument list"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
661 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
662 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
663 else if (gettuplesize(v) < oparg) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
664 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
665 "not enough arguments"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
666 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
667 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
668 else if (oparg == 0) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
669 PUSH(v); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
670 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
671 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
672 else { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
673 x = gettupleslice(v, oparg, gettuplesize(v)); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
674 if (x != NULL) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
675 PUSH(x); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
676 for (; --oparg >= 0; ) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
677 w = gettupleitem(v, oparg); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
678 INCREF(w); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
679 PUSH(w); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
680 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
681 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
682 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
683 DECREF(v); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
684 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
685 |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
686 case UNPACK_ARG: |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
687 /* Implement various compatibility hacks: |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
688 (a) f(a,b,...) should accept f((1,2,...)) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
689 (b) f((a,b,...)) should accept f(1,2,...) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
690 (c) f(self,(a,b,...)) should accept f(x,1,2,...) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
691 */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
692 { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
693 int n; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
694 if (EMPTY()) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
695 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
696 "no argument list"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
697 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
698 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
699 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
700 v = POP(); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
701 if (!is_tupleobject(v)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
702 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
703 "bad argument list"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
704 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
705 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
706 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
707 n = gettuplesize(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
708 if (n == 1 && oparg != 1) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
709 /* Rule (a) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
710 w = gettupleitem(v, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
711 if (is_tupleobject(w)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
712 INCREF(w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
713 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
714 v = w; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
715 n = gettuplesize(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
716 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
717 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
718 else if (n != 1 && oparg == 1) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
719 /* Rule (b) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
720 PUSH(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
721 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
722 /* Don't fall through */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
723 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
724 else if (n > 2 && oparg == 2) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
725 /* Rule (c) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
726 int i; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
727 w = newtupleobject(n-1); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
728 u = newtupleobject(2); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
729 if (u == NULL || w == NULL) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
730 XDECREF(w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
731 XDECREF(u); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
732 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
733 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
734 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
735 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
736 t = gettupleitem(v, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
737 INCREF(t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
738 settupleitem(u, 0, t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
739 for (i = 1; i < n; i++) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
740 t = gettupleitem(v, i); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
741 INCREF(t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
742 settupleitem(w, i-1, t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
743 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
744 settupleitem(u, 1, w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
745 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
746 v = u; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
747 n = 2; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
748 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
749 if (n != oparg) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
750 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
751 "arg count mismatch"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
752 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
753 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
754 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
755 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
756 PUSH(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
757 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
758 /* Fall through */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
759 case UNPACK_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
760 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
761 if (!is_tupleobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
762 err_setstr(TypeError, "unpack non-tuple"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
763 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
764 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
765 else if (gettuplesize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
766 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
767 "unpack tuple of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
768 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
769 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
770 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
771 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
772 w = gettupleitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
773 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
774 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
775 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
776 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
777 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
778 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
779 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
780 case UNPACK_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
781 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
782 if (!is_listobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
783 err_setstr(TypeError, "unpack non-list"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
784 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
785 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
786 else if (getlistsize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
787 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
788 "unpack list of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
789 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
790 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
791 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
792 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
793 w = getlistitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
794 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
795 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
796 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
797 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
798 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
799 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
800 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
801 case STORE_ATTR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
802 name = GETNAME(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
803 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
804 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
805 err = setattr(v, name, u); /* v.name = u */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
806 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
807 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
808 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
809 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
810 case DELETE_ATTR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
811 name = GETNAME(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
812 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
813 err = setattr(v, name, (object *)NULL); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
814 /* del v.name */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
815 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
816 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
817 |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
818 case STORE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
819 w = GETNAMEV(oparg); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
820 v = POP(); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
821 err = dict2insert(f->f_globals, w, v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
822 DECREF(v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
823 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
824 |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
825 case DELETE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
826 w = GETNAMEV(oparg); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
827 if ((err = dict2remove(f->f_globals, w)) != 0) |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
828 err_setstr(NameError, getstringvalue(w)); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
829 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
830 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
831 case LOAD_CONST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
832 x = GETCONST(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
833 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
834 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
835 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
836 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
837 case LOAD_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
838 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
839 x = dict2lookup(f->f_locals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
840 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
841 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
842 x = dict2lookup(f->f_globals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
843 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
844 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
845 x = getbuiltin(w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
846 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
847 err_setstr(NameError, |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
848 getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
849 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
850 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
851 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
852 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
853 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
854 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
855 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
856 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
857 case LOAD_GLOBAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
858 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
859 x = dict2lookup(f->f_globals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
860 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
861 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
862 x = getbuiltin(w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
863 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
864 err_setstr(NameError, |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
865 getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
866 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
867 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
868 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
869 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
870 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
871 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
872 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
873 case LOAD_LOCAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
874 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
875 x = dict2lookup(f->f_locals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
876 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
877 err_setstr(NameError, getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
878 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
879 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
880 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
881 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
882 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
883 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
884 case BUILD_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
885 x = newtupleobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
886 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
887 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
888 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
889 err = settupleitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
890 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
891 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
892 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
893 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
894 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
895 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
896 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
897 case BUILD_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
898 x = newlistobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
899 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
900 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
901 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
902 err = setlistitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
903 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
904 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
905 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
906 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
907 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
908 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
909 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
910 case BUILD_MAP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
911 x = newdictobject(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
912 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
913 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
914 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
915 case LOAD_ATTR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
916 name = GETNAME(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
917 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
918 x = getattr(v, name); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
919 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
920 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
921 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
922 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
923 case COMPARE_OP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
924 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
925 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
926 x = cmp_outcome((enum cmp_op)oparg, v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
927 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
928 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
929 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
930 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
931 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
932 case IMPORT_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
933 name = GETNAME(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
934 x = import_module(name); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
935 XINCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
936 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
937 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
938 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
939 case IMPORT_FROM: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
940 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
941 v = TOP(); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
942 err = import_from(f->f_locals, v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
943 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
944 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
945 case JUMP_FORWARD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
946 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
947 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
948 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
949 case JUMP_IF_FALSE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
950 if (!testbool(TOP())) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
951 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
952 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
953 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
954 case JUMP_IF_TRUE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
955 if (testbool(TOP())) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
956 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
957 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
958 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
959 case JUMP_ABSOLUTE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
960 JUMPTO(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
961 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
962 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
963 case FOR_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
964 /* for v in s: ... |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
965 On entry: stack contains s, i. |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
966 On exit: stack contains s, i+1, s[i]; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
967 but if loop exhausted: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
968 s, i are popped, and we jump */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
969 w = POP(); /* Loop index */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
970 v = POP(); /* Sequence object */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
971 u = loop_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
972 if (u != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
973 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
974 x = newintobject(getintvalue(w)+1); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
975 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
976 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
977 PUSH(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
978 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
979 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
980 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
981 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
982 /* A NULL can mean "s exhausted" |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
983 but also an error: */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
984 if (err_occurred()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
985 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
986 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
987 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
988 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
989 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
990 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
991 case SETUP_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
992 case SETUP_EXCEPT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
993 case SETUP_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
994 setup_block(f, opcode, INSTR_OFFSET() + oparg, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
995 STACK_LEVEL()); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
996 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
997 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
998 case SET_LINENO: |
| 567 | 999 #ifdef LLTRACE |
| 1000 if (lltrace) | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1001 printf("--- Line %d ---\n", oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1002 #endif |
| 567 | 1003 f->f_lineno = oparg; |
| 1004 if (trace != NULL) { | |
| 1005 /* Trace each line of code reached */ | |
| 1006 f->f_lasti = INSTR_OFFSET(); | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1007 err = call_trace(&trace, &trace, |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1008 f, "line", None); |
| 567 | 1009 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1010 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1011 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1012 default: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1013 fprintf(stderr, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1014 "XXX lineno: %d, opcode: %d\n", |
| 567 | 1015 f->f_lineno, opcode); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1016 err_setstr(SystemError, "eval_code: unknown opcode"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1017 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1018 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1019 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1020 } /* switch */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1021 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1022 on_error: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1023 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1024 /* Quickly continue if no error occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1025 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1026 if (why == WHY_NOT) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1027 if (err == 0 && x != NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1028 continue; /* Normal, fast path */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1029 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1030 x = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1031 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1032 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1033 |
| 567 | 1034 #ifndef CHECKEXC |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1035 /* Double-check exception status */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1036 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1037 if (why == WHY_EXCEPTION || why == WHY_RERAISE) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1038 if (!err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1039 fprintf(stderr, "XXX ghost error\n"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1040 err_setstr(SystemError, "ghost error"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1041 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1042 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1043 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1044 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1045 if (err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1046 fprintf(stderr, "XXX undetected error\n"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1047 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1048 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1049 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1050 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1051 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1052 /* Log traceback info if this is a real exception */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1053 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1054 if (why == WHY_EXCEPTION) { |
| 567 | 1055 f->f_lasti = INSTR_OFFSET() - 1; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1056 if (HAS_ARG(opcode)) |
| 567 | 1057 f->f_lasti -= 2; |
| 1058 tb_here(f); | |
| 1059 | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1060 if (trace) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1061 call_exc_trace(&trace, &trace, f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1062 if (sys_profile) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1063 call_exc_trace(&sys_profile, (object**)0, f); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1064 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1065 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1066 /* For the rest, treat WHY_RERAISE as WHY_EXCEPTION */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1067 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1068 if (why == WHY_RERAISE) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1069 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1070 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1071 /* Unwind stacks if a (pseudo) exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1072 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1073 while (why != WHY_NOT && f->f_iblock > 0) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1074 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1075 while (STACK_LEVEL() > b->b_level) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1076 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1077 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1078 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1079 if (b->b_type == SETUP_LOOP && why == WHY_BREAK) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1080 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1081 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1082 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1083 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1084 if (b->b_type == SETUP_FINALLY || |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1085 b->b_type == SETUP_EXCEPT && |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1086 why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1087 if (why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1088 object *exc, *val; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1089 err_get(&exc, &val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1090 if (val == NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1091 val = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1092 INCREF(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1093 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1094 v = tb_fetch(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1095 /* Make the raw exception data |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1096 available to the handler, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1097 so a program can emulate the |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1098 Python main loop. Don't do |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1099 this for 'finally'. */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1100 if (b->b_type == SETUP_EXCEPT) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1101 sysset("exc_traceback", v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1102 sysset("exc_value", val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1103 sysset("exc_type", exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1104 err_clear(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1105 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1106 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1107 PUSH(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1108 PUSH(exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1109 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1110 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1111 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1112 PUSH(retval); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1113 v = newintobject((long)why); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1114 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1115 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1116 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1117 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1118 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1119 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1120 } /* unwind stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1121 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1122 /* End the loop if we still have an error (or return) */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1123 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1124 if (why != WHY_NOT) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1125 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1126 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1127 } /* main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1128 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1129 /* Pop remaining stack entries */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1130 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1131 while (!EMPTY()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1132 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1133 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1134 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1135 |
| 567 | 1136 if (why != WHY_RETURN) |
| 1137 retval = NULL; | |
| 1138 | |
| 1139 if (trace) { | |
| 1140 if (why == WHY_RETURN) { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1141 if (call_trace(&trace, &trace, f, "return", retval)) { |
| 567 | 1142 XDECREF(retval); |
| 1143 retval = NULL; | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1144 why = WHY_EXCEPTION; |
| 567 | 1145 } |
| 1146 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1147 XDECREF(trace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1148 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1149 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1150 if (sys_profile && why == WHY_RETURN) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1151 if (call_trace(&sys_profile, (object**)0, |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1152 f, "return", retval)) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1153 XDECREF(retval); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1154 retval = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1155 why = WHY_EXCEPTION; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1156 } |
| 567 | 1157 } |
| 1158 | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1159 /* Restore previous frame and release the current one */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1160 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1161 current_frame = f->f_back; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1162 DECREF(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1163 |
| 567 | 1164 return retval; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1165 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1166 |
| 567 | 1167 #ifdef LLTRACE |
| 86 | 1168 static int |
| 1169 prtrace(v, str) | |
| 1170 object *v; | |
| 1171 char *str; | |
| 69 | 1172 { |
| 86 | 1173 printf("%s ", str); |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1174 if (printobject(v, stdout, 0) != 0) |
|
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1175 err_clear(); /* Don't know what else to do */ |
| 86 | 1176 printf("\n"); |
| 69 | 1177 } |
| 86 | 1178 #endif |
| 69 | 1179 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1180 static void |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1181 call_exc_trace(p_trace, p_newtrace, f) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1182 object **p_trace, **p_newtrace; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1183 frameobject *f; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1184 { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1185 object *type, *value, *traceback, *arg; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1186 int err; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1187 err_get(&type, &value); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1188 traceback = tb_fetch(); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1189 arg = newtupleobject(3); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1190 if (arg == NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1191 err = -1; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1192 goto cleanup; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1193 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1194 settupleitem(arg, 0, type); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1195 settupleitem(arg, 1, value); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1196 settupleitem(arg, 2, traceback); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1197 err = call_trace(p_trace, p_newtrace, f, "exception", arg); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1198 XDECREF(arg); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1199 cleanup: |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1200 if (!err) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1201 /* Restore original exception */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1202 err_setval(type, value); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1203 tb_store(traceback); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1204 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1205 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1206 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1207 static int |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1208 call_trace(p_trace, p_newtrace, f, msg, arg) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1209 object **p_trace; /* in/out; may not be NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1210 may not point to NULL variable initially */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1211 object **p_newtrace; /* in/out; may be NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1212 may point to NULL variable; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1213 may be same variable as p_newtrace */ |
| 567 | 1214 frameobject *f; |
| 1215 char *msg; | |
| 1216 object *arg; | |
| 1217 { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1218 object *arglist, *what; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1219 object *res = NULL; |
| 567 | 1220 static int tracing = 0; |
| 1221 | |
| 1222 if (tracing) { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1223 /* Don't do recursive traces */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1224 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1225 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1226 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1227 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1228 return 0; |
| 567 | 1229 } |
| 1230 | |
| 1231 arglist = newtupleobject(3); | |
| 1232 if (arglist == NULL) | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1233 goto cleanup; |
| 567 | 1234 what = newstringobject(msg); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1235 if (what == NULL) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1236 goto cleanup; |
| 567 | 1237 INCREF(f); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1238 settupleitem(arglist, 0, (object *)f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1239 settupleitem(arglist, 1, what); |
| 567 | 1240 if (arg == NULL) |
| 1241 arg = None; | |
| 1242 INCREF(arg); | |
| 1243 settupleitem(arglist, 2, arg); | |
| 1244 tracing++; | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1245 res = call_object(*p_trace, arglist); |
| 567 | 1246 tracing--; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1247 cleanup: |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1248 XDECREF(arglist); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1249 if (res == NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1250 /* The trace proc raised an exception */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1251 tb_here(f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1252 XDECREF(*p_trace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1253 *p_trace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1254 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1255 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1256 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1257 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1258 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1259 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1260 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1261 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1262 if (res == None) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1263 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1264 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1265 INCREF(res); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1266 *p_newtrace = res; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1267 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1268 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1269 DECREF(res); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1270 } |
| 567 | 1271 if (res == NULL) |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1272 return -1; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1273 else |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1274 return 0; |
| 567 | 1275 } |
| 1276 | |
| 86 | 1277 object * |
| 1278 getlocals() | |
| 69 | 1279 { |
| 86 | 1280 if (current_frame == NULL) |
| 69 | 1281 return NULL; |
| 86 | 1282 else |
| 1283 return current_frame->f_locals; | |
| 69 | 1284 } |
| 1285 | |
| 86 | 1286 object * |
| 1287 getglobals() | |
| 69 | 1288 { |
| 86 | 1289 if (current_frame == NULL) |
| 1290 return NULL; | |
| 1291 else | |
| 1292 return current_frame->f_globals; | |
| 69 | 1293 } |
| 1294 | |
| 86 | 1295 void |
| 1296 printtraceback(fp) | |
| 1297 FILE *fp; | |
| 69 | 1298 { |
| 86 | 1299 object *v = tb_fetch(); |
| 1300 if (v != NULL) { | |
| 1301 fprintf(fp, "Stack backtrace (innermost last):\n"); | |
| 1302 tb_print(v, fp); | |
| 1303 DECREF(v); | |
| 69 | 1304 } |
| 1305 } | |
| 1306 | |
| 1307 | |
| 1308 void | |
| 1309 flushline() | |
| 1310 { | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1311 if (softspace(sysget("stdout"), 0)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1312 fprintf(sysgetfile("stdout", stdout), "\n"); |
| 69 | 1313 } |
| 1314 | |
| 86 | 1315 |
| 1316 /* Test a value used as condition, e.g., in a for or if statement */ | |
| 1317 | |
| 1318 static int | |
| 1319 testbool(v) | |
| 69 | 1320 object *v; |
| 1321 { | |
|
237
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
1322 if (v == None) |
|
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
1323 return 0; |
|
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
1324 if (v->ob_type->tp_as_number != NULL) |
|
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
1325 return (*v->ob_type->tp_as_number->nb_nonzero)(v); |
| 86 | 1326 if (v->ob_type->tp_as_sequence != NULL) |
| 1327 return (*v->ob_type->tp_as_sequence->sq_length)(v) != 0; | |
| 1328 if (v->ob_type->tp_as_mapping != NULL) | |
| 1329 return (*v->ob_type->tp_as_mapping->mp_length)(v) != 0; | |
| 1330 /* All other objects are 'true' */ | |
| 1331 return 1; | |
| 69 | 1332 } |
| 1333 | |
| 1334 static object * | |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1335 or(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1336 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1337 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1338 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1339 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1340 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1341 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1342 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1343 if ((f = v->ob_type->tp_as_number->nb_or) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1344 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1345 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1346 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1347 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1348 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1349 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1350 err_setstr(TypeError, "bad operand type(s) for |"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1351 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1352 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1353 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1354 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1355 xor(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1356 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1357 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1358 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1359 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1360 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1361 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1362 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1363 if ((f = v->ob_type->tp_as_number->nb_xor) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1364 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1365 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1366 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1367 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1368 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1369 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1370 err_setstr(TypeError, "bad operand type(s) for ^"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1371 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1372 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1373 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1374 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1375 and(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1376 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1377 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1378 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1379 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1380 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1381 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1382 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1383 if ((f = v->ob_type->tp_as_number->nb_and) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1384 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1385 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1386 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1387 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1388 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1389 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1390 err_setstr(TypeError, "bad operand type(s) for &"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1391 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1392 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1393 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1394 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1395 lshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1396 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1397 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1398 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1399 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1400 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1401 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1402 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1403 if ((f = v->ob_type->tp_as_number->nb_lshift) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1404 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1405 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1406 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1407 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1408 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1409 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1410 err_setstr(TypeError, "bad operand type(s) for <<"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1411 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1412 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1413 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1414 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1415 rshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1416 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1417 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1418 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1419 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1420 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1421 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1422 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1423 if ((f = v->ob_type->tp_as_number->nb_rshift) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1424 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1425 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1426 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1427 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1428 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1429 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1430 err_setstr(TypeError, "bad operand type(s) for >>"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1431 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1432 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1433 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1434 static object * |
| 86 | 1435 add(v, w) |
| 69 | 1436 object *v, *w; |
| 1437 { | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1438 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1439 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1440 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1441 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1442 x = (*v->ob_type->tp_as_number->nb_add)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1443 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1444 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1445 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1446 } |
| 69 | 1447 else if (v->ob_type->tp_as_sequence != NULL) |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1448 return (*v->ob_type->tp_as_sequence->sq_concat)(v, w); |
| 69 | 1449 else { |
| 86 | 1450 err_setstr(TypeError, "+ not supported by operands"); |
| 69 | 1451 return NULL; |
| 1452 } | |
| 1453 } | |
| 1454 | |
| 1455 static object * | |
| 86 | 1456 sub(v, w) |
| 69 | 1457 object *v, *w; |
| 1458 { | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1459 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1460 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1461 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1462 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1463 x = (*v->ob_type->tp_as_number->nb_subtract)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1464 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1465 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1466 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1467 } |
| 86 | 1468 err_setstr(TypeError, "bad operand type(s) for -"); |
| 69 | 1469 return NULL; |
| 1470 } | |
| 1471 | |
| 1472 static object * | |
| 86 | 1473 mul(v, w) |
| 69 | 1474 object *v, *w; |
| 1475 { | |
| 1476 typeobject *tp; | |
| 1477 if (is_intobject(v) && w->ob_type->tp_as_sequence != NULL) { | |
| 1478 /* int*sequence -- swap v and w */ | |
| 1479 object *tmp = v; | |
| 1480 v = w; | |
| 1481 w = tmp; | |
| 1482 } | |
| 1483 tp = v->ob_type; | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1484 if (tp->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1485 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1486 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1487 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1488 x = (*v->ob_type->tp_as_number->nb_multiply)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1489 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1490 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1491 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1492 } |
| 69 | 1493 if (tp->tp_as_sequence != NULL) { |
| 1494 if (!is_intobject(w)) { | |
| 86 | 1495 err_setstr(TypeError, |
| 1496 "can't multiply sequence with non-int"); | |
| 69 | 1497 return NULL; |
| 1498 } | |
| 86 | 1499 return (*tp->tp_as_sequence->sq_repeat) |
| 1500 (v, (int)getintvalue(w)); | |
| 69 | 1501 } |
| 86 | 1502 err_setstr(TypeError, "bad operand type(s) for *"); |
| 69 | 1503 return NULL; |
| 1504 } | |
| 1505 | |
| 1506 static object * | |
|
88
16e8c5d16493
Change div() into divide(); div() is a Standard C function.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1507 divide(v, w) |
| 69 | 1508 object *v, *w; |
| 1509 { | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1510 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1511 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1512 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1513 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1514 x = (*v->ob_type->tp_as_number->nb_divide)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1515 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1516 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1517 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1518 } |
| 86 | 1519 err_setstr(TypeError, "bad operand type(s) for /"); |
| 69 | 1520 return NULL; |
| 1521 } | |
| 1522 | |
| 1523 static object * | |
| 86 | 1524 rem(v, w) |
| 1525 object *v, *w; | |
| 69 | 1526 { |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1527 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1528 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1529 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1530 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1531 x = (*v->ob_type->tp_as_number->nb_remainder)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1532 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1533 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1534 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1535 } |
| 86 | 1536 err_setstr(TypeError, "bad operand type(s) for %"); |
| 69 | 1537 return NULL; |
| 1538 } | |
| 1539 | |
| 1540 static object * | |
| 86 | 1541 neg(v) |
| 69 | 1542 object *v; |
| 1543 { | |
| 1544 if (v->ob_type->tp_as_number != NULL) | |
| 86 | 1545 return (*v->ob_type->tp_as_number->nb_negative)(v); |
| 1546 err_setstr(TypeError, "bad operand type(s) for unary -"); | |
| 1547 return NULL; | |
| 1548 } | |
| 1549 | |
| 1550 static object * | |
| 1551 pos(v) | |
| 1552 object *v; | |
| 1553 { | |
| 1554 if (v->ob_type->tp_as_number != NULL) | |
| 1555 return (*v->ob_type->tp_as_number->nb_positive)(v); | |
| 1556 err_setstr(TypeError, "bad operand type(s) for unary +"); | |
| 69 | 1557 return NULL; |
| 1558 } | |
| 1559 | |
| 1560 static object * | |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1561 invert(v) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1562 object *v; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1563 { |
|
671
10002e1bc526
Use correct prototype for invert().
Guido van Rossum <guido@python.org>
parents:
661
diff
changeset
|
1564 object * (*f) FPROTO((object *)); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1565 if (v->ob_type->tp_as_number != NULL && |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1566 (f = v->ob_type->tp_as_number->nb_invert) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1567 return (*f)(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1568 err_setstr(TypeError, "bad operand type(s) for unary ~"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1569 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1570 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1571 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1572 static object * |
| 86 | 1573 not(v) |
| 69 | 1574 object *v; |
| 1575 { | |
| 86 | 1576 int outcome = testbool(v); |
| 1577 object *w = outcome == 0 ? True : False; | |
| 1578 INCREF(w); | |
| 1579 return w; | |
| 69 | 1580 } |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1581 /* External interface to call any callable object. The arg may be NULL. */ |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1582 |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1583 object * |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1584 call_object(func, arg) |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1585 object *func; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1586 object *arg; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1587 { |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1588 if (is_instancemethodobject(func) || is_funcobject(func)) |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1589 return call_function(func, arg); |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1590 else |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1591 return call_builtin(func, arg); |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1592 } |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1593 |
| 69 | 1594 static object * |
| 86 | 1595 call_builtin(func, arg) |
| 69 | 1596 object *func; |
| 86 | 1597 object *arg; |
| 69 | 1598 { |
| 1599 if (is_methodobject(func)) { | |
| 1600 method meth = getmethod(func); | |
| 1601 object *self = getself(func); | |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1602 if (!getvarargs(func) && arg != NULL && is_tupleobject(arg)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1603 int size = gettuplesize(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1604 if (size == 1) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1605 arg = gettupleitem(arg, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1606 else if (size == 0) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1607 arg = NULL; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1608 } |
| 86 | 1609 return (*meth)(self, arg); |
| 69 | 1610 } |
| 1611 if (is_classobject(func)) { | |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1612 if (arg != NULL && |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1613 !(is_tupleobject(arg) && |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1614 gettuplesize(arg) == 0)) { |
| 86 | 1615 err_setstr(TypeError, |
| 1616 "classobject() allows no arguments"); | |
| 69 | 1617 return NULL; |
| 1618 } | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1619 return newinstanceobject(func); |
| 69 | 1620 } |
| 86 | 1621 err_setstr(TypeError, "call of non-function"); |
| 69 | 1622 return NULL; |
| 1623 } | |
| 1624 | |
| 1625 static object * | |
| 86 | 1626 call_function(func, arg) |
| 69 | 1627 object *func; |
| 86 | 1628 object *arg; |
| 69 | 1629 { |
| 86 | 1630 object *newarg = NULL; |
| 1631 object *newlocals, *newglobals; | |
| 1632 object *co, *v; | |
| 69 | 1633 |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
1634 if (is_instancemethodobject(func)) { |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1635 int argcount; |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
1636 object *self = instancemethodgetself(func); |
|
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
1637 func = instancemethodgetfunc(func); |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1638 if (arg == NULL) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1639 argcount = 0; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1640 else if (is_tupleobject(arg)) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1641 argcount = gettuplesize(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1642 else |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1643 argcount = 1; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1644 newarg = newtupleobject(argcount + 1); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1645 if (newarg == NULL) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1646 return NULL; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1647 INCREF(self); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1648 settupleitem(newarg, 0, self); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1649 if (arg != NULL && !is_tupleobject(arg)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1650 INCREF(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1651 settupleitem(newarg, 1, arg); |
| 69 | 1652 } |
| 1653 else { | |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1654 int i; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1655 object *v; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1656 for (i = 0; i < argcount; i++) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1657 v = gettupleitem(arg, i); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1658 XINCREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1659 settupleitem(newarg, i+1, v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1660 } |
| 69 | 1661 } |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
1662 arg = newarg; |
| 69 | 1663 } |
| 1664 else { | |
| 1665 if (!is_funcobject(func)) { | |
| 86 | 1666 err_setstr(TypeError, "call of non-function"); |
| 69 | 1667 return NULL; |
| 1668 } | |
| 1669 } | |
| 1670 | |
| 86 | 1671 co = getfunccode(func); |
| 1672 if (co == NULL) { | |
| 1673 XDECREF(newarg); | |
| 69 | 1674 return NULL; |
| 1675 } | |
| 86 | 1676 if (!is_codeobject(co)) { |
| 1677 fprintf(stderr, "XXX Bad code\n"); | |
| 69 | 1678 abort(); |
| 1679 } | |
| 86 | 1680 newlocals = newdictobject(); |
| 69 | 1681 if (newlocals == NULL) { |
| 86 | 1682 XDECREF(newarg); |
| 69 | 1683 return NULL; |
| 1684 } | |
| 1685 | |
| 86 | 1686 newglobals = getfuncglobals(func); |
| 1687 INCREF(newglobals); | |
| 1688 | |
| 1689 v = eval_code((codeobject *)co, newglobals, newlocals, arg); | |
| 69 | 1690 |
| 86 | 1691 DECREF(newlocals); |
| 1692 DECREF(newglobals); | |
| 69 | 1693 |
| 86 | 1694 XDECREF(newarg); |
| 69 | 1695 |
| 1696 return v; | |
| 1697 } | |
| 1698 | |
| 1699 static object * | |
| 86 | 1700 apply_subscript(v, w) |
| 69 | 1701 object *v, *w; |
| 1702 { | |
| 1703 typeobject *tp = v->ob_type; | |
| 1704 if (tp->tp_as_sequence == NULL && tp->tp_as_mapping == NULL) { | |
| 86 | 1705 err_setstr(TypeError, "unsubscriptable object"); |
| 69 | 1706 return NULL; |
| 1707 } | |
| 1708 if (tp->tp_as_sequence != NULL) { | |
| 1709 int i; | |
| 1710 if (!is_intobject(w)) { | |
| 86 | 1711 err_setstr(TypeError, "sequence subscript not int"); |
| 69 | 1712 return NULL; |
| 1713 } | |
| 1714 i = getintvalue(w); | |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1715 if (i < 0) |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1716 i += (*tp->tp_as_sequence->sq_length)(v); |
| 86 | 1717 return (*tp->tp_as_sequence->sq_item)(v, i); |
| 69 | 1718 } |
| 86 | 1719 return (*tp->tp_as_mapping->mp_subscript)(v, w); |
| 69 | 1720 } |
| 1721 | |
| 1722 static object * | |
| 86 | 1723 loop_subscript(v, w) |
| 69 | 1724 object *v, *w; |
| 1725 { | |
| 1726 sequence_methods *sq = v->ob_type->tp_as_sequence; | |
| 1727 int i, n; | |
| 1728 if (sq == NULL) { | |
| 86 | 1729 err_setstr(TypeError, "loop over non-sequence"); |
| 69 | 1730 return NULL; |
| 1731 } | |
| 1732 i = getintvalue(w); | |
| 1733 n = (*sq->sq_length)(v); | |
| 1734 if (i >= n) | |
| 1735 return NULL; /* End of loop */ | |
| 86 | 1736 return (*sq->sq_item)(v, i); |
| 69 | 1737 } |
| 1738 | |
| 1739 static int | |
| 86 | 1740 slice_index(v, isize, pi) |
| 69 | 1741 object *v; |
| 1742 int isize; | |
| 1743 int *pi; | |
| 1744 { | |
| 1745 if (v != NULL) { | |
| 1746 if (!is_intobject(v)) { | |
| 86 | 1747 err_setstr(TypeError, "slice index must be int"); |
| 1748 return -1; | |
| 69 | 1749 } |
| 1750 *pi = getintvalue(v); | |
| 1751 if (*pi < 0) | |
| 1752 *pi += isize; | |
| 1753 } | |
| 86 | 1754 return 0; |
| 69 | 1755 } |
| 1756 | |
| 1757 static object * | |
| 86 | 1758 apply_slice(u, v, w) /* return u[v:w] */ |
| 69 | 1759 object *u, *v, *w; |
| 1760 { | |
| 1761 typeobject *tp = u->ob_type; | |
| 1762 int ilow, ihigh, isize; | |
| 1763 if (tp->tp_as_sequence == NULL) { | |
| 86 | 1764 err_setstr(TypeError, "only sequences can be sliced"); |
| 69 | 1765 return NULL; |
| 1766 } | |
| 1767 ilow = 0; | |
| 1768 isize = ihigh = (*tp->tp_as_sequence->sq_length)(u); | |
| 86 | 1769 if (slice_index(v, isize, &ilow) != 0) |
| 69 | 1770 return NULL; |
| 86 | 1771 if (slice_index(w, isize, &ihigh) != 0) |
| 69 | 1772 return NULL; |
| 86 | 1773 return (*tp->tp_as_sequence->sq_slice)(u, ilow, ihigh); |
| 69 | 1774 } |
| 86 | 1775 |
| 1776 static int | |
| 1777 assign_subscript(w, key, v) /* w[key] = v */ | |
| 69 | 1778 object *w; |
| 1779 object *key; | |
| 1780 object *v; | |
| 1781 { | |
| 1782 typeobject *tp = w->ob_type; | |
| 1783 sequence_methods *sq; | |
| 1784 mapping_methods *mp; | |
| 1785 int (*func)(); | |
| 1786 if ((sq = tp->tp_as_sequence) != NULL && | |
| 1787 (func = sq->sq_ass_item) != NULL) { | |
| 1788 if (!is_intobject(key)) { | |
| 86 | 1789 err_setstr(TypeError, |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1790 "sequence subscript must be integer (assign or del)"); |
| 86 | 1791 return -1; |
| 69 | 1792 } |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1793 else { |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1794 int i = getintvalue(key); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1795 if (i < 0) |
|
565
5faf93eb9256
Fix bug in assign_slice for negative index; used length of wrong object!
Guido van Rossum <guido@python.org>
parents:
506
diff
changeset
|
1796 i += (*sq->sq_length)(w); |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1797 return (*func)(w, i, v); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1798 } |
| 69 | 1799 } |
| 1800 else if ((mp = tp->tp_as_mapping) != NULL && | |
| 1801 (func = mp->mp_ass_subscript) != NULL) { | |
| 86 | 1802 return (*func)(w, key, v); |
| 69 | 1803 } |
| 1804 else { | |
| 86 | 1805 err_setstr(TypeError, |
| 1806 "can't assign to this subscripted object"); | |
| 1807 return -1; | |
| 69 | 1808 } |
| 1809 } | |
| 1810 | |
| 86 | 1811 static int |
| 1812 assign_slice(u, v, w, x) /* u[v:w] = x */ | |
| 69 | 1813 object *u, *v, *w, *x; |
| 1814 { | |
| 86 | 1815 sequence_methods *sq = u->ob_type->tp_as_sequence; |
| 69 | 1816 int ilow, ihigh, isize; |
| 86 | 1817 if (sq == NULL) { |
| 1818 err_setstr(TypeError, "assign to slice of non-sequence"); | |
| 1819 return -1; | |
| 1820 } | |
| 1821 if (sq == NULL || sq->sq_ass_slice == NULL) { | |
| 1822 err_setstr(TypeError, "unassignable slice"); | |
| 1823 return -1; | |
| 69 | 1824 } |
| 1825 ilow = 0; | |
| 86 | 1826 isize = ihigh = (*sq->sq_length)(u); |
| 1827 if (slice_index(v, isize, &ilow) != 0) | |
| 1828 return -1; | |
| 1829 if (slice_index(w, isize, &ihigh) != 0) | |
| 1830 return -1; | |
| 1831 return (*sq->sq_ass_slice)(u, ilow, ihigh, x); | |
| 69 | 1832 } |
| 1833 | |
| 1834 static int | |
| 1835 cmp_exception(err, v) | |
| 1836 object *err, *v; | |
| 1837 { | |
| 1838 if (is_tupleobject(v)) { | |
| 1839 int i, n; | |
| 1840 n = gettuplesize(v); | |
| 1841 for (i = 0; i < n; i++) { | |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1842 /* Test recursively */ |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1843 if (cmp_exception(err, gettupleitem(v, i))) |
| 69 | 1844 return 1; |
| 1845 } | |
| 1846 return 0; | |
| 1847 } | |
| 1848 return err == v; | |
| 1849 } | |
| 1850 | |
| 86 | 1851 static int |
| 1852 cmp_member(v, w) | |
| 1853 object *v, *w; | |
| 1854 { | |
| 1855 int i, n, cmp; | |
| 1856 object *x; | |
| 1857 sequence_methods *sq; | |
| 1858 /* Special case for char in string */ | |
| 1859 if (is_stringobject(w)) { | |
| 1860 register char *s, *end; | |
| 1861 register char c; | |
| 1862 if (!is_stringobject(v) || getstringsize(v) != 1) { | |
| 1863 err_setstr(TypeError, | |
| 1864 "string member test needs char left operand"); | |
| 1865 return -1; | |
| 1866 } | |
| 1867 c = getstringvalue(v)[0]; | |
| 1868 s = getstringvalue(w); | |
| 1869 end = s + getstringsize(w); | |
| 1870 while (s < end) { | |
| 1871 if (c == *s++) | |
| 1872 return 1; | |
| 1873 } | |
| 1874 return 0; | |
| 1875 } | |
| 1876 sq = w->ob_type->tp_as_sequence; | |
| 1877 if (sq == NULL) { | |
| 1878 err_setstr(TypeError, | |
| 1879 "'in' or 'not in' needs sequence right argument"); | |
| 1880 return -1; | |
| 1881 } | |
| 1882 n = (*sq->sq_length)(w); | |
| 1883 for (i = 0; i < n; i++) { | |
| 1884 x = (*sq->sq_item)(w, i); | |
| 1885 cmp = cmpobject(v, x); | |
| 1886 XDECREF(x); | |
| 1887 if (cmp == 0) | |
| 1888 return 1; | |
| 1889 } | |
| 1890 return 0; | |
| 1891 } | |
| 1892 | |
| 69 | 1893 static object * |
| 86 | 1894 cmp_outcome(op, v, w) |
| 69 | 1895 enum cmp_op op; |
| 1896 register object *v; | |
| 1897 register object *w; | |
| 1898 { | |
| 1899 register int cmp; | |
| 1900 register int res = 0; | |
| 1901 switch (op) { | |
| 86 | 1902 case IS: |
| 1903 case IS_NOT: | |
| 1904 res = (v == w); | |
| 1905 if (op == IS_NOT) | |
| 1906 res = !res; | |
| 1907 break; | |
| 69 | 1908 case IN: |
| 1909 case NOT_IN: | |
| 86 | 1910 res = cmp_member(v, w); |
| 1911 if (res < 0) | |
| 1912 return NULL; | |
| 1913 if (op == NOT_IN) | |
| 1914 res = !res; | |
| 69 | 1915 break; |
| 1916 case EXC_MATCH: | |
| 86 | 1917 res = cmp_exception(v, w); |
| 69 | 1918 break; |
| 1919 default: | |
| 86 | 1920 cmp = cmpobject(v, w); |
| 1921 switch (op) { | |
| 1922 case LT: res = cmp < 0; break; | |
| 1923 case LE: res = cmp <= 0; break; | |
| 1924 case EQ: res = cmp == 0; break; | |
| 1925 case NE: res = cmp != 0; break; | |
| 1926 case GT: res = cmp > 0; break; | |
| 1927 case GE: res = cmp >= 0; break; | |
| 1928 /* XXX no default? (res is initialized to 0 though) */ | |
| 1929 } | |
| 69 | 1930 } |
| 1931 v = res ? True : False; | |
| 1932 INCREF(v); | |
| 1933 return v; | |
| 1934 } | |
| 1935 | |
| 86 | 1936 static int |
| 1937 import_from(locals, v, name) | |
| 1938 object *locals; | |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1939 object *v; |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1940 object *name; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1941 { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1942 object *w, *x; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1943 w = getmoduledict(v); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1944 if (getstringvalue(name)[0] == '*') { |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1945 int i; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1946 int n = getdictsize(w); |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1947 for (i = 0; i < n; i++) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1948 name = getdict2key(w, i); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1949 if (name == NULL || getstringvalue(name)[0] == '_') |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1950 continue; |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1951 x = dict2lookup(w, name); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1952 if (x == NULL) { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1953 /* XXX can't happen? */ |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1954 err_setstr(SystemError, getstringvalue(name)); |
| 86 | 1955 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1956 } |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1957 if (dict2insert(locals, name, x) != 0) |
| 86 | 1958 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1959 } |
| 86 | 1960 return 0; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1961 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1962 else { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1963 x = dict2lookup(w, name); |
| 86 | 1964 if (x == NULL) { |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1965 char buf[250]; |
|
661
7e5f4d9aee77
Limit length of name passed to sprintf.
Guido van Rossum <guido@python.org>
parents:
607
diff
changeset
|
1966 sprintf(buf, "cannot import name %.230s", |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1967 getstringvalue(name)); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
1968 err_setstr(ImportError, buf); |
| 86 | 1969 return -1; |
| 1970 } | |
| 1971 else | |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1972 return dict2insert(locals, name, x); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1973 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1974 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1975 |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1976 static object * |
| 86 | 1977 build_class(v, w) |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1978 object *v; /* None or tuple containing base classes */ |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1979 object *w; /* dictionary */ |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1980 { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1981 if (is_tupleobject(v)) { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1982 int i; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1983 for (i = gettuplesize(v); --i >= 0; ) { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1984 object *x = gettupleitem(v, i); |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1985 if (!is_classobject(x)) { |
| 86 | 1986 err_setstr(TypeError, |
| 1987 "base is not a class object"); | |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1988 return NULL; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1989 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1990 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1991 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1992 else { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1993 v = NULL; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1994 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1995 if (!is_dictobject(w)) { |
| 86 | 1996 err_setstr(SystemError, "build_class with non-dictionary"); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1997 return NULL; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
1998 } |
|
401
0c5e4e137de6
newclassobject() gets a third argument
Guido van Rossum <guido@python.org>
parents:
334
diff
changeset
|
1999 return newclassobject(v, w, (object *) NULL); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2000 } |
