Mercurial > cpython-lru_cache-weakref
annotate Include/symtable.h @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | eb1e64e535e6 |
| children | e38335d4df91 917497e2509c |
| rev | line source |
|---|---|
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
1 #ifndef Py_SYMTABLE_H |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
2 #define Py_SYMTABLE_H |
|
36739
796d150e45a9
No need to export PySTEntry_New, it is only used in symtable.c
Neal Norwitz <nnorwitz@gmail.com>
parents:
36227
diff
changeset
|
3 |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
4 #ifdef __cplusplus |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
5 extern "C" { |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
6 #endif |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
7 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
8 typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } |
|
35793
914ec0afa51c
Do not pollute name block_ty, prefix with _Py_
Neal Norwitz <nnorwitz@gmail.com>
parents:
35779
diff
changeset
|
9 _Py_block_ty; |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
10 |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
11 struct _symtable_entry; |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
12 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
13 struct symtable { |
|
26601
cc05c2c8660e
Constify filenames and scripts. Fixes #651362.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
14 const char *st_filename; /* name of file being compiled */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
15 struct _symtable_entry *st_cur; /* current symbol table entry */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
16 struct _symtable_entry *st_top; /* module entry */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
17 PyObject *st_symbols; /* dictionary of symbol table entries */ |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
18 PyObject *st_stack; /* stack of namespace info */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
19 PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
20 int st_nblocks; /* number of blocks */ |
|
35779
19d796bd740f
Fix private name mangling. The symtable also must do mangles so that
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
35743
diff
changeset
|
21 PyObject *st_private; /* name of current class or NULL */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
22 int st_tmpname; /* temporary name counter */ |
|
16799
08d937107fe6
Improved __future__ parser; still more to do
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16781
diff
changeset
|
23 PyFutureFeatures *st_future; /* module's future features */ |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
24 }; |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
25 |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
26 typedef struct _symtable_entry { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
27 PyObject_HEAD |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
28 PyObject *ste_id; /* int: key in st_symbols */ |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
29 PyObject *ste_symbols; /* dict: name to flags */ |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
30 PyObject *ste_name; /* string: name of block */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
31 PyObject *ste_varnames; /* list of variable names */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
32 PyObject *ste_children; /* list of child ids */ |
|
35793
914ec0afa51c
Do not pollute name block_ty, prefix with _Py_
Neal Norwitz <nnorwitz@gmail.com>
parents:
35779
diff
changeset
|
33 _Py_block_ty ste_type; /* module, class, or function */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
34 int ste_unoptimized; /* false if namespace is optimized */ |
|
48257
eb1e64e535e6
fix compile errors
Benjamin Peterson <benjamin@python.org>
parents:
48255
diff
changeset
|
35 int ste_nested; /* true if block is nested */ |
|
36227
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
36 unsigned ste_free : 1; /* true if block has free variables */ |
|
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
37 unsigned ste_child_free : 1; /* true if a child block has free vars, |
|
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
38 including free refs to globals */ |
|
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
39 unsigned ste_generator : 1; /* true if namespace is a generator */ |
|
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
40 unsigned ste_varargs : 1; /* true if block has varargs */ |
|
026ae1b8a7e3
Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents:
35793
diff
changeset
|
41 unsigned ste_varkeywords : 1; /* true if block has varkeywords */ |
|
38588
5dfb21a37f19
Patch #1346214: correctly optimize away "if 0"-style stmts
Georg Brandl <georg@python.org>
parents:
36739
diff
changeset
|
42 unsigned ste_returns_value : 1; /* true if namespace uses return with |
|
5dfb21a37f19
Patch #1346214: correctly optimize away "if 0"-style stmts
Georg Brandl <georg@python.org>
parents:
36739
diff
changeset
|
43 an argument */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
44 int ste_lineno; /* first line of block */ |
|
17132
55218e0495bc
Set the line number correctly for a nested function with an exec or
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16866
diff
changeset
|
45 int ste_opt_lineno; /* lineno of last exec or import * */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
46 int ste_tmpname; /* counter for listcomp temp vars */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
47 struct symtable *ste_table; |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
48 } PySTEntryObject; |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
49 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
50 PyAPI_DATA(PyTypeObject) PySTEntry_Type; |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
51 |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42333
diff
changeset
|
52 #define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
53 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
54 PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16428
diff
changeset
|
55 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
56 PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
57 PyFutureFeatures *); |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
58 PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
59 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
60 PyAPI_FUNC(void) PySymtable_Free(struct symtable *); |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
61 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
62 /* Flags for def-use information */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
63 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
64 #define DEF_GLOBAL 1 /* global stmt */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
65 #define DEF_LOCAL 2 /* assignment in code block */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
66 #define DEF_PARAM 2<<1 /* formal parameter */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
67 #define USE 2<<2 /* name is used */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
68 #define DEF_STAR 2<<3 /* parameter is star arg */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
69 #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
70 #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */ |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
71 #define DEF_FREE 2<<6 /* name used but not defined in nested block */ |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
72 #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
73 #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
74 #define DEF_IMPORT 2<<9 /* assignment occurred via import */ |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
75 |
| 16866 | 76 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) |
| 77 | |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
78 /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
79 table. GLOBAL is returned from PyST_GetScope() for either of them. |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
80 It is stored in ste_symbols at bits 12-14. |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
81 */ |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
82 #define SCOPE_OFF 11 |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
83 #define SCOPE_MASK 7 |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
84 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
85 #define LOCAL 1 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
86 #define GLOBAL_EXPLICIT 2 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
87 #define GLOBAL_IMPLICIT 3 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
88 #define FREE 4 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
89 #define CELL 5 |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
90 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
91 /* The following three names are used for the ste_unoptimized bit field */ |
|
16781
5a1230de436a
Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
92 #define OPT_IMPORT_STAR 1 |
|
5a1230de436a
Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
93 #define OPT_EXEC 2 |
|
5a1230de436a
Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
94 #define OPT_BARE_EXEC 4 |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
95 #define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
96 |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
97 #define GENERATOR 1 |
|
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
32121
diff
changeset
|
98 #define GENERATOR_EXPRESSION 2 |
|
16781
5a1230de436a
Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
99 |
|
16421
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
100 #ifdef __cplusplus |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
101 } |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
102 #endif |
|
aa844711463a
Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
103 #endif /* !Py_SYMTABLE_H */ |
