Mercurial > cpython-lru_cache-weakref
annotate Python/ceval.c @ 1354:fccd415e2eb8 legacy-trunk
* bltinmodule.c: removed exec() built-in function.
* Grammar: add exec statement; allow testlist in expr statement.
* ceval.c, compile.c, opcode.h: support exec statement;
avoid optimizing locals when it is used
* fileobject.{c,h}: add getfilename() internal function.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 18 Oct 1993 17:06:59 +0000 |
| parents | cd397266dc1c |
| children | 043da19302ef |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
1 /*********************************************************** |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
2 Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
3 Amsterdam, The Netherlands. |
|
145
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" |
| 926 | 33 #include "eval.h" |
| 86 | 34 #include "ceval.h" |
| 69 | 35 #include "opcode.h" |
| 119 | 36 #include "bltinmodule.h" |
| 86 | 37 #include "traceback.h" |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
38 #include "graminit.h" |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
39 #include "pythonrun.h" |
| 69 | 40 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
41 /* Turn this on if your compiler chokes on the big switch: */ |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
42 /* #define CASE_TOO_BIG 1 /**/ |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
43 |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
44 /* Turn this on if you want to debug the interpreter: */ |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
45 /* (This can be on even if NDEBUG is defined) */ |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
46 /* #define DEBUG 1 /**/ |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
47 |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
48 #if defined(DEBUG) || !defined(NDEBUG) |
| 567 | 49 /* For debugging the interpreter: */ |
| 50 #define LLTRACE 1 /* Low-level trace feature */ | |
| 51 #define CHECKEXC 1 /* Double-check exception checking */ | |
| 69 | 52 #endif |
| 53 | |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
54 /* Global option, may be set by main() */ |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
55 int killprint; |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
56 |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
57 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
58 /* Forward declarations */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
59 |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
60 #ifdef LLTRACE |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
61 static int prtrace PROTO((object *, char *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
62 #endif |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
63 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
|
64 static int call_trace |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
65 PROTO((object **, object **, frameobject *, char *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
66 static object *add PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
67 static object *sub PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
68 static object *mul PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
69 static object *divide PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
70 static object *rem PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
71 static object *neg PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
72 static object *pos PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
73 static object *not PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
74 static object *invert PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
75 static object *lshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
76 static object *rshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
77 static object *and PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
78 static object *xor PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
79 static object *or PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
80 static object *call_builtin PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
81 static object *call_function PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
82 static object *apply_subscript PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
83 static object *loop_subscript PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
84 static int slice_index PROTO((object *, int, int *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
85 static object *apply_slice PROTO((object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
86 static int assign_subscript PROTO((object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
87 static int assign_slice PROTO((object *, object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
88 static int cmp_exception PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
89 static int cmp_member PROTO((object *, object *)); |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
90 static object *cmp_outcome PROTO((int, object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
91 static int import_from PROTO((object *, object *, object *)); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
92 static object *build_class PROTO((object *, object *, object *)); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
93 static void locals_2_fast PROTO((frameobject *, int)); |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
94 static void fast_2_locals PROTO((frameobject *)); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
95 static int access_statement PROTO((object *, object *, frameobject *)); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
96 static int exec_statement PROTO((object *, object *, object *)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
97 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
98 |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
99 /* Pointer to current frame, used to link new frames to */ |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
100 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
101 static frameobject *current_frame; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
102 |
| 926 | 103 #ifdef USE_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
104 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
105 #include <errno.h> |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
106 #include "thread.h" |
| 926 | 107 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
108 static type_lock interpreter_lock; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
109 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
110 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
111 init_save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
112 { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
113 if (interpreter_lock) |
| 1179 | 114 return; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
115 interpreter_lock = allocate_lock(); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
116 acquire_lock(interpreter_lock, 1); |
| 926 | 117 } |
| 118 | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
119 #endif |
| 926 | 120 |
| 121 /* Functions save_thread and restore_thread are always defined so | |
| 122 dynamically loaded modules needn't be compiled separately for use | |
| 123 with and without threads: */ | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
124 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
125 object * |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
126 save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
127 { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
128 #ifdef USE_THREAD |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
129 if (interpreter_lock) { |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
130 object *res; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
131 res = (object *)current_frame; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
132 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
133 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
134 return res; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
135 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
136 #endif |
|
1271
2919b448e385
* Microscopic corrections to make things compile on the Cray APP.
Guido van Rossum <guido@python.org>
parents:
1263
diff
changeset
|
137 return NULL; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
138 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
139 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
140 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
141 restore_thread(x) |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
142 object *x; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
143 { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
144 #ifdef USE_THREAD |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
145 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
146 int err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
147 err = errno; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
148 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
149 errno = err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
150 current_frame = (frameobject *)x; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
151 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
152 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
153 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
154 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
155 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
156 /* 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
|
157 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
158 enum why_code { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
159 WHY_NOT, /* No error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
160 WHY_EXCEPTION, /* Exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
161 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
|
162 WHY_RETURN, /* 'return' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
163 WHY_BREAK /* 'break' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
164 }; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
165 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
166 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
167 /* Interpreter main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
168 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
169 object * |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
170 eval_code(co, globals, locals, owner, arg) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
171 codeobject *co; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
172 object *globals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
173 object *locals; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
174 object *owner; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
175 object *arg; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
176 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
177 register unsigned char *next_instr; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
178 register int opcode; /* Current opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
179 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
|
180 register object **stack_pointer; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 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
|
185 register object *w; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
186 register object *u; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
187 register object *t; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
188 register frameobject *f; /* Current frame */ |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
189 register listobject *fastlocals = NULL; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
190 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
|
191 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
|
192 char *name; /* Name used by some instructions */ |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
193 int needmerge = 0; /* Set if need to merge locals back at end */ |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
194 int defmode = 0; /* Default access mode for new variables */ |
| 567 | 195 #ifdef LLTRACE |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
196 int lltrace; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
197 #endif |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
198 #ifdef DEBUG |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
199 /* Make it easier to find out where we are with dbx */ |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
200 char *filename = getstringvalue(co->co_filename); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
201 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
202 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
203 /* Code access macros */ |
|
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 #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
|
206 #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
|
207 #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
|
208 #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
|
209 #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
|
210 #define NEXTOP() (*next_instr++) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
211 #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
|
212 #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
|
213 #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
|
214 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
215 /* Stack manipulation macros */ |
|
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 #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
|
218 #define EMPTY() (STACK_LEVEL() == 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
219 #define TOP() (stack_pointer[-1]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
220 #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
|
221 #define BASIC_POP() (*--stack_pointer) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
222 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
223 #define CHECK_STACK(n) (STACK_LEVEL() + (n) < f->f_nvalues || \ |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
224 (stack_pointer = extend_stack(f, STACK_LEVEL(), n))) |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
225 |
| 567 | 226 #ifdef LLTRACE |
| 227 #define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) | |
| 228 #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
|
229 #else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
230 #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
|
231 #define POP() BASIC_POP() |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
232 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
233 |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
234 if (globals == NULL) { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
235 globals = getglobals(); |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
236 if (locals == NULL) { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
237 locals = getlocals(); |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
238 needmerge = 1; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
239 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
240 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
241 else { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
242 if (locals == NULL) |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
243 locals = globals; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
244 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
245 |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
246 #ifdef LLTRACE |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
247 lltrace = dictlookup(globals, "__lltrace__") != NULL; |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
248 #endif |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
249 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
250 f = newframeobject( |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
251 current_frame, /*back*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
252 co, /*code*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
253 globals, /*globals*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
254 locals, /*locals*/ |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
255 owner, /*owner*/ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
256 50, /*nvalues*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
257 20); /*nblocks*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
258 if (f == NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
259 return NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
260 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
261 current_frame = f; |
| 567 | 262 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
263 if (sys_trace != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
264 /* sys_trace, if defined, is a function that will |
| 567 | 265 be called on *every* entry to a code block. |
| 266 Its return value, if not None, is a function that | |
| 267 will be called at the start of each executed line | |
| 268 of code. (Actually, the function must return | |
| 269 itself in order to continue tracing.) | |
| 270 The trace functions are called with three arguments: | |
| 271 a pointer to the current frame, a string indicating | |
| 272 why the function is called, and an argument which | |
| 273 depends on the situation. The global trace function | |
| 274 (sys.trace) is also called whenever an exception | |
| 275 is detected. */ | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
276 if (call_trace(&sys_trace, &trace, f, "call", arg)) { |
| 567 | 277 /* Trace function raised an error */ |
| 278 current_frame = f->f_back; | |
| 279 DECREF(f); | |
| 280 return NULL; | |
| 281 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
282 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
283 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
284 if (sys_profile != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
285 /* 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
|
286 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
|
287 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
|
288 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
|
289 DECREF(f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
290 return NULL; |
| 567 | 291 } |
| 292 } | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
293 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
294 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
|
295 stack_pointer = f->f_valuestack; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
296 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
297 if (arg != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
298 INCREF(arg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
299 PUSH(arg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
300 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
301 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
302 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
303 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
304 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
|
305 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
306 for (;;) { |
|
237
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
307 static int ticker; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
308 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
309 /* Do periodic things. |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
310 Doing this every time through the loop would add |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
311 too much overhead (a function call per instruction). |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
312 So we do it only every tenth instruction. */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
313 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
314 if (--ticker < 0) { |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
315 ticker = 10; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
316 if (intrcheck()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
317 err_set(KeyboardInterrupt); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
318 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
319 goto on_error; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
320 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
321 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
322 #ifdef USE_THREAD |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
323 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
324 /* Give another thread a chance */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
325 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
326 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
327 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
328 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
329 /* Other threads may run now */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
330 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
331 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
332 current_frame = f; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
333 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
334 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
335 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
336 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
337 /* Extract opcode and argument */ |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
338 |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
339 #ifdef DEBUG |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
340 f->f_lasti = INSTR_OFFSET(); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
341 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
342 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
343 opcode = NEXTOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
344 if (HAS_ARG(opcode)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
345 oparg = NEXTARG(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
346 |
| 567 | 347 #ifdef LLTRACE |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
348 /* Instruction tracing */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
349 |
| 567 | 350 if (lltrace) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
351 if (HAS_ARG(opcode)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
352 printf("%d: %d, %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
353 (int) (INSTR_OFFSET() - 3), |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
354 opcode, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
355 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
356 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
357 printf("%d: %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
358 (int) (INSTR_OFFSET() - 1), opcode); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
359 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
360 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
361 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
362 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
363 if (!CHECK_STACK(3)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
364 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
365 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
366 } |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
367 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
368 /* Main switch on opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
369 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
370 switch (opcode) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
371 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
372 /* BEWARE! |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
373 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
|
374 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
|
375 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
|
376 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
377 /* 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
|
378 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
379 case POP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
380 v = POP(); |
|
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 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
383 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
384 case ROT_TWO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
385 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
386 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
387 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
388 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
389 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
390 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
391 case ROT_THREE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
392 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
393 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
394 x = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
395 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
396 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
397 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
398 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
399 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
400 case DUP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
401 v = TOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
402 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
403 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
404 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
405 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
406 case UNARY_POSITIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
407 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
408 x = pos(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
409 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
410 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
411 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
412 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
413 case UNARY_NEGATIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
414 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
415 x = neg(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
416 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
417 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
418 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
419 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
420 case UNARY_NOT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
421 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
422 x = not(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
423 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
424 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
425 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
426 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
427 case UNARY_CONVERT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
428 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
429 x = reprobject(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
430 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
431 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
432 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
433 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
434 case UNARY_CALL: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
435 v = POP(); |
| 567 | 436 f->f_lasti = INSTR_OFFSET() - 1; /* For tracing */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
437 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
|
438 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
439 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
440 break; |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
441 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
442 case UNARY_INVERT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
443 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
444 x = invert(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
445 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
446 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
447 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
448 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
449 case BINARY_MULTIPLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
450 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
451 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
452 x = mul(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
453 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
454 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
455 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
456 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
457 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
458 case BINARY_DIVIDE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
459 w = POP(); |
|
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 x = divide(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
462 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
463 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
464 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
465 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
466 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
467 case BINARY_MODULO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
468 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
469 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
470 x = rem(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
471 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
472 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
473 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
474 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
475 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
476 case BINARY_ADD: |
|
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 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
479 x = add(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
480 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
481 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
482 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
483 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
484 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
485 case BINARY_SUBTRACT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
486 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
487 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
488 x = sub(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
489 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
490 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
491 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
492 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
493 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
494 case BINARY_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
495 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
496 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
497 x = apply_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
498 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
499 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
500 PUSH(x); |
|
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 BINARY_CALL: |
|
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(); |
| 567 | 506 f->f_lasti = INSTR_OFFSET() - 1; /* For tracing */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
507 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
|
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 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
511 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
512 |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
513 case BINARY_LSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
514 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
515 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
516 x = lshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
517 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
518 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
519 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
520 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
521 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
522 case BINARY_RSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
523 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
524 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
525 x = rshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
526 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
527 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
528 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
529 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
530 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
531 case BINARY_AND: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
532 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
533 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
534 x = and(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
535 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
536 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
537 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
538 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
539 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
540 case BINARY_XOR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
541 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
542 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
543 x = xor(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
544 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
545 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
546 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
547 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
548 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
549 case BINARY_OR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
550 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
551 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
552 x = or(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
553 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
554 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
555 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
556 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
557 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
558 case SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
559 case SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
560 case SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
561 case SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
562 if ((opcode-SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
563 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
564 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
565 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
566 if ((opcode-SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
567 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
568 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
569 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
570 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
571 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
|
572 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
573 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
574 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
575 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
576 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
577 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
578 case STORE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
579 case STORE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
580 case STORE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
581 case STORE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
582 if ((opcode-STORE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
583 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
584 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
585 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
586 if ((opcode-STORE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
587 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
588 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
589 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
590 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
591 t = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
592 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
|
593 DECREF(t); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
594 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
595 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
596 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
597 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
598 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
599 case DELETE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
600 case DELETE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
601 case DELETE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
602 case DELETE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
603 if ((opcode-DELETE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
604 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
605 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
606 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
607 if ((opcode-DELETE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
608 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
609 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
610 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
611 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
612 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
|
613 /* del u[v:w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
614 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
615 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
616 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
617 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
618 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
619 case STORE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
620 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
621 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
622 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
623 /* v[w] = u */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
624 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
|
625 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
626 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
627 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
628 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
629 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
630 case DELETE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
631 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
632 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
633 /* del v[w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
634 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
|
635 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
636 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
637 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
638 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
639 case PRINT_EXPR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
640 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
641 /* 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
|
642 if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
643 flushline(); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
644 x = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
645 softspace(x, 1); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
646 err = writeobject(v, x, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
647 flushline(); |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
648 if (killprint) { |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
649 err_setstr(RuntimeError, |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
650 "printing expression statement"); |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
651 x = 0; |
|
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
652 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
653 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
654 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
655 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
656 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
657 case PRINT_ITEM: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
658 v = POP(); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
659 w = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
660 if (softspace(w, 1)) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
661 writestring(" ", w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
662 if (is_stringobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
663 char *s = getstringvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
664 int len = getstringsize(v); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
665 err = writeobject(v, w, PRINT_RAW); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
666 if (err == 0 && len > 0 && s[len-1] == '\n') |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
667 softspace(w, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
668 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
669 else { |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
670 err = writeobject(v, w, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
671 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
672 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
673 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
674 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
675 case PRINT_NEWLINE: |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
676 x = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
677 if (x == NULL) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
678 err_setstr(RuntimeError, "lost sys.stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
679 else { |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
680 writestring("\n", x); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
681 softspace(x, 0); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
682 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
683 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
684 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
685 case BREAK_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
686 why = WHY_BREAK; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
687 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
688 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
689 case RAISE_EXCEPTION: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
690 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
691 w = POP(); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
692 /* 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
|
693 while (is_tupleobject(w)) { |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
694 u = w; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
695 w = gettupleitem(u, 0); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
696 DECREF(u); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
697 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
698 if (!is_stringobject(w)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
699 err_setstr(TypeError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
700 "exceptions must be strings"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
701 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
702 err_setval(w, v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
703 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
704 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
705 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
706 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
707 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
708 case LOAD_LOCALS: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
709 v = f->f_locals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
710 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
711 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
712 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
713 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
714 case RETURN_VALUE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
715 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
716 why = WHY_RETURN; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
717 break; |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
718 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
719 case LOAD_GLOBALS: |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
720 v = f->f_locals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
721 INCREF(v); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
722 PUSH(v); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
723 break; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
724 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
725 case EXEC_STMT: |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
726 w = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
727 v = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
728 u = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
729 err = exec_statement(u, v, w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
730 DECREF(u); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
731 DECREF(v); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
732 DECREF(w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
733 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
734 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
735 case BUILD_FUNCTION: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
736 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
737 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
|
738 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
739 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
740 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
741 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
742 case POP_BLOCK: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
743 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
744 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
745 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
|
746 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
747 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
748 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
749 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
750 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
751 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
752 case END_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
753 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
754 if (is_intobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
755 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
|
756 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
757 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
758 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
759 else if (is_stringobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
760 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
761 err_setval(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
762 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
763 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
764 tb_store(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
765 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
766 why = WHY_RERAISE; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
767 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
768 else if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
769 err_setstr(SystemError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
770 "'finally' pops bad exception"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
771 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
772 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
773 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
774 break; |
|
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 case BUILD_CLASS: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
777 u = POP(); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
778 v = POP(); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
779 w = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
780 x = build_class(u, v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
781 PUSH(x); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
782 DECREF(u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
783 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
784 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
785 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
786 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
787 case STORE_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
788 w = GETNAMEV(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
789 v = POP(); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
790 u = dict2lookup(f->f_locals, w); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
791 if (u == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
792 if (defmode != 0) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
793 if (v != None) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
794 u = (object *)v->ob_type; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
795 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
796 u = NULL; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
797 x = newaccessobject(v, f->f_locals, |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
798 (typeobject *)u, |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
799 defmode); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
800 DECREF(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
801 if (x == NULL) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
802 break; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
803 v = x; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
804 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
805 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
806 else if (is_accessobject(u)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
807 err = setaccessvalue(u, f->f_locals, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
808 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
809 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
810 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
811 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
|
812 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
813 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
814 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
815 case DELETE_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
816 w = GETNAMEV(oparg); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
817 u = dict2lookup(f->f_locals, w); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
818 if (u != NULL && is_accessobject(u)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
819 err = setaccessvalue(u, f->f_locals, |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
820 (object *)NULL); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
821 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
822 } |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
823 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
|
824 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
|
825 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
826 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
827 #ifdef CASE_TOO_BIG |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
828 default: switch (opcode) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
829 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
830 |
|
581
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
831 case UNPACK_VARARG: |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
832 if (EMPTY()) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
833 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
834 "no argument list"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
835 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
836 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
837 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
838 v = POP(); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
839 if (!is_tupleobject(v)) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
840 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
841 "bad argument list"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
842 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
843 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
844 else if (gettuplesize(v) < oparg) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
845 err_setstr(TypeError, |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
846 "not enough arguments"); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
847 why = WHY_EXCEPTION; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
848 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
849 else if (oparg == 0) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
850 PUSH(v); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
851 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
852 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
853 else { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
854 x = gettupleslice(v, oparg, gettuplesize(v)); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
855 if (x != NULL) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
856 PUSH(x); |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
857 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
858 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
859 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
860 } |
|
581
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
861 for (; --oparg >= 0; ) { |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
862 w = gettupleitem(v, oparg); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
863 INCREF(w); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
864 PUSH(w); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
865 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
866 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
867 } |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
868 DECREF(v); |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
869 break; |
|
bae1494f2ec8
Added UNPACK_VARARG code.
Guido van Rossum <guido@python.org>
parents:
567
diff
changeset
|
870 |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
871 case UNPACK_ARG: |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
872 { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
873 int n; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
874 if (EMPTY()) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
875 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
876 "no argument list"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
877 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
878 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
879 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
880 v = POP(); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
881 if (!is_tupleobject(v)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
882 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
883 "bad argument list"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
884 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
885 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
886 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
887 n = gettuplesize(v); |
|
1207
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
888 #ifdef COMPAT_HACKS |
|
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
889 /* Implement various compatibility hacks (for 0.9.4 or earlier): |
|
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
890 (a) f(a,b,...) accepts f((1,2,...)) |
|
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
891 (b) f((a,b,...)) accepts f(1,2,...) |
|
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
892 (c) f(self,(a,b,...)) accepts f(x,1,2,...) |
|
b564bd4e57e1
* ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
893 */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
894 if (n == 1 && oparg != 1) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
895 /* Rule (a) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
896 w = gettupleitem(v, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
897 if (is_tupleobject(w)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
898 INCREF(w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
899 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
900 v = w; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
901 n = gettuplesize(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
902 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
903 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
904 else if (n != 1 && oparg == 1) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
905 /* Rule (b) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
906 PUSH(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
907 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
908 /* Don't fall through */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
909 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
910 else if (n > 2 && oparg == 2) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
911 /* Rule (c) */ |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
912 int i; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
913 w = newtupleobject(n-1); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
914 u = newtupleobject(2); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
915 if (u == NULL || w == NULL) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
916 XDECREF(w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
917 XDECREF(u); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
918 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
919 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
920 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
921 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
922 t = gettupleitem(v, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
923 INCREF(t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
924 settupleitem(u, 0, t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
925 for (i = 1; i < n; i++) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
926 t = gettupleitem(v, i); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
927 INCREF(t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
928 settupleitem(w, i-1, t); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
929 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
930 settupleitem(u, 1, w); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
931 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
932 v = u; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
933 n = 2; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
934 } |
|
1132
6461dac9a9f2
* mymalloc.h: always allocate one extra byte, since some malloc's
Guido van Rossum <guido@python.org>
parents:
1096
diff
changeset
|
935 #endif /* Disabled compatibility hacks */ |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
936 if (n != oparg) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
937 err_setstr(TypeError, |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
938 "arg count mismatch"); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
939 why = WHY_EXCEPTION; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
940 DECREF(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
941 break; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
942 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
943 PUSH(v); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
944 } |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
945 /* Fall through */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
946 case UNPACK_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
947 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
948 if (!is_tupleobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
949 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
|
950 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
951 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
952 else if (gettuplesize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
953 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
954 "unpack tuple of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
955 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
956 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
957 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
958 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
959 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
960 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
961 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
962 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
963 w = gettupleitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
964 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
965 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
966 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
967 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
968 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
969 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
970 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
971 case UNPACK_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
972 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
973 if (!is_listobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
974 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
|
975 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
976 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
977 else if (getlistsize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
978 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
979 "unpack list of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
980 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
981 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
982 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
983 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
984 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
985 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
986 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
987 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
988 w = getlistitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
989 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
990 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
991 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
992 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
993 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
994 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
995 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
996 case STORE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
997 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
998 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
999 u = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1000 err = setattro(v, w, u); /* v.w = u */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1001 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1002 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1003 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1004 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1005 case DELETE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1006 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1007 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1008 err = setattro(v, w, (object *)NULL); /* del v.w */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1009 DECREF(v); |
|
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 |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1012 case STORE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1013 w = GETNAMEV(oparg); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1014 v = POP(); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1015 u = dict2lookup(f->f_locals, w); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1016 if (u != NULL && is_accessobject(u)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1017 err = setaccessvalue(u, f->f_globals, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1018 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1019 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1020 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1021 err = dict2insert(f->f_globals, w, v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1022 DECREF(v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1023 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1024 |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1025 case DELETE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1026 w = GETNAMEV(oparg); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1027 u = dict2lookup(f->f_locals, w); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1028 if (u != NULL && is_accessobject(u)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1029 err = setaccessvalue(u, f->f_globals, |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1030 (object *)NULL); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1031 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1032 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1033 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
|
1034 err_setstr(NameError, getstringvalue(w)); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1035 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1036 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1037 case LOAD_CONST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1038 x = GETCONST(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1039 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1040 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1041 break; |
|
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 case LOAD_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1044 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1045 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
|
1046 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1047 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1048 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
|
1049 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1050 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1051 x = getbuiltin(w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1052 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1053 err_setstr(NameError, |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1054 getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1055 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1056 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1057 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1058 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1059 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1060 x = getaccessvalue(x, f->f_globals /* XXX */); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1061 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1062 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1063 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1064 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1065 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1066 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1067 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1068 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1069 case LOAD_GLOBAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1070 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1071 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
|
1072 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1073 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1074 x = getbuiltin(w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1075 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1076 err_setstr(NameError, |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1077 getstringvalue(w)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1078 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1079 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1080 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1081 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1082 x = getaccessvalue(x, f->f_globals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1083 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1084 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1085 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1086 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1087 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1088 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1089 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1090 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1091 case LOAD_LOCAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1092 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1093 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
|
1094 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1095 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
|
1096 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1097 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1098 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1099 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1100 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1101 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1102 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1103 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1104 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1105 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1106 break; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1107 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1108 case RESERVE_FAST: |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1109 x = GETCONST(oparg); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1110 if (x == None) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1111 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1112 if (x == NULL || !is_dictobject(x)) { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1113 fatal("bad RESERVE_FAST"); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1114 err_setstr(SystemError, "bad RESERVE_FAST"); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1115 x = NULL; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1116 break; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1117 } |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1118 XDECREF(f->f_fastlocals); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1119 XDECREF(f->f_localmap); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1120 INCREF(x); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1121 f->f_localmap = x; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1122 f->f_fastlocals = x = newlistobject( |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1123 x->ob_type->tp_as_mapping->mp_length(x)); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1124 fastlocals = (listobject *) x; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1125 break; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1126 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1127 case LOAD_FAST: |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1128 x = GETLISTITEM(fastlocals, oparg); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1129 if (x == NULL) { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1130 err_setstr(NameError, |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1131 "undefined local variable"); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1132 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1133 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1134 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1135 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1136 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1137 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1138 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1139 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1140 INCREF(x); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1141 PUSH(x); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1142 break; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1143 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1144 case STORE_FAST: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1145 v = POP(); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1146 w = GETLISTITEM(fastlocals, oparg); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1147 if (w != NULL && is_accessobject(w)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1148 err = setaccessvalue(w, f->f_locals, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1149 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1150 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1151 } |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1152 XDECREF(w); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1153 GETLISTITEM(fastlocals, oparg) = v; |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1154 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1155 |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1156 case DELETE_FAST: |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1157 x = GETLISTITEM(fastlocals, oparg); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1158 if (x == NULL) { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1159 err_setstr(NameError, |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1160 "undefined local variable"); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1161 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1162 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1163 if (w != NULL && is_accessobject(w)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1164 err = setaccessvalue(w, f->f_locals, |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1165 (object *)NULL); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1166 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1167 } |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1168 DECREF(x); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1169 GETLISTITEM(fastlocals, oparg) = NULL; |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1170 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1171 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1172 case BUILD_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1173 x = newtupleobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1174 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1175 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1176 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1177 err = settupleitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1178 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1179 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1180 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1181 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1182 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1183 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1184 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1185 case BUILD_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1186 x = newlistobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1187 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1188 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1189 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1190 err = setlistitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1191 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1192 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1193 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1194 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1195 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1196 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1197 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1198 case BUILD_MAP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1199 x = newdictobject(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1200 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1201 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1202 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1203 case LOAD_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1204 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1205 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1206 x = getattro(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1207 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1208 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1209 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1210 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1211 case COMPARE_OP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1212 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1213 v = POP(); |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
1214 x = cmp_outcome(oparg, v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1215 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1216 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1217 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1218 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1219 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1220 case IMPORT_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1221 name = GETNAME(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1222 x = import_module(name); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1223 XINCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1224 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1225 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1226 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1227 case IMPORT_FROM: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1228 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1229 v = TOP(); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1230 err = import_from(f->f_locals, v, w); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1231 locals_2_fast(f, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1232 break; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1233 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1234 case ACCESS_MODE: |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1235 v = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1236 w = GETNAMEV(oparg); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1237 if (getstringvalue(w)[0] == '*') |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1238 defmode = getintvalue(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1239 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1240 err = access_statement(w, v, f); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1241 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1242 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1243 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1244 case JUMP_FORWARD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1245 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1246 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1247 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1248 case JUMP_IF_FALSE: |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1249 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1250 if (err > 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1251 err = 0; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1252 else if (err == 0) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1253 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1254 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1255 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1256 case JUMP_IF_TRUE: |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1257 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1258 if (err > 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1259 err = 0; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1260 JUMPBY(oparg); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1261 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1262 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1263 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1264 case JUMP_ABSOLUTE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1265 JUMPTO(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1266 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1267 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1268 case FOR_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1269 /* for v in s: ... |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1270 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
|
1271 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
|
1272 but if loop exhausted: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1273 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
|
1274 w = POP(); /* Loop index */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1275 v = POP(); /* Sequence object */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1276 u = loop_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1277 if (u != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1278 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1279 x = newintobject(getintvalue(w)+1); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1280 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1281 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1282 PUSH(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1283 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1284 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1285 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1286 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1287 /* 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
|
1288 but also an error: */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1289 if (err_occurred()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1290 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1291 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1292 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1293 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1294 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1295 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1296 case SETUP_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1297 case SETUP_EXCEPT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1298 case SETUP_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1299 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
|
1300 STACK_LEVEL()); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1301 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1302 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1303 case SET_LINENO: |
| 567 | 1304 #ifdef LLTRACE |
| 1305 if (lltrace) | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1306 printf("--- Line %d ---\n", oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1307 #endif |
| 567 | 1308 f->f_lineno = oparg; |
| 1309 if (trace != NULL) { | |
| 1310 /* Trace each line of code reached */ | |
| 1311 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
|
1312 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
|
1313 f, "line", None); |
| 567 | 1314 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1315 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1316 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1317 default: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1318 fprintf(stderr, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1319 "XXX lineno: %d, opcode: %d\n", |
| 567 | 1320 f->f_lineno, opcode); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1321 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
|
1322 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1323 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1324 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1325 #ifdef CASE_TOO_BIG |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1326 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1327 #endif |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1328 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1329 } /* switch */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1330 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1331 on_error: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1332 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1333 /* 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
|
1334 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1335 if (why == WHY_NOT) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1336 if (err == 0 && x != NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1337 continue; /* Normal, fast path */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1338 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1339 x = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1340 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1341 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1342 |
|
814
f08d34499269
reverse sense of test for CHECKEXC
Guido van Rossum <guido@python.org>
parents:
802
diff
changeset
|
1343 #ifdef CHECKEXC |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1344 /* Double-check exception status */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1345 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1346 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
|
1347 if (!err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1348 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
|
1349 err_setstr(SystemError, "ghost error"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1350 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1351 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1352 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1353 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1354 if (err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1355 fprintf(stderr, "XXX undetected error\n"); |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
1356 abort(); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
1357 /* NOTREACHED */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1358 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1359 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1360 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1361 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1362 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1363 /* 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
|
1364 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1365 if (why == WHY_EXCEPTION) { |
| 567 | 1366 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
|
1367 if (HAS_ARG(opcode)) |
| 567 | 1368 f->f_lasti -= 2; |
| 1369 tb_here(f); | |
| 1370 | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1371 if (trace) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1372 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
|
1373 if (sys_profile) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1374 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
|
1375 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1376 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1377 /* 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
|
1378 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1379 if (why == WHY_RERAISE) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1380 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1381 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1382 /* 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
|
1383 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1384 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
|
1385 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1386 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
|
1387 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1388 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1389 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1390 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
|
1391 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1392 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1393 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1394 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1395 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
|
1396 b->b_type == SETUP_EXCEPT && |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1397 why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1398 if (why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1399 object *exc, *val; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1400 err_get(&exc, &val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1401 if (val == NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1402 val = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1403 INCREF(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1404 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1405 v = tb_fetch(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1406 /* Make the raw exception data |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1407 available to the handler, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1408 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
|
1409 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
|
1410 this for 'finally'. */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1411 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
|
1412 sysset("exc_traceback", v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1413 sysset("exc_value", val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1414 sysset("exc_type", exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1415 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1416 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1417 PUSH(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1418 PUSH(exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1419 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1420 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1421 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1422 PUSH(retval); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1423 v = newintobject((long)why); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1424 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1425 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1426 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1427 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1428 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1429 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1430 } /* unwind stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1431 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1432 /* 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
|
1433 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1434 if (why != WHY_NOT) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1435 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1436 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1437 } /* main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1438 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1439 /* Pop remaining stack entries */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1440 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1441 while (!EMPTY()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1442 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1443 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1444 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1445 |
| 567 | 1446 if (why != WHY_RETURN) |
| 1447 retval = NULL; | |
| 1448 | |
| 1449 if (trace) { | |
| 1450 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
|
1451 if (call_trace(&trace, &trace, f, "return", retval)) { |
| 567 | 1452 XDECREF(retval); |
| 1453 retval = NULL; | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1454 why = WHY_EXCEPTION; |
| 567 | 1455 } |
| 1456 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1457 XDECREF(trace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1458 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1459 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1460 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
|
1461 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
|
1462 f, "return", retval)) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1463 XDECREF(retval); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1464 retval = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1465 why = WHY_EXCEPTION; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1466 } |
| 567 | 1467 } |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1468 |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1469 if (fastlocals && (f->ob_refcnt > 1 || f->f_locals->ob_refcnt > 2)) |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1470 fast_2_locals(f); |
| 567 | 1471 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1472 /* 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
|
1473 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1474 current_frame = f->f_back; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1475 DECREF(f); |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1476 |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1477 if (needmerge) |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1478 locals_2_fast(current_frame, 1); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1479 |
| 567 | 1480 return retval; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1481 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1482 |
| 567 | 1483 #ifdef LLTRACE |
| 86 | 1484 static int |
| 1485 prtrace(v, str) | |
| 1486 object *v; | |
| 1487 char *str; | |
| 69 | 1488 { |
| 86 | 1489 printf("%s ", str); |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1490 if (printobject(v, stdout, 0) != 0) |
|
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1491 err_clear(); /* Don't know what else to do */ |
| 86 | 1492 printf("\n"); |
| 69 | 1493 } |
| 86 | 1494 #endif |
| 69 | 1495 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1496 static void |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1497 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
|
1498 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
|
1499 frameobject *f; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1500 { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1501 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
|
1502 int err; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1503 err_get(&type, &value); |
|
815
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1504 if (value == NULL) { |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1505 value = None; |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1506 INCREF(value); |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1507 } |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1508 traceback = tb_fetch(); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1509 arg = newtupleobject(3); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1510 if (arg == NULL) |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1511 goto cleanup; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1512 settupleitem(arg, 0, type); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1513 settupleitem(arg, 1, value); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1514 settupleitem(arg, 2, traceback); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1515 err = call_trace(p_trace, p_newtrace, f, "exception", arg); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1516 if (!err) { |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1517 cleanup: |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1518 /* Restore original exception */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1519 err_setval(type, value); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1520 tb_store(traceback); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1521 } |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1522 XDECREF(arg); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1523 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1524 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1525 static int |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1526 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
|
1527 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
|
1528 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
|
1529 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
|
1530 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
|
1531 may be same variable as p_newtrace */ |
| 567 | 1532 frameobject *f; |
| 1533 char *msg; | |
| 1534 object *arg; | |
| 1535 { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1536 object *arglist, *what; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1537 object *res = NULL; |
| 567 | 1538 static int tracing = 0; |
| 1539 | |
| 1540 if (tracing) { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1541 /* 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
|
1542 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1543 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1544 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1545 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1546 return 0; |
| 567 | 1547 } |
| 1548 | |
| 1549 arglist = newtupleobject(3); | |
| 1550 if (arglist == NULL) | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1551 goto cleanup; |
| 567 | 1552 what = newstringobject(msg); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1553 if (what == NULL) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1554 goto cleanup; |
| 567 | 1555 INCREF(f); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1556 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
|
1557 settupleitem(arglist, 1, what); |
| 567 | 1558 if (arg == NULL) |
| 1559 arg = None; | |
| 1560 INCREF(arg); | |
| 1561 settupleitem(arglist, 2, arg); | |
| 1562 tracing++; | |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1563 fast_2_locals(f); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1564 res = call_object(*p_trace, arglist); |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1565 locals_2_fast(f, 1); |
| 567 | 1566 tracing--; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1567 cleanup: |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1568 XDECREF(arglist); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1569 if (res == NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1570 /* 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
|
1571 tb_here(f); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1572 DECREF(*p_trace); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1573 *p_trace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1574 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1575 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1576 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1577 } |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1578 return -1; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1579 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1580 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1581 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1582 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1583 if (res == None) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1584 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1585 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1586 INCREF(res); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1587 *p_newtrace = res; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1588 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1589 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1590 DECREF(res); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1591 return 0; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1592 } |
| 567 | 1593 } |
| 1594 | |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1595 static void |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1596 fast_2_locals(f) |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1597 frameobject *f; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1598 { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1599 /* Merge f->f_fastlocals into f->f_locals */ |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1600 object *locals, *fast, *map; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1601 object *error_type, *error_value; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1602 int pos; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1603 object *key, *value; |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1604 if (f == NULL) |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1605 return; |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1606 locals = f->f_locals; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1607 fast = f->f_fastlocals; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1608 map = f->f_localmap; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1609 if (locals == NULL || fast == NULL || map == NULL) |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1610 return; |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1611 if (!is_dictobject(locals) || !is_listobject(fast) || |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1612 !is_dictobject(map)) |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1613 return; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1614 err_get(&error_type, &error_value); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1615 pos = 0; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1616 while (mappinggetnext(map, &pos, &key, &value)) { |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1617 int j; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1618 if (!is_intobject(value)) |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1619 continue; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1620 j = getintvalue(value); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1621 value = getlistitem(fast, j); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1622 if (value == NULL) { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1623 err_clear(); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1624 if (dict2remove(locals, key) != 0) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1625 err_clear(); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1626 } |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1627 else { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1628 if (dict2insert(locals, key, value) != 0) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1629 err_clear(); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1630 } |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1631 } |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1632 err_setval(error_type, error_value); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1633 } |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1634 |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1635 static void |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1636 locals_2_fast(f, clear) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1637 frameobject *f; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1638 int clear; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1639 { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1640 /* Merge f->f_locals into f->f_fastlocals */ |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1641 object *locals, *fast, *map; |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
1642 object *error_type, *error_value; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1643 int pos; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1644 object *key, *value; |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1645 if (f == NULL) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1646 return; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1647 locals = f->f_locals; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1648 fast = f->f_fastlocals; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1649 map = f->f_localmap; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1650 if (locals == NULL || fast == NULL || map == NULL) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1651 return; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1652 if (!is_dictobject(locals) || !is_listobject(fast) || |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1653 !is_dictobject(map)) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1654 return; |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
1655 err_get(&error_type, &error_value); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1656 pos = 0; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1657 while (mappinggetnext(map, &pos, &key, &value)) { |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1658 int j; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1659 if (!is_intobject(value)) |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1660 continue; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1661 j = getintvalue(value); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1662 value = dict2lookup(locals, key); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1663 if (value == NULL) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1664 err_clear(); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1665 else |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1666 INCREF(value); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1667 if (value != NULL || clear) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1668 if (setlistitem(fast, j, value) != 0) |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1669 err_clear(); |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1670 } |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
1671 err_setval(error_type, error_value); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1672 } |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1673 |
|
1319
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1318
diff
changeset
|
1674 static void |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1675 mergelocals() |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1676 { |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1677 locals_2_fast(current_frame, 1); |
| 69 | 1678 } |
| 1679 | |
| 86 | 1680 object * |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1681 getlocals() |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1682 { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1683 if (current_frame == NULL) |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1684 return NULL; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1685 fast_2_locals(current_frame); |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1686 return current_frame->f_locals; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1687 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1688 |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1689 object * |
| 86 | 1690 getglobals() |
| 69 | 1691 { |
| 86 | 1692 if (current_frame == NULL) |
| 1693 return NULL; | |
| 1694 else | |
| 1695 return current_frame->f_globals; | |
| 69 | 1696 } |
| 1697 | |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1698 object * |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1699 getowner() |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1700 { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1701 if (current_frame == NULL) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1702 return NULL; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1703 else |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1704 return current_frame->f_owner; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1705 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1706 |
| 86 | 1707 void |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1708 printtraceback(f) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1709 object *f; |
| 69 | 1710 { |
| 86 | 1711 object *v = tb_fetch(); |
| 1712 if (v != NULL) { | |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1713 writestring("Stack backtrace (innermost last):\n", f); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1714 tb_print(v, f); |
| 86 | 1715 DECREF(v); |
| 69 | 1716 } |
| 1717 } | |
| 1718 | |
| 1719 | |
| 1720 void | |
| 1721 flushline() | |
| 1722 { | |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1723 object *f = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1724 if (softspace(f, 0)) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1725 writestring("\n", f); |
| 69 | 1726 } |
| 1727 | |
| 86 | 1728 |
| 69 | 1729 static object * |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1730 or(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1731 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1732 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1733 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1734 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1735 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1736 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1737 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1738 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
|
1739 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1740 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1741 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1742 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1743 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1744 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1745 err_setstr(TypeError, "bad operand type(s) for |"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1746 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1747 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1748 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1749 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1750 xor(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1751 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1752 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1753 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1754 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1755 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1756 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1757 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1758 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
|
1759 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1760 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1761 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1762 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1763 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1764 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1765 err_setstr(TypeError, "bad operand type(s) for ^"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1766 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1767 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1768 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1769 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1770 and(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1771 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1772 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1773 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1774 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1775 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1776 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1777 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1778 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
|
1779 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1780 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1781 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1782 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1783 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1784 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1785 err_setstr(TypeError, "bad operand type(s) for &"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1786 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1787 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1788 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1789 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1790 lshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1791 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1792 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1793 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1794 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1795 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1796 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1797 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1798 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
|
1799 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1800 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1801 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1802 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1803 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1804 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1805 err_setstr(TypeError, "bad operand type(s) for <<"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1806 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1807 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1808 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1809 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1810 rshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1811 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1812 { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1813 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1814 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1815 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1816 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1817 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1818 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
|
1819 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1820 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1821 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1822 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1823 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1824 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1825 err_setstr(TypeError, "bad operand type(s) for >>"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1826 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1827 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1828 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1829 static object * |
| 86 | 1830 add(v, w) |
| 69 | 1831 object *v, *w; |
| 1832 { | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1833 if (v->ob_type->tp_as_sequence != NULL) |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1834 return (*v->ob_type->tp_as_sequence->sq_concat)(v, w); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1835 else if (v->ob_type->tp_as_number != NULL) { |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1836 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1837 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
|
1838 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1839 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
|
1840 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1841 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1842 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1843 } |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
1844 err_setstr(TypeError, "bad operand type(s) for +"); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
1845 return NULL; |
| 69 | 1846 } |
| 1847 | |
| 1848 static object * | |
| 86 | 1849 sub(v, w) |
| 69 | 1850 object *v, *w; |
| 1851 { | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1852 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
|
1853 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1854 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
|
1855 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1856 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
|
1857 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1858 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1859 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1860 } |
| 86 | 1861 err_setstr(TypeError, "bad operand type(s) for -"); |
| 69 | 1862 return NULL; |
| 1863 } | |
| 1864 | |
| 1865 static object * | |
| 86 | 1866 mul(v, w) |
| 69 | 1867 object *v, *w; |
| 1868 { | |
| 1869 typeobject *tp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1870 tp = v->ob_type; |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1871 if (tp->tp_as_number != NULL && |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1872 w->ob_type->tp_as_sequence != NULL && |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1873 !is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1874 /* number*sequence -- swap v and w */ |
| 69 | 1875 object *tmp = v; |
| 1876 v = w; | |
| 1877 w = tmp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1878 tp = v->ob_type; |
| 69 | 1879 } |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1880 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
|
1881 object *x; |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1882 if (is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1883 /* Instances of user-defined classes get their |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1884 other argument uncoerced, so they may |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1885 implement sequence*number as well as |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1886 number*number. */ |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1887 INCREF(v); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1888 INCREF(w); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1889 } |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
1890 else if (coerce(&v, &w) != 0) |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1891 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1892 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
|
1893 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1894 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1895 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1896 } |
| 69 | 1897 if (tp->tp_as_sequence != NULL) { |
| 1898 if (!is_intobject(w)) { | |
| 86 | 1899 err_setstr(TypeError, |
| 1900 "can't multiply sequence with non-int"); | |
| 69 | 1901 return NULL; |
| 1902 } | |
| 86 | 1903 return (*tp->tp_as_sequence->sq_repeat) |
| 1904 (v, (int)getintvalue(w)); | |
| 69 | 1905 } |
| 86 | 1906 err_setstr(TypeError, "bad operand type(s) for *"); |
| 69 | 1907 return NULL; |
| 1908 } | |
| 1909 | |
| 1910 static object * | |
|
88
16e8c5d16493
Change div() into divide(); div() is a Standard C function.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1911 divide(v, w) |
| 69 | 1912 object *v, *w; |
| 1913 { | |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1914 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
|
1915 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1916 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
|
1917 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1918 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
|
1919 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1920 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1921 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1922 } |
| 86 | 1923 err_setstr(TypeError, "bad operand type(s) for /"); |
| 69 | 1924 return NULL; |
| 1925 } | |
| 1926 | |
| 1927 static object * | |
| 86 | 1928 rem(v, w) |
| 1929 object *v, *w; | |
| 69 | 1930 { |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1931 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
|
1932 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1933 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
|
1934 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1935 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
|
1936 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1937 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1938 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
1939 } |
|
1252
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1207
diff
changeset
|
1940 if (is_stringobject(v)) { |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1207
diff
changeset
|
1941 return formatstring(v, w); |
|
c4cd0d9d8281
* Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents:
1207
diff
changeset
|
1942 } |
| 86 | 1943 err_setstr(TypeError, "bad operand type(s) for %"); |
| 69 | 1944 return NULL; |
| 1945 } | |
| 1946 | |
| 1947 static object * | |
| 86 | 1948 neg(v) |
| 69 | 1949 object *v; |
| 1950 { | |
| 1951 if (v->ob_type->tp_as_number != NULL) | |
| 86 | 1952 return (*v->ob_type->tp_as_number->nb_negative)(v); |
| 1953 err_setstr(TypeError, "bad operand type(s) for unary -"); | |
| 1954 return NULL; | |
| 1955 } | |
| 1956 | |
| 1957 static object * | |
| 1958 pos(v) | |
| 1959 object *v; | |
| 1960 { | |
| 1961 if (v->ob_type->tp_as_number != NULL) | |
| 1962 return (*v->ob_type->tp_as_number->nb_positive)(v); | |
| 1963 err_setstr(TypeError, "bad operand type(s) for unary +"); | |
| 69 | 1964 return NULL; |
| 1965 } | |
| 1966 | |
| 1967 static object * | |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1968 invert(v) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1969 object *v; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1970 { |
|
671
10002e1bc526
Use correct prototype for invert().
Guido van Rossum <guido@python.org>
parents:
661
diff
changeset
|
1971 object * (*f) FPROTO((object *)); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1972 if (v->ob_type->tp_as_number != NULL && |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1973 (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
|
1974 return (*f)(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1975 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
|
1976 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1977 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1978 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1979 static object * |
| 86 | 1980 not(v) |
| 69 | 1981 object *v; |
| 1982 { | |
| 86 | 1983 int outcome = testbool(v); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1984 object *w; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1985 if (outcome < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1986 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1987 if (outcome == 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1988 w = True; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1989 else |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1990 w = False; |
| 86 | 1991 INCREF(w); |
| 1992 return w; | |
| 69 | 1993 } |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
1994 |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
1995 |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1996 /* 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
|
1997 |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1998 object * |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
1999 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
|
2000 object *func; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2001 object *arg; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2002 { |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2003 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
|
2004 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
|
2005 else |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2006 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
|
2007 } |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2008 |
| 69 | 2009 static object * |
| 86 | 2010 call_builtin(func, arg) |
| 69 | 2011 object *func; |
| 86 | 2012 object *arg; |
| 69 | 2013 { |
| 2014 if (is_methodobject(func)) { | |
| 2015 method meth = getmethod(func); | |
| 2016 object *self = getself(func); | |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2017 if (!getvarargs(func) && arg != NULL && is_tupleobject(arg)) { |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2018 int size = gettuplesize(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2019 if (size == 1) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2020 arg = gettupleitem(arg, 0); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2021 else if (size == 0) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2022 arg = NULL; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2023 } |
| 86 | 2024 return (*meth)(self, arg); |
| 69 | 2025 } |
| 2026 if (is_classobject(func)) { | |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2027 return newinstanceobject(func, arg); |
| 69 | 2028 } |
| 86 | 2029 err_setstr(TypeError, "call of non-function"); |
| 69 | 2030 return NULL; |
| 2031 } | |
| 2032 | |
| 2033 static object * | |
| 86 | 2034 call_function(func, arg) |
| 69 | 2035 object *func; |
| 86 | 2036 object *arg; |
| 69 | 2037 { |
| 86 | 2038 object *newarg = NULL; |
| 2039 object *newlocals, *newglobals; | |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2040 object *class = NULL; |
| 86 | 2041 object *co, *v; |
| 69 | 2042 |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2043 if (is_instancemethodobject(func)) { |
|
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2044 object *self = instancemethodgetself(func); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2045 class = instancemethodgetclass(func); |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2046 func = instancemethodgetfunc(func); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2047 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2048 /* Unbound methods must be called with an instance of |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2049 the class (or a derived class) as first argument */ |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2050 if (arg != NULL && is_tupleobject(arg) && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2051 gettuplesize(arg) >= 1) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2052 self = gettupleitem(arg, 0); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2053 if (self != NULL && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2054 is_instanceobject(self) && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2055 issubclass((object *) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2056 (((instanceobject *)self)->in_class), |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2057 class)) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2058 /* self = self */ ; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2059 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2060 self = NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2061 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2062 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2063 err_setstr(TypeError, |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2064 "unbound method must be called with class instance argument"); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2065 return NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2066 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2067 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2068 else { |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2069 int argcount; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2070 if (arg == NULL) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2071 argcount = 0; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2072 else if (is_tupleobject(arg)) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2073 argcount = gettuplesize(arg); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2074 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2075 argcount = 1; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2076 newarg = newtupleobject(argcount + 1); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2077 if (newarg == NULL) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2078 return NULL; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2079 INCREF(self); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2080 settupleitem(newarg, 0, self); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2081 if (arg != NULL && !is_tupleobject(arg)) { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2082 INCREF(arg); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2083 settupleitem(newarg, 1, arg); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2084 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2085 else { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2086 int i; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2087 object *v; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2088 for (i = 0; i < argcount; i++) { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2089 v = gettupleitem(arg, i); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2090 XINCREF(v); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2091 settupleitem(newarg, i+1, v); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2092 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2093 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2094 arg = newarg; |
| 69 | 2095 } |
| 2096 } | |
| 2097 else { | |
| 2098 if (!is_funcobject(func)) { | |
| 86 | 2099 err_setstr(TypeError, "call of non-function"); |
| 69 | 2100 return NULL; |
| 2101 } | |
| 2102 } | |
| 2103 | |
| 86 | 2104 co = getfunccode(func); |
| 2105 if (co == NULL) { | |
| 2106 XDECREF(newarg); | |
| 69 | 2107 return NULL; |
| 2108 } | |
| 86 | 2109 if (!is_codeobject(co)) { |
| 2110 fprintf(stderr, "XXX Bad code\n"); | |
| 69 | 2111 abort(); |
| 2112 } | |
| 86 | 2113 newlocals = newdictobject(); |
| 69 | 2114 if (newlocals == NULL) { |
| 86 | 2115 XDECREF(newarg); |
| 69 | 2116 return NULL; |
| 2117 } | |
| 2118 | |
| 86 | 2119 newglobals = getfuncglobals(func); |
| 2120 INCREF(newglobals); | |
| 2121 | |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2122 v = eval_code((codeobject *)co, newglobals, newlocals, class, arg); |
| 69 | 2123 |
| 86 | 2124 DECREF(newlocals); |
| 2125 DECREF(newglobals); | |
| 69 | 2126 |
| 86 | 2127 XDECREF(newarg); |
| 69 | 2128 |
| 2129 return v; | |
| 2130 } | |
| 2131 | |
| 2132 static object * | |
| 86 | 2133 apply_subscript(v, w) |
| 69 | 2134 object *v, *w; |
| 2135 { | |
| 2136 typeobject *tp = v->ob_type; | |
| 2137 if (tp->tp_as_sequence == NULL && tp->tp_as_mapping == NULL) { | |
| 86 | 2138 err_setstr(TypeError, "unsubscriptable object"); |
| 69 | 2139 return NULL; |
| 2140 } | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2141 if (tp->tp_as_mapping != NULL) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2142 return (*tp->tp_as_mapping->mp_subscript)(v, w); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2143 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2144 else { |
| 69 | 2145 int i; |
| 2146 if (!is_intobject(w)) { | |
| 86 | 2147 err_setstr(TypeError, "sequence subscript not int"); |
| 69 | 2148 return NULL; |
| 2149 } | |
| 2150 i = getintvalue(w); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2151 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2152 int len = (*tp->tp_as_sequence->sq_length)(v); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2153 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2154 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2155 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2156 } |
| 86 | 2157 return (*tp->tp_as_sequence->sq_item)(v, i); |
| 69 | 2158 } |
| 2159 } | |
| 2160 | |
| 2161 static object * | |
| 86 | 2162 loop_subscript(v, w) |
| 69 | 2163 object *v, *w; |
| 2164 { | |
| 2165 sequence_methods *sq = v->ob_type->tp_as_sequence; | |
| 2166 int i, n; | |
| 2167 if (sq == NULL) { | |
| 86 | 2168 err_setstr(TypeError, "loop over non-sequence"); |
| 69 | 2169 return NULL; |
| 2170 } | |
| 2171 i = getintvalue(w); | |
| 2172 n = (*sq->sq_length)(v); | |
|
1096
ce718457b172
* classobject.c: in instance_lenth, test result of call_object
Guido van Rossum <guido@python.org>
parents:
1079
diff
changeset
|
2173 if (n < 0) |
|
ce718457b172
* classobject.c: in instance_lenth, test result of call_object
Guido van Rossum <guido@python.org>
parents:
1079
diff
changeset
|
2174 return NULL; /* Exception */ |
| 69 | 2175 if (i >= n) |
| 2176 return NULL; /* End of loop */ | |
| 86 | 2177 return (*sq->sq_item)(v, i); |
| 69 | 2178 } |
| 2179 | |
| 2180 static int | |
| 86 | 2181 slice_index(v, isize, pi) |
| 69 | 2182 object *v; |
| 2183 int isize; | |
| 2184 int *pi; | |
| 2185 { | |
| 2186 if (v != NULL) { | |
| 2187 if (!is_intobject(v)) { | |
| 86 | 2188 err_setstr(TypeError, "slice index must be int"); |
| 2189 return -1; | |
| 69 | 2190 } |
| 2191 *pi = getintvalue(v); | |
| 2192 if (*pi < 0) | |
| 2193 *pi += isize; | |
| 2194 } | |
| 86 | 2195 return 0; |
| 69 | 2196 } |
| 2197 | |
| 2198 static object * | |
| 86 | 2199 apply_slice(u, v, w) /* return u[v:w] */ |
| 69 | 2200 object *u, *v, *w; |
| 2201 { | |
| 2202 typeobject *tp = u->ob_type; | |
| 2203 int ilow, ihigh, isize; | |
| 2204 if (tp->tp_as_sequence == NULL) { | |
| 86 | 2205 err_setstr(TypeError, "only sequences can be sliced"); |
| 69 | 2206 return NULL; |
| 2207 } | |
| 2208 ilow = 0; | |
| 2209 isize = ihigh = (*tp->tp_as_sequence->sq_length)(u); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2210 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2211 return NULL; |
| 86 | 2212 if (slice_index(v, isize, &ilow) != 0) |
| 69 | 2213 return NULL; |
| 86 | 2214 if (slice_index(w, isize, &ihigh) != 0) |
| 69 | 2215 return NULL; |
| 86 | 2216 return (*tp->tp_as_sequence->sq_slice)(u, ilow, ihigh); |
| 69 | 2217 } |
| 86 | 2218 |
| 2219 static int | |
| 2220 assign_subscript(w, key, v) /* w[key] = v */ | |
| 69 | 2221 object *w; |
| 2222 object *key; | |
| 2223 object *v; | |
| 2224 { | |
| 2225 typeobject *tp = w->ob_type; | |
| 2226 sequence_methods *sq; | |
| 2227 mapping_methods *mp; | |
| 2228 int (*func)(); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2229 if ((mp = tp->tp_as_mapping) != NULL && |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2230 (func = mp->mp_ass_subscript) != NULL) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2231 return (*func)(w, key, v); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2232 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2233 else if ((sq = tp->tp_as_sequence) != NULL && |
| 69 | 2234 (func = sq->sq_ass_item) != NULL) { |
| 2235 if (!is_intobject(key)) { | |
| 86 | 2236 err_setstr(TypeError, |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2237 "sequence subscript must be integer (assign or del)"); |
| 86 | 2238 return -1; |
| 69 | 2239 } |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2240 else { |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2241 int i = getintvalue(key); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2242 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2243 int len = (*sq->sq_length)(w); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2244 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2245 return -1; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2246 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2247 } |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2248 return (*func)(w, i, v); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2249 } |
| 69 | 2250 } |
| 2251 else { | |
| 86 | 2252 err_setstr(TypeError, |
| 2253 "can't assign to this subscripted object"); | |
| 2254 return -1; | |
| 69 | 2255 } |
| 2256 } | |
| 2257 | |
| 86 | 2258 static int |
| 2259 assign_slice(u, v, w, x) /* u[v:w] = x */ | |
| 69 | 2260 object *u, *v, *w, *x; |
| 2261 { | |
| 86 | 2262 sequence_methods *sq = u->ob_type->tp_as_sequence; |
| 69 | 2263 int ilow, ihigh, isize; |
| 86 | 2264 if (sq == NULL) { |
| 2265 err_setstr(TypeError, "assign to slice of non-sequence"); | |
| 2266 return -1; | |
| 2267 } | |
| 2268 if (sq == NULL || sq->sq_ass_slice == NULL) { | |
| 2269 err_setstr(TypeError, "unassignable slice"); | |
| 2270 return -1; | |
| 69 | 2271 } |
| 2272 ilow = 0; | |
| 86 | 2273 isize = ihigh = (*sq->sq_length)(u); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2274 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2275 return -1; |
| 86 | 2276 if (slice_index(v, isize, &ilow) != 0) |
| 2277 return -1; | |
| 2278 if (slice_index(w, isize, &ihigh) != 0) | |
| 2279 return -1; | |
| 2280 return (*sq->sq_ass_slice)(u, ilow, ihigh, x); | |
| 69 | 2281 } |
| 2282 | |
| 2283 static int | |
| 2284 cmp_exception(err, v) | |
| 2285 object *err, *v; | |
| 2286 { | |
| 2287 if (is_tupleobject(v)) { | |
| 2288 int i, n; | |
| 2289 n = gettuplesize(v); | |
| 2290 for (i = 0; i < n; i++) { | |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
2291 /* Test recursively */ |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
2292 if (cmp_exception(err, gettupleitem(v, i))) |
| 69 | 2293 return 1; |
| 2294 } | |
| 2295 return 0; | |
| 2296 } | |
| 2297 return err == v; | |
| 2298 } | |
| 2299 | |
| 86 | 2300 static int |
| 2301 cmp_member(v, w) | |
| 2302 object *v, *w; | |
| 2303 { | |
| 2304 int i, n, cmp; | |
| 2305 object *x; | |
| 2306 sequence_methods *sq; | |
| 2307 /* Special case for char in string */ | |
| 2308 if (is_stringobject(w)) { | |
| 2309 register char *s, *end; | |
| 2310 register char c; | |
| 2311 if (!is_stringobject(v) || getstringsize(v) != 1) { | |
| 2312 err_setstr(TypeError, | |
| 2313 "string member test needs char left operand"); | |
| 2314 return -1; | |
| 2315 } | |
| 2316 c = getstringvalue(v)[0]; | |
| 2317 s = getstringvalue(w); | |
| 2318 end = s + getstringsize(w); | |
| 2319 while (s < end) { | |
| 2320 if (c == *s++) | |
| 2321 return 1; | |
| 2322 } | |
| 2323 return 0; | |
| 2324 } | |
| 2325 sq = w->ob_type->tp_as_sequence; | |
| 2326 if (sq == NULL) { | |
| 2327 err_setstr(TypeError, | |
| 2328 "'in' or 'not in' needs sequence right argument"); | |
| 2329 return -1; | |
| 2330 } | |
| 2331 n = (*sq->sq_length)(w); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2332 if (n < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2333 return -1; |
| 86 | 2334 for (i = 0; i < n; i++) { |
| 2335 x = (*sq->sq_item)(w, i); | |
| 2336 cmp = cmpobject(v, x); | |
| 2337 XDECREF(x); | |
| 2338 if (cmp == 0) | |
| 2339 return 1; | |
| 2340 } | |
| 2341 return 0; | |
| 2342 } | |
| 2343 | |
| 69 | 2344 static object * |
| 86 | 2345 cmp_outcome(op, v, w) |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
2346 int op; |
| 69 | 2347 register object *v; |
| 2348 register object *w; | |
| 2349 { | |
| 2350 register int cmp; | |
| 2351 register int res = 0; | |
| 2352 switch (op) { | |
| 86 | 2353 case IS: |
| 2354 case IS_NOT: | |
| 2355 res = (v == w); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2356 if (op == (int) IS_NOT) |
| 86 | 2357 res = !res; |
| 2358 break; | |
| 69 | 2359 case IN: |
| 2360 case NOT_IN: | |
| 86 | 2361 res = cmp_member(v, w); |
| 2362 if (res < 0) | |
| 2363 return NULL; | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2364 if (op == (int) NOT_IN) |
| 86 | 2365 res = !res; |
| 69 | 2366 break; |
| 2367 case EXC_MATCH: | |
| 86 | 2368 res = cmp_exception(v, w); |
| 69 | 2369 break; |
| 2370 default: | |
| 86 | 2371 cmp = cmpobject(v, w); |
| 2372 switch (op) { | |
| 2373 case LT: res = cmp < 0; break; | |
| 2374 case LE: res = cmp <= 0; break; | |
| 2375 case EQ: res = cmp == 0; break; | |
| 2376 case NE: res = cmp != 0; break; | |
| 2377 case GT: res = cmp > 0; break; | |
| 2378 case GE: res = cmp >= 0; break; | |
| 2379 /* XXX no default? (res is initialized to 0 though) */ | |
| 2380 } | |
| 69 | 2381 } |
| 2382 v = res ? True : False; | |
| 2383 INCREF(v); | |
| 2384 return v; | |
| 2385 } | |
| 2386 | |
| 86 | 2387 static int |
| 2388 import_from(locals, v, name) | |
| 2389 object *locals; | |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2390 object *v; |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2391 object *name; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2392 { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2393 object *w, *x; |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2394 w = getmoduledict(v); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2395 if (getstringvalue(name)[0] == '*') { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2396 int pos, err; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2397 object *name, *value; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2398 pos = 0; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2399 while (mappinggetnext(w, &pos, &name, &value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2400 if (!is_stringobject(name) || |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2401 getstringvalue(name)[0] == '_') |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2402 continue; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2403 if (is_accessobject(value)) { |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2404 value = getaccessvalue(value, (object *)NULL); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2405 if (value == NULL) { |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2406 err_clear(); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2407 continue; |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2408 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2409 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2410 else |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2411 INCREF(value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2412 err = dict2insert(locals, name, value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2413 DECREF(value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2414 if (err != 0) |
| 86 | 2415 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2416 } |
| 86 | 2417 return 0; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2418 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2419 else { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2420 x = dict2lookup(w, name); |
| 86 | 2421 if (x == NULL) { |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2422 char buf[250]; |
|
661
7e5f4d9aee77
Limit length of name passed to sprintf.
Guido van Rossum <guido@python.org>
parents:
607
diff
changeset
|
2423 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
|
2424 getstringvalue(name)); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2425 err_setstr(ImportError, buf); |
| 86 | 2426 return -1; |
| 2427 } | |
| 2428 else | |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2429 return dict2insert(locals, name, x); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2430 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2431 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2432 |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2433 static object * |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2434 build_class(methods, bases, name) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2435 object *methods; /* dictionary */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2436 object *bases; /* tuple containing classes */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2437 object *name; /* string */ |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2438 { |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2439 int i; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2440 if (!is_tupleobject(bases)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2441 err_setstr(SystemError, "build_class with non-tuple bases"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2442 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2443 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2444 if (!is_dictobject(methods)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2445 err_setstr(SystemError, "build_class with non-dictionary"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2446 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2447 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2448 if (!is_stringobject(name)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2449 err_setstr(SystemError, "build_class witn non-string name"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2450 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2451 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2452 for (i = gettuplesize(bases); --i >= 0; ) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2453 object *base = gettupleitem(bases, i); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2454 if (!is_classobject(base)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2455 err_setstr(TypeError, |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2456 "base is not a class object"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2457 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2458 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2459 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2460 return newclassobject(bases, methods, name); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2461 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2462 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2463 static int |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2464 access_statement(name, vmode, f) |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2465 object *name; |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2466 object *vmode; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2467 frameobject *f; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2468 { |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2469 int mode = getintvalue(vmode); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2470 object *value, *ac; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2471 typeobject *type; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2472 int fastind, ret; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2473 fastind = -1; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2474 if (f->f_localmap == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2475 value = dict2lookup(f->f_locals, name); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2476 else { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2477 value = dict2lookup(f->f_localmap, name); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2478 if (value == NULL || !is_intobject(value)) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2479 value = NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2480 else { |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2481 fastind = getintvalue(value); |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2482 if (0 <= fastind && |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2483 fastind < getlistsize(f->f_fastlocals)) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2484 value = getlistitem(f->f_fastlocals, fastind); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2485 else { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2486 value = NULL; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2487 fastind = -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2488 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2489 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2490 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2491 if (value && is_accessobject(value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2492 err_setstr(AccessError, "can't override access"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2493 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2494 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2495 err_clear(); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2496 if (value != NULL && value != None) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2497 type = value->ob_type; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2498 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2499 type = NULL; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2500 ac = newaccessobject(value, f->f_locals, type, mode); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2501 if (ac == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2502 return -1; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2503 if (fastind >= 0) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2504 ret = setlistitem(f->f_fastlocals, fastind, ac); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2505 else { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2506 ret = dict2insert(f->f_locals, name, ac); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2507 DECREF(ac); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2508 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2509 return ret; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2510 } |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2511 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2512 static int |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2513 exec_statement(prog, globals, locals) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2514 object *prog; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2515 object *globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2516 object *locals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2517 { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2518 char *s; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2519 int n; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2520 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2521 if (is_tupleobject(prog) && globals == None && locals == None && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2522 ((n = gettuplesize(prog)) == 2 || n == 3)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2523 /* Backward compatibility hack */ |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2524 globals = gettupleitem(prog, 1); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2525 if (n == 3) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2526 locals = gettupleitem(prog, 2); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2527 prog = gettupleitem(prog, 0); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2528 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2529 if (globals == None) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2530 globals = getglobals(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2531 if (locals == None) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2532 locals = getlocals(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2533 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2534 else if (locals == None) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2535 locals = globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2536 if (!is_stringobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2537 !is_codeobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2538 !is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2539 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2540 "exec 1st arg must be string, code or file object"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2541 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2542 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2543 if (!is_dictobject(globals) || !is_dictobject(locals)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2544 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2545 "exec 2nd/3rd args must be dict or None"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2546 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2547 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2548 if (is_codeobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2549 if (eval_code((codeobject *) prog, globals, locals, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2550 (object *)NULL, (object *)NULL) == NULL) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2551 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2552 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2553 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2554 if (is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2555 FILE *fp = getfilefile(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2556 char *name = getstringvalue(getfilename(prog)); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2557 if (run_file(fp, name, file_input, globals, locals) == NULL) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2558 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2559 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2560 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2561 s = getstringvalue(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2562 if (strlen(s) != getstringsize(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2563 err_setstr(ValueError, "embedded '\\0' in exec string"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2564 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2565 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2566 if (run_string(s, file_input, globals, locals) == NULL) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2567 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2568 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2569 } |
