annotate Include/symtable.h @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents edfed0e32ced
children fd25030223b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
16799
08d937107fe6 Improved __future__ parser; still more to do
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16781
diff changeset
22 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
23 };
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
24
16539
a47d93ef103a Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16428
diff changeset
25 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
26 PyObject_HEAD
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
27 PyObject *ste_id; /* int: key in st_symbols */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
28 PyObject *ste_symbols; /* dict: name to flags */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
29 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
30 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
31 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
32 _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
33 int ste_unoptimized; /* false if namespace is optimized */
48257
eb1e64e535e6 fix compile errors
Benjamin Peterson <benjamin@python.org>
parents: 48255
diff changeset
34 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
35 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
36 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
37 including free refs to globals */
026ae1b8a7e3 Fix icc warnings: single bit fields should be unsigned
Neal Norwitz <nnorwitz@gmail.com>
parents: 35793
diff changeset
38 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
39 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
40 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
41 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
42 an argument */
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
43 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
44 int ste_opt_lineno; /* lineno of last exec or import * */
58250
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 54819
diff changeset
45 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
46 struct symtable *ste_table;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
47 } 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
48
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
49 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
50
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
51 #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
52
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
53 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
54
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
55 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
56 PyFutureFeatures *);
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
57 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
58
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
59 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
60
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
61 /* 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
62
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
63 #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
64 #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
65 #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
66 #define USE 2<<2 /* name is used */
54819
514fc9366f2d remove some unused symtable constants
Benjamin Peterson <benjamin@python.org>
parents: 54811
diff changeset
67 #define DEF_FREE 2<<3 /* name used but not defined in nested block */
514fc9366f2d remove some unused symtable constants
Benjamin Peterson <benjamin@python.org>
parents: 54811
diff changeset
68 #define DEF_FREE_CLASS 2<<4 /* free variable from class's method */
514fc9366f2d remove some unused symtable constants
Benjamin Peterson <benjamin@python.org>
parents: 54811
diff changeset
69 #define DEF_IMPORT 2<<5 /* assignment occurred via import */
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
70
16866
3a411d41eeb4 add DEF_BOUND
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16799
diff changeset
71 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
3a411d41eeb4 add DEF_BOUND
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16799
diff changeset
72
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
73 /* 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
74 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
75 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
76 */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
77 #define SCOPE_OFF 11
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
78 #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
79
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
80 #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
81 #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
82 #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
83 #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
84 #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
85
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
86 /* 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
87 #define OPT_IMPORT_STAR 1
5a1230de436a Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16539
diff changeset
88 #define OPT_EXEC 2
5a1230de436a Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16539
diff changeset
89 #define OPT_BARE_EXEC 4
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
90 #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
91
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
92 #define GENERATOR 1
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32121
diff changeset
93 #define GENERATOR_EXPRESSION 2
16781
5a1230de436a Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 16539
diff changeset
94
16421
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
95 #ifdef __cplusplus
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
96 }
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
97 #endif
aa844711463a Move a bunch of definitions that were internal to compile.c to
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
98 #endif /* !Py_SYMTABLE_H */