Mercurial > cpython-lru_cache-weakref
annotate Python/ceval.c @ 3324:36920bbd81a8 legacy-trunk
changes for complex and power (**) operator
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 12 Jan 1996 01:13:16 +0000 |
| parents | 2bddfb3cfcf1 |
| children | dafc8a10b186 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
3 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 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
27 /* XXX TO DO: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
28 XXX how to pass arguments to call_trace? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
29 XXX access stuff can probably dereference NULL locals? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
30 XXX need to extend apply() to be able to pass keyword args |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
31 XXX need to be able to call built-in functions with keyword args |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
32 XXX speed up searching for keywords by using a dictionary |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
33 XXX unknown keyword shouldn't raise KeyError? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
34 XXX document it! |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
35 */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
36 |
| 86 | 37 #include "allobjects.h" |
| 38 | |
| 69 | 39 #include "import.h" |
| 40 #include "sysmodule.h" | |
|
2128
92da8901517e
use getbuiltins() everywhere, it defaults to getbuiltidict()
Guido van Rossum <guido@python.org>
parents:
2098
diff
changeset
|
41 #include "bltinmodule.h" |
| 69 | 42 #include "compile.h" |
| 86 | 43 #include "frameobject.h" |
| 926 | 44 #include "eval.h" |
| 86 | 45 #include "ceval.h" |
| 69 | 46 #include "opcode.h" |
| 86 | 47 #include "traceback.h" |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
48 #include "graminit.h" |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
49 #include "pythonrun.h" |
| 69 | 50 |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
51 #include <ctype.h> |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
52 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
53 extern int suppress_print; /* Declared in pythonrun.c, set in pythonmain.c */ |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
54 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
55 /* Turn this on if your compiler chokes on the big switch: */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
56 /* #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
|
57 |
|
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
|
58 /* 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
|
59 /* (This can be on even if NDEBUG is defined) */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
60 /* #define DEBUG 1 */ |
|
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
|
61 |
|
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
|
62 #if defined(DEBUG) || !defined(NDEBUG) |
| 567 | 63 /* For debugging the interpreter: */ |
| 64 #define LLTRACE 1 /* Low-level trace feature */ | |
| 65 #define CHECKEXC 1 /* Double-check exception checking */ | |
| 69 | 66 #endif |
| 67 | |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
68 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
69 /* Forward declarations */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
70 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
71 static object *eval_code2 PROTO((codeobject *, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
72 object *, object *, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
73 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
74 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
75 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
76 object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
77 #ifdef LLTRACE |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
78 static int prtrace PROTO((object *, char *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
79 #endif |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
80 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
|
81 static int call_trace |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
82 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
|
83 static object *add PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
84 static object *sub PROTO((object *, object *)); |
|
3324
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
85 static object *pow PROTO((object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
86 static object *mul PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
87 static object *divide PROTO((object *, object *)); |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
88 static object *mod PROTO((object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
89 static object *neg PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
90 static object *pos PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
91 static object *not PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
92 static object *invert PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
93 static object *lshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
94 static object *rshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
95 static object *and PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
96 static object *xor PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
97 static object *or PROTO((object *, object *)); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
98 static object *call_builtin PROTO((object *, object *, object *)); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
99 static object *call_function PROTO((object *, object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 static int import_from PROTO((object *, object *, object *)); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
110 static object *build_class PROTO((object *, object *, object *)); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
111 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
|
112 static int exec_statement PROTO((object *, object *, object *)); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
113 static object *find_from_args PROTO((frameobject *, int)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
114 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
115 |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
116 /* 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
|
117 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
118 static frameobject *current_frame; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
119 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
120 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
121 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
122 #include <errno.h> |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
123 #include "thread.h" |
| 926 | 124 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
125 static type_lock interpreter_lock = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
126 static long main_thread = 0; |
|
923
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 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
129 init_save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
130 { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
131 if (interpreter_lock) |
| 1179 | 132 return; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
133 interpreter_lock = allocate_lock(); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
134 acquire_lock(interpreter_lock, 1); |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
135 main_thread = get_thread_ident(); |
| 926 | 136 } |
| 137 | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
138 #endif |
| 926 | 139 |
| 140 /* Functions save_thread and restore_thread are always defined so | |
| 141 dynamically loaded modules needn't be compiled separately for use | |
| 142 with and without threads: */ | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
143 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
144 object * |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
145 save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
146 { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
147 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
148 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
|
149 object *res; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
150 res = (object *)current_frame; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
151 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
152 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
153 return res; |
|
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 #endif |
|
1271
2919b448e385
* Microscopic corrections to make things compile on the Cray APP.
Guido van Rossum <guido@python.org>
parents:
1263
diff
changeset
|
156 return NULL; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
157 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
158 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
159 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
160 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
|
161 object *x; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
162 { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
163 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
164 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
165 int err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
166 err = errno; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
167 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
168 errno = err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
169 current_frame = (frameobject *)x; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
170 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
171 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
172 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
173 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
174 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
175 /* Mechanism whereby asynchronously executing callbacks (e.g. UNIX |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
176 signal handlers or Mac I/O completion routines) can schedule calls |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
177 to a function to be called synchronously. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
178 The synchronous function is called with one void* argument. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
179 It should return 0 for success or -1 for failure -- failure should |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
180 be accompanied by an exception. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
181 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
182 If registry succeeds, the registry function returns 0; if it fails |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
183 (e.g. due to too many pending calls) it returns -1 (without setting |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
184 an exception condition). |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
185 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
186 Note that because registry may occur from within signal handlers, |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
187 or other asynchronous events, calling malloc() is unsafe! |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
188 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
189 #ifdef WITH_THREAD |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
190 Any thread can schedule pending calls, but only the main thread |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
191 will execute them. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
192 #endif |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
193 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
194 XXX WARNING! ASYNCHRONOUSLY EXECUTING CODE! |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
195 There are two possible race conditions: |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
196 (1) nested asynchronous registry calls; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
197 (2) registry calls made while pending calls are being processed. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
198 While (1) is very unlikely, (2) is a real possibility. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
199 The current code is safe against (2), but not against (1). |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
200 The safety against (2) is derived from the fact that only one |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
201 thread (the main thread) ever takes things out of the queue. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
202 */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
203 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
204 #define NPENDINGCALLS 32 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
205 static struct { |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
206 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
207 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
208 } pendingcalls[NPENDINGCALLS]; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
209 static volatile int pendingfirst = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
210 static volatile int pendinglast = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
211 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
212 int |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
213 Py_AddPendingCall(func, arg) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
214 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
215 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
216 { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
217 static int busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
218 int i, j; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
219 /* XXX Begin critical section */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
220 /* XXX If you want this to be safe against nested |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
221 XXX asynchronous calls, you'll have to work harder! */ |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
222 if (busy) |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
223 return -1; |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
224 busy = 1; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
225 i = pendinglast; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
226 j = (i + 1) % NPENDINGCALLS; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
227 if (j == pendingfirst) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
228 return -1; /* Queue full */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
229 pendingcalls[i].func = func; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
230 pendingcalls[i].arg = arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
231 pendinglast = j; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
232 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
233 /* XXX End critical section */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
234 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
235 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
236 |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
237 int |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
238 Py_MakePendingCalls() |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
239 { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
240 static int busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
241 #ifdef WITH_THREAD |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
242 if (get_thread_ident() != main_thread) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
243 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
244 #endif |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
245 if (busy) |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
246 return 0; |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
247 busy = 1; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
248 for (;;) { |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
249 int i; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
250 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
251 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
252 i = pendingfirst; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
253 if (i == pendinglast) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
254 break; /* Queue empty */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
255 func = pendingcalls[i].func; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
256 arg = pendingcalls[i].arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
257 pendingfirst = (i + 1) % NPENDINGCALLS; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
258 if (func(arg) < 0) { |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
259 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
260 return -1; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
261 } |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
262 } |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
263 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
264 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
265 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
266 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
267 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
268 /* 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
|
269 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
270 enum why_code { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
271 WHY_NOT, /* No error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
272 WHY_EXCEPTION, /* Exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
273 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
|
274 WHY_RETURN, /* 'return' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
275 WHY_BREAK /* 'break' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
276 }; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
277 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
278 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
279 /* Backward compatible interface */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
280 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
281 object * |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
282 eval_code(co, globals, locals) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
283 codeobject *co; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
284 object *globals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
285 object *locals; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
286 { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
287 return eval_code2(co, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
288 globals, locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
289 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
290 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
291 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
292 (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
293 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
294 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
295 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
296 /* Interpreter main loop */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
297 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
298 static object * |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
299 eval_code2(co, globals, locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
300 args, argcount, kws, kwcount, defs, defcount, owner) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
301 codeobject *co; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
302 object *globals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
303 object *locals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
304 object **args; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
305 int argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
306 object **kws; /* length: 2*kwcount */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
307 int kwcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
308 object **defs; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
309 int defcount; |
|
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
|
310 object *owner; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
311 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
312 register unsigned char *next_instr; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
313 register int opcode; /* Current opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
314 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
|
315 register object **stack_pointer; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 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
|
320 register object *w; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
321 register object *u; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
322 register object *t; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
323 register frameobject *f; /* Current frame */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
324 register object **fastlocals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
325 object *retval; /* Return value */ |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
326 int defmode = 0; /* Default access mode for new variables */ |
| 567 | 327 #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
|
328 int lltrace; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
329 #endif |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
330 #if defined(DEBUG) || defined(LLTRACE) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
331 /* Make it easier to find out where we are with a debugger */ |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
332 char *filename = getstringvalue(co->co_filename); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
333 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
334 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
335 /* Code access macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
336 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
337 #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
|
338 #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
|
339 #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
|
340 #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
|
341 #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
|
342 #define NEXTOP() (*next_instr++) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
343 #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
|
344 #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
|
345 #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
|
346 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
347 /* Stack manipulation macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
348 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
349 #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
|
350 #define EMPTY() (STACK_LEVEL() == 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
351 #define TOP() (stack_pointer[-1]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
352 #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
|
353 #define BASIC_POP() (*--stack_pointer) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
354 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
355 #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
|
356 (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
|
357 |
| 567 | 358 #ifdef LLTRACE |
| 359 #define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) | |
| 360 #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
|
361 #else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
362 #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
|
363 #define POP() BASIC_POP() |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
364 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
365 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
366 /* Local variable macros */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
367 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
368 #define GETLOCAL(i) (fastlocals[i]) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
369 #define SETLOCAL(i, value) do { XDECREF(GETLOCAL(i)); \ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
370 GETLOCAL(i) = value; } while (0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
371 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
372 if (globals == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
373 err_setstr(SystemError, "eval_code2: NULL globals"); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
374 return NULL; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
375 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
376 |
|
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
|
377 #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
|
378 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
|
379 #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
|
380 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
381 f = newframeobject( |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
382 current_frame, /*back*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
383 co, /*code*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
384 globals, /*globals*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
385 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
|
386 owner, /*owner*/ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
387 50, /*nvalues*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
388 20); /*nblocks*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
389 if (f == NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
390 return NULL; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
391 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
392 current_frame = f; |
| 567 | 393 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
394 if (co->co_nlocals > 0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
395 fastlocals = ((listobject *)f->f_fastlocals)->ob_item; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
396 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
397 if (co->co_argcount > 0 || |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
398 co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
399 int i; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
400 int n = argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
401 object *kwdict = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
402 if (co->co_flags & CO_VARKEYWORDS) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
403 kwdict = newmappingobject(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
404 if (kwdict == NULL) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
405 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
406 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
407 if (argcount > co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
408 if (!(co->co_flags & CO_VARARGS)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
409 err_setstr(TypeError, "too many arguments"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
410 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
411 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
412 n = co->co_argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
413 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
414 for (i = 0; i < n; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
415 x = args[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
416 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
417 SETLOCAL(i, x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
418 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
419 if (co->co_flags & CO_VARARGS) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
420 u = newtupleobject(argcount - n); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
421 for (i = n; i < argcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
422 x = args[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
423 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
424 SETTUPLEITEM(u, i-n, x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
425 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
426 SETLOCAL(co->co_argcount, u); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
427 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
428 for (i = 0; i < kwcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
429 object *keyword = kws[2*i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
430 object *value = kws[2*i + 1]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
431 int j; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
432 /* XXX slow -- speed up using dictionary? */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
433 for (j = 0; j < co->co_argcount; j++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
434 object *nm = GETTUPLEITEM(co->co_varnames, j); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
435 if (cmpobject(keyword, nm) == 0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
436 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
437 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
438 if (j >= co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
439 if (kwdict == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
440 err_setval(KeyError/*XXX*/, keyword); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
441 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
442 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
443 mappinginsert(kwdict, keyword, value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
444 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
445 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
446 if (GETLOCAL(j) != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
447 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
448 "keyword parameter redefined"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
449 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
450 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
451 INCREF(value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
452 SETLOCAL(j, value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
453 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
454 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
455 if (argcount < co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
456 int m = co->co_argcount - defcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
457 for (i = argcount; i < m; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
458 if (GETLOCAL(i) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
459 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
460 "not enough arguments"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
461 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
462 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
463 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
464 if (n > m) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
465 i = n - m; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
466 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
467 i = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
468 for (; i < defcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
469 if (GETLOCAL(m+i) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
470 object *def = defs[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
471 INCREF(def); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
472 SETLOCAL(m+i, def); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
473 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
474 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
475 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
476 if (kwdict != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
477 i = co->co_argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
478 if (co->co_flags & CO_VARARGS) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
479 i++; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
480 SETLOCAL(i, kwdict); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
481 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
482 if (0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
483 fail: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
484 XDECREF(kwdict); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
485 goto fail2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
486 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
487 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
488 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
489 if (argcount > 0 || kwcount > 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
490 err_setstr(TypeError, "no arguments expected"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
491 fail2: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
492 current_frame = f->f_back; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
493 DECREF(f); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
494 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
495 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
496 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
497 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
498 if (sys_trace != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
499 /* sys_trace, if defined, is a function that will |
| 567 | 500 be called on *every* entry to a code block. |
| 501 Its return value, if not None, is a function that | |
| 502 will be called at the start of each executed line | |
| 503 of code. (Actually, the function must return | |
| 504 itself in order to continue tracing.) | |
| 505 The trace functions are called with three arguments: | |
| 506 a pointer to the current frame, a string indicating | |
| 507 why the function is called, and an argument which | |
| 508 depends on the situation. The global trace function | |
| 509 (sys.trace) is also called whenever an exception | |
| 510 is detected. */ | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
511 if (call_trace(&sys_trace, &f->f_trace, f, "call", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
512 None/*XXX how to compute arguments now?*/)) { |
| 567 | 513 /* Trace function raised an error */ |
| 514 current_frame = f->f_back; | |
| 515 DECREF(f); | |
| 516 return NULL; | |
| 517 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
518 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
519 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
520 if (sys_profile != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
521 /* 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
|
522 itself and isn't called for "line" events */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
523 if (call_trace(&sys_profile, (object**)0, f, "call", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
524 None/*XXX*/)) { |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
525 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
|
526 DECREF(f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
527 return NULL; |
| 567 | 528 } |
| 529 } | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
530 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
531 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
|
532 stack_pointer = f->f_valuestack; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
533 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
534 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
535 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
536 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
|
537 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
538 for (;;) { |
|
237
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
539 static int ticker; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
540 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
541 /* Do periodic things. |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
542 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
|
543 too much overhead (a function call per instruction). |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
544 So we do it only every Nth instruction. */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
545 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
546 if (pendingfirst != pendinglast) { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
547 if (Py_MakePendingCalls() < 0) { |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
548 why = WHY_EXCEPTION; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
549 goto on_error; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
550 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
551 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
552 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
553 if (--ticker < 0) { |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
554 ticker = sys_checkinterval; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
555 if (sigcheck()) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
556 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
557 goto on_error; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
558 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
559 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
560 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
561 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
562 /* Give another thread a chance */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
563 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
564 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
565 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
566 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
567 /* Other threads may run now */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
568 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
569 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
570 current_frame = f; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
571 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
572 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
573 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
574 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
575 /* Extract opcode and argument */ |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
576 |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
577 #ifdef DEBUG |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
578 f->f_lasti = INSTR_OFFSET(); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
579 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
580 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
581 opcode = NEXTOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
582 if (HAS_ARG(opcode)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
583 oparg = NEXTARG(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
584 |
| 567 | 585 #ifdef LLTRACE |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
586 /* Instruction tracing */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
587 |
| 567 | 588 if (lltrace) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
589 if (HAS_ARG(opcode)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
590 printf("%d: %d, %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
591 (int) (INSTR_OFFSET() - 3), |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
592 opcode, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
593 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
594 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
595 printf("%d: %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
596 (int) (INSTR_OFFSET() - 1), opcode); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
597 } |
|
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 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
600 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
601 if (!CHECK_STACK(3)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
602 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
603 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
604 } |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
605 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
606 /* Main switch on opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
607 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
608 switch (opcode) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
609 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
610 /* BEWARE! |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
615 /* 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
|
616 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
617 case POP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
618 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
619 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
620 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
621 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
622 case ROT_TWO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
623 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
624 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
625 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
626 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
627 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
628 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
629 case ROT_THREE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
630 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
631 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
632 x = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
633 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
634 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
635 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
636 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
637 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
638 case DUP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
639 v = TOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
640 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
641 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
642 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
643 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
644 case UNARY_POSITIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
645 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
646 x = pos(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
647 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
648 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
649 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
650 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
651 case UNARY_NEGATIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
652 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
653 x = neg(v); |
|
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 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
656 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
657 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
658 case UNARY_NOT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
659 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
660 x = not(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
661 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
662 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
663 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
664 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
665 case UNARY_CONVERT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
666 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
667 x = reprobject(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
668 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
669 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
670 break; |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
671 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
672 case UNARY_INVERT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
673 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
674 x = invert(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
675 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
676 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
677 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
678 |
|
3324
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
679 case BINARY_POWER: |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
680 w = POP(); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
681 v = POP(); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
682 x = pow(v, w); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
683 DECREF(v); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
684 DECREF(w); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
685 PUSH(x); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
686 break; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
687 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
688 case BINARY_MULTIPLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
689 w = POP(); |
|
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 x = mul(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
692 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
693 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
694 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
695 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
696 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
697 case BINARY_DIVIDE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
698 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
699 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
700 x = divide(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
701 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
702 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
703 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
704 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
705 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
706 case BINARY_MODULO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
707 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
708 v = POP(); |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
709 x = mod(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
710 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
711 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
712 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
713 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
714 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
715 case BINARY_ADD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
716 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
717 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
718 x = add(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
719 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
720 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
721 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
722 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
723 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
724 case BINARY_SUBTRACT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
725 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
726 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
727 x = sub(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
728 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
729 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
730 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
731 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
732 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
733 case BINARY_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
734 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
735 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
736 x = apply_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
737 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
738 DECREF(w); |
|
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 |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
742 case BINARY_LSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
743 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
744 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
745 x = lshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
746 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
747 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
748 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
749 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
750 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
751 case BINARY_RSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
752 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
753 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
754 x = rshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
755 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
756 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
757 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
758 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
759 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
760 case BINARY_AND: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
761 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
762 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
763 x = and(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
764 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
765 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
766 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
767 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
768 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
769 case BINARY_XOR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
770 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
771 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
772 x = xor(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
773 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
774 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
775 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
776 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
777 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
778 case BINARY_OR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
779 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
780 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
781 x = or(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
782 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
783 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
784 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
785 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
786 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
787 case SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
788 case SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
789 case SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
790 case SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
791 if ((opcode-SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
792 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
793 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
794 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
795 if ((opcode-SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
796 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
797 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
798 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
799 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
800 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
|
801 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
802 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
803 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
804 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
805 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
806 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
807 case STORE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
808 case STORE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
809 case STORE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
810 case STORE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
811 if ((opcode-STORE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
812 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
813 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
814 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
815 if ((opcode-STORE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
816 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
817 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
818 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
819 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
820 t = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
821 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
|
822 DECREF(t); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
823 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
824 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
825 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
826 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
827 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
828 case DELETE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
829 case DELETE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
830 case DELETE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
831 case DELETE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
832 if ((opcode-DELETE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
833 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
834 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
835 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
836 if ((opcode-DELETE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
837 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
838 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
839 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
840 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
841 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
|
842 /* del u[v:w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
843 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
844 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
845 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
846 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
847 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
848 case STORE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
849 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
850 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
851 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
852 /* v[w] = u */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
853 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
|
854 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
855 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
856 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
857 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
858 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
859 case DELETE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
860 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
861 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
862 /* del v[w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
863 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
|
864 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
865 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
866 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
867 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
868 case PRINT_EXPR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
869 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
870 /* Print value except if procedure result */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
871 /* Before printing, also assign to '_' */ |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
872 if (v != None && |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
873 (err = dictinsert(f->f_builtins, "_", v)) == 0 && |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
874 !suppress_print) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
875 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
|
876 x = sysget("stdout"); |
|
2151
5fd8524dd03a
different init for __builtins__
Guido van Rossum <guido@python.org>
parents:
2128
diff
changeset
|
877 err = writeobject(v, x, 0); |
|
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
|
878 softspace(x, 1); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
879 flushline(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
880 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
881 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
882 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
883 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
884 case PRINT_ITEM: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
885 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
|
886 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
|
887 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
|
888 writestring(" ", w); |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
889 err = writeobject(v, w, PRINT_RAW); |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
890 if (err == 0 && is_stringobject(v)) { |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
891 /* XXX move into writeobject() ? */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
892 char *s = getstringvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
893 int len = getstringsize(v); |
| 2310 | 894 if (len > 0 && |
| 895 isspace(Py_CHARMASK(s[len-1])) && | |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
896 s[len-1] != ' ') |
|
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
|
897 softspace(w, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
898 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
899 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
900 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
901 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 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
|
908 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
|
909 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
910 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
911 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
912 case BREAK_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
913 why = WHY_BREAK; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
914 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
915 |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
916 case RAISE_VARARGS: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
917 u = v = w = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
918 switch (oparg) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
919 case 3: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
920 u = POP(); /* traceback */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
921 if (u == None) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
922 DECREF(u); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
923 u = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
924 } |
|
3099
d249111d4ccc
spell TraceBack with capital B
Guido van Rossum <guido@python.org>
parents:
2894
diff
changeset
|
925 else if (!PyTraceBack_Check(u)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
926 err_setstr(TypeError, |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
927 "raise 3rd arg must be traceback or None"); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
928 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
929 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
930 /* Fallthrough */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
931 case 2: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
932 v = POP(); /* value */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
933 /* Fallthrough */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
934 case 1: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
935 w = POP(); /* exc */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
936 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
937 default: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
938 err_setstr(SystemError, |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
939 "bad RAISE_VARARGS oparg"); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
940 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
941 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
942 if (v == NULL) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
943 v = None; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
944 INCREF(v); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
945 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
946 /* A tuple is equivalent to its first element here */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
947 while (is_tupleobject(w) && gettuplesize(w) > 0) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
948 t = w; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
949 w = GETTUPLEITEM(w, 0); |
|
2201
8f1daffe799b
add missing INCREF in RAISE_EXCEPTION
Guido van Rossum <guido@python.org>
parents:
2151
diff
changeset
|
950 INCREF(w); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
951 DECREF(t); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
952 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
953 if (is_stringobject(w)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
954 ; |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
955 } else if (is_classobject(w)) { |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
956 if (!is_instanceobject(v) |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
957 || !issubclass((object*)((instanceobject*)v)->in_class, |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
958 w)) { |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
959 err_setstr(TypeError, |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
960 "a class exception must have a value that is an instance of the class"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
961 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
962 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
963 } else if (is_instanceobject(w)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
964 if (v != None) { |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
965 err_setstr(TypeError, |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
966 "an instance exception may not have a separate value"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
967 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
968 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
969 else { |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
970 DECREF(v); |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
971 v = w; |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
972 w = (object*) ((instanceobject*)w)->in_class; |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
973 INCREF(w); |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
974 } |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
975 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
976 else { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
977 err_setstr(TypeError, |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
978 "exceptions must be strings, classes, or instances"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
979 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
980 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
981 err_restore(w, v, u); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
982 if (u == NULL) |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
983 why = WHY_EXCEPTION; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
984 else |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
985 why = WHY_RERAISE; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
986 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
987 raise_error: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
988 XDECREF(v); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
989 XDECREF(w); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
990 XDECREF(u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
991 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
992 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
993 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
994 case LOAD_LOCALS: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
995 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
996 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
997 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
998 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
999 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1000 PUSH(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1001 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1002 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1003 case RETURN_VALUE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1004 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1005 why = WHY_RETURN; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1006 break; |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1007 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1008 case EXEC_STMT: |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1009 w = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1010 v = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1011 u = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1012 err = exec_statement(u, v, w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1013 DECREF(u); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1014 DECREF(v); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1015 DECREF(w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1016 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1017 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1018 case POP_BLOCK: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1019 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1020 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1021 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
|
1022 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1023 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1024 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1025 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1026 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1027 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1028 case END_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1029 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1030 if (is_intobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1031 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
|
1032 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1033 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1034 } |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
1035 else if (is_stringobject(v) || is_classobject(v)) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1036 w = POP(); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1037 u = POP(); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1038 err_restore(v, w, u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1039 why = WHY_RERAISE; |
|
2872
d3b07ba3e12d
fix bogus DECREF in finally clause
Guido van Rossum <guido@python.org>
parents:
2866
diff
changeset
|
1040 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1041 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1042 else if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1043 err_setstr(SystemError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1044 "'finally' pops bad exception"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1045 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1046 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1047 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1048 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1049 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1050 case BUILD_CLASS: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1051 u = POP(); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1052 v = POP(); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1053 w = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1054 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
|
1055 PUSH(x); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1056 DECREF(u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1057 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1058 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1059 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1060 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1061 case STORE_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1062 w = GETNAMEV(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1063 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1064 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1065 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1066 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1067 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1068 u = dict2lookup(x, w); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1069 if (u == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1070 if (defmode != 0) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1071 if (v != None) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1072 u = (object *)v->ob_type; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1073 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1074 u = NULL; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1075 x = newaccessobject(v, x, |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1076 (typeobject *)u, |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1077 defmode); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1078 DECREF(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1079 if (x == NULL) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1080 break; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1081 v = x; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1082 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1083 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1084 else if (is_accessobject(u)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1085 err = setaccessvalue(u, x, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1086 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1087 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1088 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1089 err = dict2insert(x, w, v); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1090 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1091 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1092 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1093 case DELETE_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1094 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1095 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1096 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1097 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1098 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1099 u = dict2lookup(x, w); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1100 if (u != NULL && is_accessobject(u)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1101 err = setaccessvalue(u, x, |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1102 (object *)NULL); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1103 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1104 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1105 if ((err = dict2remove(x, w)) != 0) |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1106 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1107 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1108 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1109 #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
|
1110 default: switch (opcode) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1111 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1112 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1113 case UNPACK_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1114 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1115 if (!is_tupleobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1116 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
|
1117 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1118 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1119 else if (gettuplesize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1120 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1121 "unpack tuple of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1122 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1123 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1124 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1125 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1126 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1127 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1128 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1129 for (; --oparg >= 0; ) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
1130 w = GETTUPLEITEM(v, oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1131 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1132 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1133 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1134 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1135 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1136 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1137 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1138 case UNPACK_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1139 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1140 if (!is_listobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1141 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
|
1142 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1143 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1144 else if (getlistsize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1145 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1146 "unpack list of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1147 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1148 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1149 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1150 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1151 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1152 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1153 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1154 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1155 w = getlistitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1156 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1157 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1158 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1159 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1160 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1161 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1162 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1163 case STORE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1164 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1165 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1166 u = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1167 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
|
1168 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1169 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1170 break; |
|
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 DELETE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1173 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1174 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1175 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
|
1176 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1177 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1178 |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1179 case STORE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1180 w = GETNAMEV(oparg); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1181 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1182 if (f->f_locals != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1183 u = dict2lookup(f->f_locals, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1184 if (u != NULL && is_accessobject(u)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1185 err = setaccessvalue(u, f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1186 v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1187 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1188 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1189 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1190 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1191 err = dict2insert(f->f_globals, w, v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1192 DECREF(v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1193 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1194 |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1195 case DELETE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1196 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1197 if (f->f_locals != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1198 u = dict2lookup(f->f_locals, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1199 if (u != NULL && is_accessobject(u)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1200 err = setaccessvalue(u, f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1201 (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1202 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1203 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1204 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1205 if ((err = dict2remove(f->f_globals, w)) != 0) |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1206 err_setval(NameError, w); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1207 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1208 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1209 case LOAD_CONST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1210 x = GETCONST(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1211 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1212 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1213 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1214 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1215 case LOAD_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1216 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1217 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1218 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1219 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1220 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1221 x = dict2lookup(x, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1222 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1223 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1224 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
|
1225 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1226 err_clear(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1227 x = dict2lookup(f->f_builtins, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1228 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1229 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1230 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1231 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1232 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1233 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1234 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
|
1235 x = getaccessvalue(x, f->f_globals /* XXX */); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1236 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1237 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1238 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1239 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1240 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1241 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1242 break; |
|
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 LOAD_GLOBAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1245 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1246 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
|
1247 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1248 err_clear(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1249 x = dict2lookup(f->f_builtins, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1250 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1251 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1252 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1253 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1254 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1255 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
|
1256 x = getaccessvalue(x, f->f_globals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1257 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1258 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1259 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1260 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1261 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1262 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1263 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1264 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1265 #if 0 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1266 case LOAD_LOCAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1267 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1268 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1269 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1270 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1271 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1272 x = dict2lookup(x, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1273 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1274 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1275 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1276 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1277 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
|
1278 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1279 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1280 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1281 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1282 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1283 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1284 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1285 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1286 #endif |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1287 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1288 case LOAD_FAST: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1289 x = GETLOCAL(oparg); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1290 if (x == NULL) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1291 err_setval(NameError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1292 gettupleitem(co->co_varnames, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1293 oparg)); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1294 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1295 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1296 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
|
1297 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1298 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1299 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1300 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1301 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1302 INCREF(x); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1303 PUSH(x); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1304 break; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1305 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1306 case STORE_FAST: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1307 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1308 w = GETLOCAL(oparg); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1309 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
|
1310 err = setaccessvalue(w, f->f_locals, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1311 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1312 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1313 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1314 SETLOCAL(oparg, v); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1315 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1316 |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1317 case DELETE_FAST: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1318 x = GETLOCAL(oparg); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1319 if (x == NULL) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1320 err_setval(NameError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1321 gettupleitem(co->co_varnames, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1322 oparg)); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1323 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1324 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1325 if (is_accessobject(x)) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1326 err = setaccessvalue(x, f->f_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
|
1327 (object *)NULL); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1328 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1329 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1330 SETLOCAL(oparg, NULL); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1331 break; |
|
173
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 case BUILD_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1334 x = newtupleobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1335 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1336 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1337 w = POP(); |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
1338 SETTUPLEITEM(x, oparg, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1339 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1340 PUSH(x); |
|
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 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1343 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1344 case BUILD_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1345 x = newlistobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1346 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1347 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1348 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1349 err = setlistitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1350 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1351 break; |
|
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 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1354 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1355 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1356 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1357 case BUILD_MAP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1358 x = newdictobject(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1359 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1360 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1361 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1362 case LOAD_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1363 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1364 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1365 x = getattro(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1366 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1367 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1368 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1369 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1370 case COMPARE_OP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1371 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1372 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
|
1373 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
|
1374 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1375 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1376 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1377 break; |
|
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 case IMPORT_NAME: |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1380 w = GETNAMEV(oparg); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1381 x = dictlookup(f->f_builtins, "__import__"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1382 if (x == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1383 err_setstr(ImportError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1384 "__import__ not found"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1385 break; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1386 } |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1387 if (is_methodobject(x)) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1388 u = None; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1389 INCREF(u); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1390 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1391 else { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1392 u = find_from_args(f, INSTR_OFFSET()); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1393 if (u == NULL) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1394 x = u; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1395 break; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1396 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1397 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1398 w = mkvalue("(OOOO)", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1399 w, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1400 f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1401 f->f_locals == NULL ? None : f->f_locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1402 u); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1403 DECREF(u); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1404 if (w == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1405 x = NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1406 break; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1407 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1408 x = call_object(x, w); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1409 DECREF(w); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1410 PUSH(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1411 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1412 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1413 case IMPORT_FROM: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1414 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1415 v = TOP(); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1416 fast_2_locals(f); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1417 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1418 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1419 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1420 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1421 err = import_from(x, v, w); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1422 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
|
1423 break; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1424 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1425 case ACCESS_MODE: |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1426 v = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1427 w = GETNAMEV(oparg); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1428 if (getstringvalue(w)[0] == '*') |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1429 defmode = getintvalue(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1430 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1431 err = access_statement(w, v, f); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1432 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1433 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1434 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1435 case JUMP_FORWARD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1436 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1437 break; |
|
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 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
|
1440 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1441 if (err > 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1442 err = 0; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1443 else if (err == 0) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1444 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1445 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1446 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1447 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
|
1448 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1449 if (err > 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1450 err = 0; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1451 JUMPBY(oparg); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1452 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1453 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1454 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1455 case JUMP_ABSOLUTE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1456 JUMPTO(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1457 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1458 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1459 case FOR_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1460 /* for v in s: ... |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1461 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
|
1462 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
|
1463 but if loop exhausted: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1464 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
|
1465 w = POP(); /* Loop index */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1466 v = POP(); /* Sequence object */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1467 u = loop_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1468 if (u != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1469 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1470 x = newintobject(getintvalue(w)+1); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1471 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1472 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1473 PUSH(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1474 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1475 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1476 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1477 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1478 /* 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
|
1479 but also an error: */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1480 if (err_occurred()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1481 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1482 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1483 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1484 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1485 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1486 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1487 case SETUP_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1488 case SETUP_EXCEPT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1489 case SETUP_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1490 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
|
1491 STACK_LEVEL()); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1492 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1493 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1494 case SET_LINENO: |
| 567 | 1495 #ifdef LLTRACE |
| 1496 if (lltrace) | |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1497 printf("--- %s:%d \n", filename, oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1498 #endif |
| 567 | 1499 f->f_lineno = oparg; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1500 if (f->f_trace != NULL) { |
| 567 | 1501 /* Trace each line of code reached */ |
| 1502 f->f_lasti = INSTR_OFFSET(); | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1503 err = call_trace(&f->f_trace, &f->f_trace, |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1504 f, "line", None); |
| 567 | 1505 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1506 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1507 |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1508 case CALL_FUNCTION: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1509 { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1510 int na = oparg & 0xff; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1511 int nk = (oparg>>8) & 0xff; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1512 int n = na + 2*nk; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1513 object **pfunc = stack_pointer - n - 1; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1514 object *func = *pfunc; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1515 object *self = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1516 object *class = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1517 f->f_lasti = INSTR_OFFSET() - 3; /* For tracing */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1518 if (is_instancemethodobject(func)) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1519 self = instancemethodgetself(func); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1520 class = instancemethodgetclass(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1521 func = instancemethodgetfunc(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1522 INCREF(func); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1523 if (self != NULL) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1524 INCREF(self); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1525 DECREF(*pfunc); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1526 *pfunc = self; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1527 na++; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1528 n++; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1529 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1530 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1531 /* Unbound methods must be |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1532 called with an instance of |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1533 the class (or a derived |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1534 class) as first argument */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1535 if (na > 0 && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1536 (self = stack_pointer[-n]) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1537 != NULL && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1538 is_instanceobject(self) && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1539 issubclass( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1540 (object *) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1541 (((instanceobject *)self) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1542 ->in_class), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1543 class)) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1544 /* Handy-dandy */ ; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1545 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1546 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1547 "unbound method must be called with class instance 1st argument"); |
|
3294
2bddfb3cfcf1
don't return from main loop when error occurs
Guido van Rossum <guido@python.org>
parents:
3099
diff
changeset
|
1548 x = NULL; |
|
2bddfb3cfcf1
don't return from main loop when error occurs
Guido van Rossum <guido@python.org>
parents:
3099
diff
changeset
|
1549 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1550 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1551 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1552 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1553 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1554 INCREF(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1555 if (is_funcobject(func)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1556 object *co = getfunccode(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1557 object *globals = getfuncglobals(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1558 object *argdefs = PyFunction_GetDefaults(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1559 object **d; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1560 int nd; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1561 if (argdefs != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1562 d = &GETTUPLEITEM(argdefs, 0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1563 nd = ((tupleobject *)argdefs)->ob_size; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1564 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1565 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1566 d = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1567 nd = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1568 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1569 x = eval_code2( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1570 (codeobject *)co, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1571 globals, (object *)NULL, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1572 stack_pointer-n, na, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1573 stack_pointer-2*nk, nk, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1574 d, nd, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1575 class); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1576 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1577 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1578 object *args = newtupleobject(na); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1579 object *kwdict = NULL; |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1580 if (args == NULL) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1581 x = NULL; |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1582 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1583 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1584 if (nk > 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1585 kwdict = newdictobject(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1586 if (kwdict == NULL) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1587 x = NULL; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1588 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1589 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1590 err = 0; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1591 while (--nk >= 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1592 object *value = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1593 object *key = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1594 err = mappinginsert( |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1595 kwdict, key, value); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1596 if (err) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1597 DECREF(key); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1598 DECREF(value); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1599 break; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1600 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1601 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1602 if (err) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1603 DECREF(args); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1604 DECREF(kwdict); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1605 break; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1606 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1607 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1608 while (--na >= 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1609 w = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1610 SETTUPLEITEM(args, na, w); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1611 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1612 x = PyEval_CallObjectWithKeywords( |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1613 func, args, kwdict); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1614 DECREF(args); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1615 XDECREF(kwdict); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1616 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1617 DECREF(func); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1618 while (stack_pointer > pfunc) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1619 w = POP(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1620 DECREF(w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1621 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1622 PUSH(x); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1623 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1624 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1625 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1626 case MAKE_FUNCTION: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1627 v = POP(); /* code object */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1628 x = newfuncobject(v, f->f_globals); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1629 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1630 /* XXX Maybe this should be a separate opcode? */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1631 if (x != NULL && oparg > 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1632 v = newtupleobject(oparg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1633 if (v == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1634 DECREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1635 x = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1636 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1637 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1638 while (--oparg >= 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1639 w = POP(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1640 SETTUPLEITEM(v, oparg, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1641 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1642 err = PyFunction_SetDefaults(x, v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1643 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1644 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1645 PUSH(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1646 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1647 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1648 default: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1649 fprintf(stderr, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1650 "XXX lineno: %d, opcode: %d\n", |
| 567 | 1651 f->f_lineno, opcode); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1652 err_setstr(SystemError, "unknown opcode"); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1653 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1654 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1655 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1656 #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
|
1657 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1658 #endif |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1659 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1660 } /* switch */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1661 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1662 on_error: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1663 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1664 /* 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
|
1665 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1666 if (why == WHY_NOT) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1667 if (err == 0 && x != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1668 #ifdef CHECKEXC |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1669 if (err_occurred()) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1670 fprintf(stderr, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1671 "XXX undetected error\n"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1672 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1673 #endif |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1674 continue; /* Normal, fast path */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1675 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1676 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1677 x = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1678 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1679 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1680 |
|
814
f08d34499269
reverse sense of test for CHECKEXC
Guido van Rossum <guido@python.org>
parents:
802
diff
changeset
|
1681 #ifdef CHECKEXC |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1682 /* Double-check exception status */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1683 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1684 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
|
1685 if (!err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1686 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
|
1687 err_setstr(SystemError, "ghost error"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1688 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1689 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1690 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1691 else { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1692 if (err_occurred()) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1693 fprintf(stderr, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1694 "XXX undetected error (why=%d)\n", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1695 why); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1696 why = WHY_EXCEPTION; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1697 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1698 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1699 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1700 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1701 /* 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
|
1702 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1703 if (why == WHY_EXCEPTION) { |
| 567 | 1704 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
|
1705 if (HAS_ARG(opcode)) |
| 567 | 1706 f->f_lasti -= 2; |
| 1707 tb_here(f); | |
| 1708 | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1709 if (f->f_trace) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1710 call_exc_trace(&f->f_trace, &f->f_trace, f); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1711 if (sys_profile) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1712 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
|
1713 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1714 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1715 /* 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
|
1716 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1717 if (why == WHY_RERAISE) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1718 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1719 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1720 /* 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
|
1721 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1722 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
|
1723 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1724 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
|
1725 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1726 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1727 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1728 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
|
1729 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1730 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1731 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1732 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1733 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
|
1734 b->b_type == SETUP_EXCEPT && |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1735 why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1736 if (why == WHY_EXCEPTION) { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1737 object *exc, *val, *tb; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1738 err_fetch(&exc, &val, &tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1739 if (val == NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1740 val = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1741 INCREF(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1742 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1743 /* Make the raw exception data |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1744 available to the handler, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1745 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
|
1746 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
|
1747 this for 'finally'. */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1748 if (b->b_type == SETUP_EXCEPT) { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1749 sysset("exc_traceback", tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1750 sysset("exc_value", val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1751 sysset("exc_type", exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1752 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1753 PUSH(tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1754 PUSH(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1755 PUSH(exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1756 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1757 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1758 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1759 PUSH(retval); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1760 v = newintobject((long)why); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1761 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1762 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1763 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1764 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1765 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1766 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1767 } /* unwind stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1768 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1769 /* 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
|
1770 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1771 if (why != WHY_NOT) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1772 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1773 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1774 } /* main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1775 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1776 /* Pop remaining stack entries */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1777 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1778 while (!EMPTY()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1779 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1780 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1781 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1782 |
| 567 | 1783 if (why != WHY_RETURN) |
| 1784 retval = NULL; | |
| 1785 | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1786 if (f->f_trace) { |
| 567 | 1787 if (why == WHY_RETURN) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1788 if (call_trace(&f->f_trace, &f->f_trace, f, |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1789 "return", retval)) { |
| 567 | 1790 XDECREF(retval); |
| 1791 retval = NULL; | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1792 why = WHY_EXCEPTION; |
| 567 | 1793 } |
| 1794 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1795 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1796 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1797 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
|
1798 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
|
1799 f, "return", retval)) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1800 XDECREF(retval); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1801 retval = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1802 why = WHY_EXCEPTION; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1803 } |
| 567 | 1804 } |
| 1805 | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1806 /* Restore previous frame and release the current one */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1807 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1808 current_frame = f->f_back; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1809 DECREF(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1810 |
| 567 | 1811 return retval; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1812 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1813 |
| 567 | 1814 #ifdef LLTRACE |
| 86 | 1815 static int |
| 1816 prtrace(v, str) | |
| 1817 object *v; | |
| 1818 char *str; | |
| 69 | 1819 { |
| 86 | 1820 printf("%s ", str); |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1821 if (printobject(v, stdout, 0) != 0) |
|
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1822 err_clear(); /* Don't know what else to do */ |
| 86 | 1823 printf("\n"); |
| 69 | 1824 } |
| 86 | 1825 #endif |
| 69 | 1826 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1827 static void |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1828 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
|
1829 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
|
1830 frameobject *f; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1831 { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1832 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
|
1833 int err; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1834 err_fetch(&type, &value, &traceback); |
|
815
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1835 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
|
1836 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
|
1837 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
|
1838 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1839 arg = mkvalue("(OOO)", type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1840 if (arg == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1841 err_restore(type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1842 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1843 } |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1844 err = call_trace(p_trace, p_newtrace, f, "exception", arg); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1845 DECREF(arg); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1846 if (err == 0) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1847 err_restore(type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1848 else { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1849 XDECREF(type); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1850 XDECREF(value); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1851 XDECREF(traceback); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1852 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1853 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1854 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1855 static int |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1856 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
|
1857 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
|
1858 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
|
1859 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
|
1860 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
|
1861 may be same variable as p_newtrace */ |
| 567 | 1862 frameobject *f; |
| 1863 char *msg; | |
| 1864 object *arg; | |
| 1865 { | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1866 object *args, *what; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1867 object *res = NULL; |
| 567 | 1868 static int tracing = 0; |
| 1869 | |
| 1870 if (tracing) { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1871 /* 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
|
1872 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1873 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1874 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1875 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1876 return 0; |
| 567 | 1877 } |
| 1878 | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1879 args = newtupleobject(3); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1880 if (args == NULL) |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1881 goto cleanup; |
| 567 | 1882 what = newstringobject(msg); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1883 if (what == NULL) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1884 goto cleanup; |
| 567 | 1885 INCREF(f); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1886 SETTUPLEITEM(args, 0, (object *)f); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1887 SETTUPLEITEM(args, 1, what); |
| 567 | 1888 if (arg == NULL) |
| 1889 arg = None; | |
| 1890 INCREF(arg); | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1891 SETTUPLEITEM(args, 2, arg); |
| 567 | 1892 tracing++; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1893 fast_2_locals(f); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1894 res = call_object(*p_trace, args); /* May clear *p_trace! */ |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1895 locals_2_fast(f, 1); |
| 567 | 1896 tracing--; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1897 cleanup: |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1898 XDECREF(args); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1899 if (res == NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1900 /* 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
|
1901 tb_here(f); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1902 XDECREF(*p_trace); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1903 *p_trace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1904 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1905 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1906 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1907 } |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1908 return -1; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1909 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1910 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1911 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1912 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1913 if (res == None) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1914 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1915 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1916 INCREF(res); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1917 *p_newtrace = res; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1918 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1919 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1920 DECREF(res); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1921 return 0; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1922 } |
| 567 | 1923 } |
| 1924 | |
| 86 | 1925 object * |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1926 getbuiltins() |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1927 { |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1928 if (current_frame == NULL) |
|
2151
5fd8524dd03a
different init for __builtins__
Guido van Rossum <guido@python.org>
parents:
2128
diff
changeset
|
1929 return getbuiltinmod(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1930 else |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1931 return current_frame->f_builtins; |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1932 } |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1933 |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1934 object * |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1935 getlocals() |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1936 { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1937 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
|
1938 return NULL; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1939 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
|
1940 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
|
1941 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1942 |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1943 object * |
| 86 | 1944 getglobals() |
| 69 | 1945 { |
| 86 | 1946 if (current_frame == NULL) |
| 1947 return NULL; | |
| 1948 else | |
| 1949 return current_frame->f_globals; | |
| 69 | 1950 } |
| 1951 | |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1952 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
|
1953 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
|
1954 { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1955 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
|
1956 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
|
1957 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
|
1958 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
|
1959 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1960 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1961 object * |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1962 getframe() |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1963 { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1964 return (object *)current_frame; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1965 } |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1966 |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1967 int |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1968 getrestricted() |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1969 { |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1970 return current_frame == NULL ? 0 : current_frame->f_restricted; |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1971 } |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1972 |
| 86 | 1973 void |
| 69 | 1974 flushline() |
| 1975 { | |
|
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
|
1976 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
|
1977 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
|
1978 writestring("\n", f); |
| 69 | 1979 } |
| 1980 | |
| 86 | 1981 |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1982 #define BINOP(opname, ropname, thisfunc) \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1983 if (!is_instanceobject(v) && !is_instanceobject(w)) \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1984 ; \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1985 else \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1986 return instancebinop(v, w, opname, ropname, thisfunc) |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
1987 |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
1988 |
| 69 | 1989 static object * |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1990 or(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1991 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1992 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1993 BINOP("__or__", "__ror__", or); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1994 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1995 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1996 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1997 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1998 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1999 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
|
2000 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2001 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2002 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2003 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2004 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2005 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2006 err_setstr(TypeError, "bad operand type(s) for |"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2007 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2008 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2009 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2010 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2011 xor(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2012 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2013 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2014 BINOP("__xor__", "__rxor__", xor); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2015 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2016 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2017 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2018 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2019 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2020 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
|
2021 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2022 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2023 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2024 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2025 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2026 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2027 err_setstr(TypeError, "bad operand type(s) for ^"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2028 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2029 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2030 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2031 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2032 and(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2033 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2034 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2035 BINOP("__and__", "__rand__", and); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2036 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2037 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2038 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2039 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2040 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2041 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
|
2042 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2043 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2044 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2045 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2046 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2047 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2048 err_setstr(TypeError, "bad operand type(s) for &"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2049 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2050 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2051 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2052 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2053 lshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2054 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2055 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2056 BINOP("__lshift__", "__rlshift__", lshift); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2057 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2058 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2059 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2060 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2061 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2062 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
|
2063 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2064 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2065 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2066 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2067 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2068 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2069 err_setstr(TypeError, "bad operand type(s) for <<"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2070 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2071 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2072 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2073 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2074 rshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2075 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2076 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2077 BINOP("__rshift__", "__rrshift__", rshift); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2078 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2079 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2080 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2081 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2082 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2083 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
|
2084 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2085 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2086 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2087 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2088 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2089 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2090 err_setstr(TypeError, "bad operand type(s) for >>"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2091 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2092 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2093 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2094 static object * |
| 86 | 2095 add(v, w) |
| 69 | 2096 object *v, *w; |
| 2097 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2098 BINOP("__add__", "__radd__", add); |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2099 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
|
2100 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
|
2101 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
|
2102 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2103 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
|
2104 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2105 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
|
2106 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2107 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2108 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2109 } |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
2110 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
|
2111 return NULL; |
| 69 | 2112 } |
| 2113 | |
| 2114 static object * | |
| 86 | 2115 sub(v, w) |
| 69 | 2116 object *v, *w; |
| 2117 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2118 BINOP("__sub__", "__rsub__", sub); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2119 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
|
2120 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2121 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
|
2122 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2123 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
|
2124 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2125 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2126 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2127 } |
| 86 | 2128 err_setstr(TypeError, "bad operand type(s) for -"); |
| 69 | 2129 return NULL; |
| 2130 } | |
| 2131 | |
| 2132 static object * | |
| 86 | 2133 mul(v, w) |
| 69 | 2134 object *v, *w; |
| 2135 { | |
| 2136 typeobject *tp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2137 tp = v->ob_type; |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2138 BINOP("__mul__", "__rmul__", mul); |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2139 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
|
2140 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
|
2141 !is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2142 /* number*sequence -- swap v and w */ |
| 69 | 2143 object *tmp = v; |
| 2144 v = w; | |
| 2145 w = tmp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2146 tp = v->ob_type; |
| 69 | 2147 } |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2148 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
|
2149 object *x; |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2150 if (is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2151 /* 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
|
2152 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
|
2153 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
|
2154 number*number. */ |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2155 INCREF(v); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2156 INCREF(w); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2157 } |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2158 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
|
2159 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2160 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
|
2161 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2162 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2163 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2164 } |
| 69 | 2165 if (tp->tp_as_sequence != NULL) { |
| 2166 if (!is_intobject(w)) { | |
| 86 | 2167 err_setstr(TypeError, |
| 2168 "can't multiply sequence with non-int"); | |
| 69 | 2169 return NULL; |
| 2170 } | |
| 86 | 2171 return (*tp->tp_as_sequence->sq_repeat) |
| 2172 (v, (int)getintvalue(w)); | |
| 69 | 2173 } |
| 86 | 2174 err_setstr(TypeError, "bad operand type(s) for *"); |
| 69 | 2175 return NULL; |
| 2176 } | |
| 2177 | |
| 2178 static object * | |
|
88
16e8c5d16493
Change div() into divide(); div() is a Standard C function.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2179 divide(v, w) |
| 69 | 2180 object *v, *w; |
| 2181 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2182 BINOP("__div__", "__rdiv__", divide); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2183 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
|
2184 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2185 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
|
2186 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2187 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
|
2188 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2189 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2190 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2191 } |
| 86 | 2192 err_setstr(TypeError, "bad operand type(s) for /"); |
| 69 | 2193 return NULL; |
| 2194 } | |
| 2195 | |
| 2196 static object * | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2197 mod(v, w) |
| 86 | 2198 object *v, *w; |
| 69 | 2199 { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2200 if (is_stringobject(v)) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2201 return formatstring(v, w); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2202 } |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2203 BINOP("__mod__", "__rmod__", mod); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2204 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
|
2205 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2206 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
|
2207 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2208 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
|
2209 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2210 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2211 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2212 } |
| 86 | 2213 err_setstr(TypeError, "bad operand type(s) for %"); |
| 69 | 2214 return NULL; |
| 2215 } | |
| 2216 | |
| 2217 static object * | |
|
3324
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2218 pow(v, w) |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2219 object *v, *w; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2220 { |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2221 object *res; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2222 BINOP("__pow__", "__rpow__", pow); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2223 if (v->ob_type->tp_as_number == NULL || |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2224 w->ob_type->tp_as_number == NULL) { |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2225 err_setstr(TypeError, "pow() requires numeric arguments"); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2226 return NULL; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2227 } |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2228 if ( |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2229 #ifndef WITHOUT_COMPLEX |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2230 !is_complexobject(v) && |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2231 #endif |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2232 is_floatobject(w) && getfloatvalue(v) < 0.0) { |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2233 if (!err_occurred()) |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2234 err_setstr(ValueError, "negative number to float power"); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2235 return NULL; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2236 } |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2237 if (coerce(&v, &w) != 0) |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2238 return NULL; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2239 res = (*v->ob_type->tp_as_number->nb_power)(v, w, None); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2240 DECREF(v); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2241 DECREF(w); |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2242 return res; |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2243 } |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2244 |
|
36920bbd81a8
changes for complex and power (**) operator
Guido van Rossum <guido@python.org>
parents:
3294
diff
changeset
|
2245 static object * |
| 86 | 2246 neg(v) |
| 69 | 2247 object *v; |
| 2248 { | |
| 2249 if (v->ob_type->tp_as_number != NULL) | |
| 86 | 2250 return (*v->ob_type->tp_as_number->nb_negative)(v); |
| 2251 err_setstr(TypeError, "bad operand type(s) for unary -"); | |
| 2252 return NULL; | |
| 2253 } | |
| 2254 | |
| 2255 static object * | |
| 2256 pos(v) | |
| 2257 object *v; | |
| 2258 { | |
| 2259 if (v->ob_type->tp_as_number != NULL) | |
| 2260 return (*v->ob_type->tp_as_number->nb_positive)(v); | |
| 2261 err_setstr(TypeError, "bad operand type(s) for unary +"); | |
| 69 | 2262 return NULL; |
| 2263 } | |
| 2264 | |
| 2265 static object * | |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2266 invert(v) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2267 object *v; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2268 { |
|
671
10002e1bc526
Use correct prototype for invert().
Guido van Rossum <guido@python.org>
parents:
661
diff
changeset
|
2269 object * (*f) FPROTO((object *)); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2270 if (v->ob_type->tp_as_number != NULL && |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2271 (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
|
2272 return (*f)(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2273 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
|
2274 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2275 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2276 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2277 static object * |
| 86 | 2278 not(v) |
| 69 | 2279 object *v; |
| 2280 { | |
| 86 | 2281 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
|
2282 object *w; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2283 if (outcome < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2284 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2285 if (outcome == 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2286 w = True; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2287 else |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2288 w = False; |
| 86 | 2289 INCREF(w); |
| 2290 return w; | |
| 69 | 2291 } |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
2292 |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
2293 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2294 /* External interface to call any callable object. |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2295 The arg must be a tuple or NULL. */ |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2296 |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2297 object * |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2298 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
|
2299 object *func; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2300 object *arg; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2301 { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2302 return PyEval_CallObjectWithKeywords(func, arg, (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2303 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2304 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2305 object * |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2306 PyEval_CallObjectWithKeywords(func, arg, kw) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2307 object *func; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2308 object *arg; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2309 object *kw; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2310 { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2311 ternaryfunc call; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2312 object *result; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2313 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2314 if (arg == NULL) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2315 arg = newtupleobject(0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2316 else if (!is_tupleobject(arg)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2317 err_setstr(TypeError, "argument list must be a tuple"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2318 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2319 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2320 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2321 INCREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2322 |
|
2894
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2323 if (kw != NULL && !is_dictobject(kw)) { |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2324 err_setstr(TypeError, "keyword list must be a dictionary"); |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2325 return NULL; |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2326 } |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2327 |
|
2589
d5d27dad7fea
remove unused code for tp_call
Guido van Rossum <guido@python.org>
parents:
2503
diff
changeset
|
2328 if (call = func->ob_type->tp_call) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2329 result = (*call)(func, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2330 else if (is_instancemethodobject(func) || is_funcobject(func)) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2331 result = call_function(func, arg, kw); |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2332 else |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2333 result = call_builtin(func, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2334 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2335 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2336 |
|
2006
3aa9184cff8b
replace abort() calls by fatal()
Guido van Rossum <guido@python.org>
parents:
1914
diff
changeset
|
2337 if (result == NULL && !err_occurred()) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2338 err_setstr(SystemError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2339 "NULL result without error in call_object"); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2340 |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2341 return result; |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2342 } |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2343 |
| 69 | 2344 static object * |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2345 call_builtin(func, arg, kw) |
| 69 | 2346 object *func; |
| 86 | 2347 object *arg; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2348 object *kw; |
| 69 | 2349 { |
| 2350 if (is_methodobject(func)) { | |
| 2351 method meth = getmethod(func); | |
| 2352 object *self = getself(func); | |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2353 int flags = getflags(func); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2354 if (!(flags & METH_VARARGS)) { |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2355 int size = gettuplesize(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2356 if (size == 1) |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2357 arg = GETTUPLEITEM(arg, 0); |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2358 else if (size == 0) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2359 arg = NULL; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2360 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2361 if (flags & METH_KEYWORDS) |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2362 return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); |
|
2894
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2363 if (kw != NULL && getmappingsize(kw) != 0) { |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2364 err_setstr(TypeError, |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2365 "this function takes no keyword arguments"); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2366 return NULL; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2367 } |
| 86 | 2368 return (*meth)(self, arg); |
| 69 | 2369 } |
| 2370 if (is_classobject(func)) { | |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2371 return newinstanceobject(func, arg, kw); |
| 69 | 2372 } |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2373 if (is_instanceobject(func)) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2374 object *res, *call = getattr(func,"__call__"); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2375 if (call == NULL) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2376 err_clear(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2377 err_setstr(AttributeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2378 "no __call__ method defined"); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2379 return NULL; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2380 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2381 res = PyEval_CallObjectWithKeywords(call, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2382 DECREF(call); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2383 return res; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2384 } |
| 86 | 2385 err_setstr(TypeError, "call of non-function"); |
| 69 | 2386 return NULL; |
| 2387 } | |
| 2388 | |
| 2389 static object * | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2390 call_function(func, arg, kw) |
| 69 | 2391 object *func; |
| 86 | 2392 object *arg; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2393 object *kw; |
| 69 | 2394 { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2395 object *class = NULL; /* == owner */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2396 object *argdefs; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2397 object **d, **k; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2398 int nk, nd; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2399 object *result; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2400 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2401 if (kw != NULL && !is_dictobject(kw)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2402 err_badcall(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2403 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2404 } |
| 69 | 2405 |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2406 if (is_instancemethodobject(func)) { |
|
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2407 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
|
2408 class = instancemethodgetclass(func); |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2409 func = instancemethodgetfunc(func); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2410 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2411 /* 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
|
2412 the class (or a derived class) as first argument */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2413 if (gettuplesize(arg) >= 1) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2414 self = GETTUPLEITEM(arg, 0); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2415 if (self != NULL && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2416 is_instanceobject(self) && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2417 issubclass((object *) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2418 (((instanceobject *)self)->in_class), |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2419 class)) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2420 /* Handy-dandy */ ; |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2421 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2422 self = NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2423 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2424 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2425 err_setstr(TypeError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2426 "unbound method must be called with class instance 1st argument"); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2427 return NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2428 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2429 INCREF(arg); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2430 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2431 else { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2432 int argcount = gettuplesize(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2433 object *newarg = newtupleobject(argcount + 1); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2434 int i; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2435 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
|
2436 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
|
2437 INCREF(self); |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2438 SETTUPLEITEM(newarg, 0, self); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2439 for (i = 0; i < argcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2440 object *v = GETTUPLEITEM(arg, i); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2441 XINCREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2442 SETTUPLEITEM(newarg, i+1, v); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2443 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2444 arg = newarg; |
| 69 | 2445 } |
| 2446 } | |
| 2447 else { | |
| 2448 if (!is_funcobject(func)) { | |
| 86 | 2449 err_setstr(TypeError, "call of non-function"); |
| 69 | 2450 return NULL; |
| 2451 } | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2452 INCREF(arg); |
| 69 | 2453 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2454 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2455 argdefs = PyFunction_GetDefaults(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2456 if (argdefs != NULL && is_tupleobject(argdefs)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2457 d = &GETTUPLEITEM((tupleobject *)argdefs, 0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2458 nd = gettuplesize(argdefs); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2459 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2460 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2461 d = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2462 nd = 0; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2463 } |
| 69 | 2464 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2465 if (kw != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2466 int pos, i; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2467 nk = getmappingsize(kw); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2468 k = NEW(object *, 2*nk); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2469 if (k == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2470 err_nomem(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2471 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2472 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2473 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2474 pos = i = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2475 while (mappinggetnext(kw, &pos, &k[i], &k[i+1])) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2476 i += 2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2477 nk = i/2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2478 /* XXX This is broken if the caller deletes dict items! */ |
| 69 | 2479 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2480 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2481 k = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2482 nk = 0; |
| 69 | 2483 } |
| 2484 | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2485 result = eval_code2( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2486 (codeobject *)getfunccode(func), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2487 getfuncglobals(func), (object *)NULL, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2488 &GETTUPLEITEM(arg, 0), gettuplesize(arg), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2489 k, nk, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2490 d, nd, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2491 class); |
| 69 | 2492 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2493 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2494 XDEL(k); |
| 69 | 2495 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2496 return result; |
| 69 | 2497 } |
| 2498 | |
| 2499 static object * | |
| 86 | 2500 apply_subscript(v, w) |
| 69 | 2501 object *v, *w; |
| 2502 { | |
| 2503 typeobject *tp = v->ob_type; | |
| 2504 if (tp->tp_as_sequence == NULL && tp->tp_as_mapping == NULL) { | |
| 86 | 2505 err_setstr(TypeError, "unsubscriptable object"); |
| 69 | 2506 return NULL; |
| 2507 } | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2508 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
|
2509 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
|
2510 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2511 else { |
| 69 | 2512 int i; |
| 2513 if (!is_intobject(w)) { | |
| 86 | 2514 err_setstr(TypeError, "sequence subscript not int"); |
| 69 | 2515 return NULL; |
| 2516 } | |
| 2517 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
|
2518 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2519 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
|
2520 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2521 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2522 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2523 } |
| 86 | 2524 return (*tp->tp_as_sequence->sq_item)(v, i); |
| 69 | 2525 } |
| 2526 } | |
| 2527 | |
| 2528 static object * | |
| 86 | 2529 loop_subscript(v, w) |
| 69 | 2530 object *v, *w; |
| 2531 { | |
| 2532 sequence_methods *sq = v->ob_type->tp_as_sequence; | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2533 int i; |
| 69 | 2534 if (sq == NULL) { |
| 86 | 2535 err_setstr(TypeError, "loop over non-sequence"); |
| 69 | 2536 return NULL; |
| 2537 } | |
| 2538 i = getintvalue(w); | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2539 v = (*sq->sq_item)(v, i); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2540 if (v) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2541 return v; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2542 if (err_occurred() == IndexError) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2543 err_clear(); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2544 return NULL; |
| 69 | 2545 } |
| 2546 | |
| 2547 static int | |
| 86 | 2548 slice_index(v, isize, pi) |
| 69 | 2549 object *v; |
| 2550 int isize; | |
| 2551 int *pi; | |
| 2552 { | |
| 2553 if (v != NULL) { | |
| 2554 if (!is_intobject(v)) { | |
| 86 | 2555 err_setstr(TypeError, "slice index must be int"); |
| 2556 return -1; | |
| 69 | 2557 } |
| 2558 *pi = getintvalue(v); | |
| 2559 if (*pi < 0) | |
| 2560 *pi += isize; | |
| 2561 } | |
| 86 | 2562 return 0; |
| 69 | 2563 } |
| 2564 | |
| 2565 static object * | |
| 86 | 2566 apply_slice(u, v, w) /* return u[v:w] */ |
| 69 | 2567 object *u, *v, *w; |
| 2568 { | |
| 2569 typeobject *tp = u->ob_type; | |
| 2570 int ilow, ihigh, isize; | |
| 2571 if (tp->tp_as_sequence == NULL) { | |
| 86 | 2572 err_setstr(TypeError, "only sequences can be sliced"); |
| 69 | 2573 return NULL; |
| 2574 } | |
| 2575 ilow = 0; | |
| 2576 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
|
2577 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2578 return NULL; |
| 86 | 2579 if (slice_index(v, isize, &ilow) != 0) |
| 69 | 2580 return NULL; |
| 86 | 2581 if (slice_index(w, isize, &ihigh) != 0) |
| 69 | 2582 return NULL; |
| 86 | 2583 return (*tp->tp_as_sequence->sq_slice)(u, ilow, ihigh); |
| 69 | 2584 } |
| 86 | 2585 |
| 2586 static int | |
| 2587 assign_subscript(w, key, v) /* w[key] = v */ | |
| 69 | 2588 object *w; |
| 2589 object *key; | |
| 2590 object *v; | |
| 2591 { | |
| 2592 typeobject *tp = w->ob_type; | |
| 2593 sequence_methods *sq; | |
| 2594 mapping_methods *mp; | |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2595 int (*func1)(); |
|
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2596 int (*func2)(); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2597 if ((mp = tp->tp_as_mapping) != NULL && |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2598 (func1 = mp->mp_ass_subscript) != NULL) { |
|
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2599 return (*func1)(w, key, v); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2600 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2601 else if ((sq = tp->tp_as_sequence) != NULL && |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2602 (func2 = sq->sq_ass_item) != NULL) { |
| 69 | 2603 if (!is_intobject(key)) { |
| 86 | 2604 err_setstr(TypeError, |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2605 "sequence subscript must be integer (assign or del)"); |
| 86 | 2606 return -1; |
| 69 | 2607 } |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2608 else { |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2609 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
|
2610 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2611 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
|
2612 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2613 return -1; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2614 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2615 } |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2616 return (*func2)(w, i, v); |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2617 } |
| 69 | 2618 } |
| 2619 else { | |
| 86 | 2620 err_setstr(TypeError, |
| 2621 "can't assign to this subscripted object"); | |
| 2622 return -1; | |
| 69 | 2623 } |
| 2624 } | |
| 2625 | |
| 86 | 2626 static int |
| 2627 assign_slice(u, v, w, x) /* u[v:w] = x */ | |
| 69 | 2628 object *u, *v, *w, *x; |
| 2629 { | |
| 86 | 2630 sequence_methods *sq = u->ob_type->tp_as_sequence; |
| 69 | 2631 int ilow, ihigh, isize; |
| 86 | 2632 if (sq == NULL) { |
| 2633 err_setstr(TypeError, "assign to slice of non-sequence"); | |
| 2634 return -1; | |
| 2635 } | |
| 2636 if (sq == NULL || sq->sq_ass_slice == NULL) { | |
| 2637 err_setstr(TypeError, "unassignable slice"); | |
| 2638 return -1; | |
| 69 | 2639 } |
| 2640 ilow = 0; | |
| 86 | 2641 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
|
2642 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2643 return -1; |
| 86 | 2644 if (slice_index(v, isize, &ilow) != 0) |
| 2645 return -1; | |
| 2646 if (slice_index(w, isize, &ihigh) != 0) | |
| 2647 return -1; | |
| 2648 return (*sq->sq_ass_slice)(u, ilow, ihigh, x); | |
| 69 | 2649 } |
| 2650 | |
| 2651 static int | |
| 2652 cmp_exception(err, v) | |
| 2653 object *err, *v; | |
| 2654 { | |
| 2655 if (is_tupleobject(v)) { | |
| 2656 int i, n; | |
| 2657 n = gettuplesize(v); | |
| 2658 for (i = 0; i < n; i++) { | |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
2659 /* Test recursively */ |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2660 if (cmp_exception(err, GETTUPLEITEM(v, i))) |
| 69 | 2661 return 1; |
| 2662 } | |
| 2663 return 0; | |
| 2664 } | |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
2665 if (is_classobject(v) && is_classobject(err)) |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
2666 return issubclass(err, v); |
| 69 | 2667 return err == v; |
| 2668 } | |
| 2669 | |
| 86 | 2670 static int |
| 2671 cmp_member(v, w) | |
| 2672 object *v, *w; | |
| 2673 { | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2674 int i, cmp; |
| 86 | 2675 object *x; |
| 2676 sequence_methods *sq; | |
| 2677 /* Special case for char in string */ | |
| 2678 if (is_stringobject(w)) { | |
| 2679 register char *s, *end; | |
| 2680 register char c; | |
| 2681 if (!is_stringobject(v) || getstringsize(v) != 1) { | |
| 2682 err_setstr(TypeError, | |
| 2683 "string member test needs char left operand"); | |
| 2684 return -1; | |
| 2685 } | |
| 2686 c = getstringvalue(v)[0]; | |
| 2687 s = getstringvalue(w); | |
| 2688 end = s + getstringsize(w); | |
| 2689 while (s < end) { | |
| 2690 if (c == *s++) | |
| 2691 return 1; | |
| 2692 } | |
| 2693 return 0; | |
| 2694 } | |
| 2695 sq = w->ob_type->tp_as_sequence; | |
| 2696 if (sq == NULL) { | |
| 2697 err_setstr(TypeError, | |
| 2698 "'in' or 'not in' needs sequence right argument"); | |
| 2699 return -1; | |
| 2700 } | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2701 for (i = 0; ; i++) { |
| 86 | 2702 x = (*sq->sq_item)(w, i); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2703 if (x == NULL) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2704 if (err_occurred() == IndexError) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2705 err_clear(); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2706 break; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2707 } |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2708 return -1; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2709 } |
| 86 | 2710 cmp = cmpobject(v, x); |
| 2711 XDECREF(x); | |
| 2712 if (cmp == 0) | |
| 2713 return 1; | |
| 2714 } | |
| 2715 return 0; | |
| 2716 } | |
| 2717 | |
| 69 | 2718 static object * |
| 86 | 2719 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
|
2720 int op; |
| 69 | 2721 register object *v; |
| 2722 register object *w; | |
| 2723 { | |
| 2724 register int cmp; | |
| 2725 register int res = 0; | |
| 2726 switch (op) { | |
| 86 | 2727 case IS: |
| 2728 case IS_NOT: | |
| 2729 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
|
2730 if (op == (int) IS_NOT) |
| 86 | 2731 res = !res; |
| 2732 break; | |
| 69 | 2733 case IN: |
| 2734 case NOT_IN: | |
| 86 | 2735 res = cmp_member(v, w); |
| 2736 if (res < 0) | |
| 2737 return NULL; | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2738 if (op == (int) NOT_IN) |
| 86 | 2739 res = !res; |
| 69 | 2740 break; |
| 2741 case EXC_MATCH: | |
| 86 | 2742 res = cmp_exception(v, w); |
| 69 | 2743 break; |
| 2744 default: | |
| 86 | 2745 cmp = cmpobject(v, w); |
| 2746 switch (op) { | |
| 2747 case LT: res = cmp < 0; break; | |
| 2748 case LE: res = cmp <= 0; break; | |
| 2749 case EQ: res = cmp == 0; break; | |
| 2750 case NE: res = cmp != 0; break; | |
| 2751 case GT: res = cmp > 0; break; | |
| 2752 case GE: res = cmp >= 0; break; | |
| 2753 /* XXX no default? (res is initialized to 0 though) */ | |
| 2754 } | |
| 69 | 2755 } |
| 2756 v = res ? True : False; | |
| 2757 INCREF(v); | |
| 2758 return v; | |
| 2759 } | |
| 2760 | |
| 86 | 2761 static int |
| 2762 import_from(locals, v, name) | |
| 2763 object *locals; | |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2764 object *v; |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2765 object *name; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2766 { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2767 object *w, *x; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2768 if (!is_moduleobject(v)) { |
|
2201
8f1daffe799b
add missing INCREF in RAISE_EXCEPTION
Guido van Rossum <guido@python.org>
parents:
2151
diff
changeset
|
2769 err_setstr(TypeError, "import-from requires module object"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2770 return -1; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2771 } |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2772 w = getmoduledict(v); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2773 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
|
2774 int pos, err; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2775 object *name, *value; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2776 pos = 0; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2777 while (mappinggetnext(w, &pos, &name, &value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2778 if (!is_stringobject(name) || |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2779 getstringvalue(name)[0] == '_') |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 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
|
2785 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
|
2786 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2787 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 if (err != 0) |
| 86 | 2793 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2794 } |
| 86 | 2795 return 0; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2796 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2797 else { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2798 x = dict2lookup(w, name); |
| 86 | 2799 if (x == NULL) { |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2800 char buf[250]; |
|
661
7e5f4d9aee77
Limit length of name passed to sprintf.
Guido van Rossum <guido@python.org>
parents:
607
diff
changeset
|
2801 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
|
2802 getstringvalue(name)); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2803 err_setstr(ImportError, buf); |
| 86 | 2804 return -1; |
| 2805 } | |
| 2806 else | |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2807 return dict2insert(locals, name, x); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2808 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2809 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2810 |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2811 static object * |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2812 build_class(methods, bases, name) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2813 object *methods; /* dictionary */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2814 object *bases; /* tuple containing classes */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2815 object *name; /* string */ |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2816 { |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2817 int i; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2818 if (!is_tupleobject(bases)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2819 err_setstr(SystemError, "build_class with non-tuple bases"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2820 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2821 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2822 if (gettuplesize(bases) > 0) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2823 object *base; |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2824 base = GETTUPLEITEM(bases, 0); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2825 /* Call the base's *type*, if it is callable. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2826 This code is a hook for Donald Beaudry's type extensions. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2827 In unexended Python it will never be triggered since its |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2828 types are not callable. */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2829 if (base->ob_type->ob_type->tp_call) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2830 object *args; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2831 object *class; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2832 args = mkvalue("(OOO)", name, bases, methods); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2833 class = call_object((object *)base->ob_type, args); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2834 DECREF(args); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2835 return class; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2836 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2837 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2838 if (!is_dictobject(methods)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2839 err_setstr(SystemError, "build_class with non-dictionary"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2840 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2841 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2842 if (!is_stringobject(name)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2843 err_setstr(SystemError, "build_class witn non-string name"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2844 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2845 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2846 for (i = gettuplesize(bases); --i >= 0; ) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2847 object *base = GETTUPLEITEM(bases, i); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2848 if (!is_classobject(base)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2849 err_setstr(TypeError, |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2850 "base is not a class object"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2851 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2852 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2853 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2854 return newclassobject(bases, methods, name); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2855 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2856 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2857 static int |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2858 access_statement(name, vmode, f) |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2859 object *name; |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2860 object *vmode; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2861 frameobject *f; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2862 { |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2863 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
|
2864 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
|
2865 typeobject *type; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2866 int ret; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2867 fast_2_locals(f); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2868 value = dict2lookup(f->f_locals, name); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2869 if (value && is_accessobject(value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2870 err_setstr(AccessError, "can't override access"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2871 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2872 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2873 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
|
2874 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
|
2875 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
|
2876 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2877 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
|
2878 ac = newaccessobject(value, f->f_locals, type, mode); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2879 if (ac == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2880 return -1; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2881 ret = mappinginsert(f->f_locals, name, ac); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2882 DECREF(ac); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2883 locals_2_fast(f, 0); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2884 return ret; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2885 } |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2886 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2887 static int |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2888 exec_statement(prog, globals, locals) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2889 object *prog; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2890 object *globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2891 object *locals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2892 { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2893 char *s; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2894 int n; |
|
2295
3d6c9a47ea44
DECREF result of run_string
Guido van Rossum <guido@python.org>
parents:
2271
diff
changeset
|
2895 object *v; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2896 int plain = 0; |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2897 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2898 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
|
2899 ((n = gettuplesize(prog)) == 2 || n == 3)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2900 /* Backward compatibility hack */ |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2901 globals = gettupleitem(prog, 1); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2902 if (n == 3) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2903 locals = gettupleitem(prog, 2); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2904 prog = gettupleitem(prog, 0); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2905 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2906 if (globals == None) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2907 globals = getglobals(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2908 if (locals == None) { |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2909 locals = getlocals(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2910 plain = 1; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2911 } |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2912 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2913 else if (locals == None) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2914 locals = globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2915 if (!is_stringobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2916 !is_codeobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2917 !is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2918 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2919 "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
|
2920 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2921 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2922 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
|
2923 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2924 "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
|
2925 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2926 } |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
2927 if (dictlookup(globals, "__builtins__") == NULL) |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
2928 dictinsert(globals, "__builtins__", current_frame->f_builtins); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2929 if (is_codeobject(prog)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2930 if (eval_code((codeobject *) prog, globals, locals) == NULL) |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2931 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2932 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2933 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2934 if (is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2935 FILE *fp = getfilefile(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2936 char *name = getstringvalue(getfilename(prog)); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2937 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
|
2938 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2939 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2940 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2941 s = getstringvalue(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2942 if (strlen(s) != getstringsize(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2943 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
|
2944 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2945 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2946 v = run_string(s, file_input, globals, locals); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2947 if (v == NULL) |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2948 return -1; |
|
2295
3d6c9a47ea44
DECREF result of run_string
Guido van Rossum <guido@python.org>
parents:
2271
diff
changeset
|
2949 DECREF(v); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2950 if (plain) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2951 locals_2_fast(current_frame, 0); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2952 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2953 } |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2954 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2955 /* Hack for newimp.py */ |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2956 static object * |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2957 find_from_args(f, nexti) |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2958 frameobject *f; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2959 int nexti; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2960 { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2961 int opcode; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2962 int oparg; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2963 object *list, *name; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2964 unsigned char *next_instr; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2965 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2966 next_instr = GETUSTRINGVALUE(f->f_code->co_code) + nexti; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2967 opcode = (*next_instr++); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2968 if (opcode != IMPORT_FROM) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2969 INCREF(None); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2970 return None; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2971 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2972 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2973 list = newlistobject(0); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2974 if (list == NULL) |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2975 return NULL; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2976 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2977 do { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2978 oparg = (next_instr[1]<<8) + next_instr[0]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2979 next_instr += 2; |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2980 name = Getnamev(f, oparg); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2981 if (addlistitem(list, name) < 0) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2982 DECREF(list); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2983 break; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2984 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2985 opcode = (*next_instr++); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2986 } while (opcode == IMPORT_FROM); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2987 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2988 return list; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2989 } |
