[Python-checkins] python/dist/src/Include symtable.h,2.9.18.2,2.9.18.3

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
2002年8月04日 13:53:35 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv16625/Include
Modified Files:
 Tag: ast-branch
	symtable.h 
Log Message:
Revise names.
PySymtableEntry(Object) -> PySTEntry(Object): Just too much typing.
scope_ty -> block_ty: It describes the type of the block. Scope will
 get used for local, global, free, etc.
Add PyST_GetScope() used by compiler to determine global vs local vs ...
Index: symtable.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/symtable.h,v
retrieving revision 2.9.18.2
retrieving revision 2.9.18.3
diff -C2 -d -r2.9.18.2 -r2.9.18.3
*** symtable.h	9 Jul 2002 13:22:00 -0000	2.9.18.2
--- symtable.h	4 Aug 2002 20:53:33 -0000	2.9.18.3
***************
*** 5,10 ****
 #endif
 
! typedef enum _scope_type { FunctionScope, ClassScope, ModuleScope }
! scope_ty;
 
 struct _symtable_entry;
--- 5,10 ----
 #endif
 
! typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
! block_ty;
 
 struct _symtable_entry;
***************
*** 17,21 ****
 PyObject *st_stack; /* stack of namespace info */
 	PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
! 	int st_nscopes; /* number of scopes */
 	int st_errors; /* number of errors */
 	char *st_private; /* name of current class or NULL */
--- 17,21 ----
 PyObject *st_stack; /* stack of namespace info */
 	PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
! 	int st_nblocks; /* number of blocks */
 	int st_errors; /* number of errors */
 	char *st_private; /* name of current class or NULL */
***************
*** 26,52 ****
 typedef struct _symtable_entry {
 	PyObject_HEAD
! 	PyObject *ste_id; /* int: key in st_symbols) */
! 	PyObject *ste_symbols; /* dict: name to flags) */
! 	PyObject *ste_name; /* string: name of scope */
 	PyObject *ste_varnames; /* list of variable names */
 	PyObject *ste_children; /* list of child ids */
! 	scope_ty ste_type; /* module, class, or function */
! 	int ste_lineno; /* first line of scope */
 	int ste_optimized; /* true if namespace can't be optimized */
! 	int ste_nested; /* true if scope is nested */
! 	int ste_child_free; /* true if a child scope has free variables,
 				 including free refs to globals */
 	int ste_generator; /* true if namespace is a generator */
 	int ste_opt_lineno; /* lineno of last exec or import * */
 	struct symtable *ste_table;
! } PySymtableEntryObject;
 
! extern DL_IMPORT(PyTypeObject) PySymtableEntry_Type;
 
! #define PySymtableEntry_Check(op) ((op)->ob_type == &PySymtableEntry_Type)
 
! extern DL_IMPORT(PySymtableEntryObject *) \
! 	PySymtableEntry_New(struct symtable *, identifier, scope_ty, void *, 
! 			 int);
 
 DL_IMPORT(struct symtable *) PyNode_CompileSymtable(struct _node *, char *);
--- 26,52 ----
 typedef struct _symtable_entry {
 	PyObject_HEAD
! 	PyObject *ste_id; /* int: key in st_symbols */
! 	PyObject *ste_symbols; /* dict: name to flags */
! 	PyObject *ste_name; /* string: name of block */
 	PyObject *ste_varnames; /* list of variable names */
 	PyObject *ste_children; /* list of child ids */
! 	block_ty ste_type; /* module, class, or function */
! 	int ste_lineno; /* first line of block */
 	int ste_optimized; /* true if namespace can't be optimized */
! 	int ste_nested; /* true if block is nested */
! 	int ste_child_free; /* true if a child block has free variables,
 				 including free refs to globals */
 	int ste_generator; /* true if namespace is a generator */
 	int ste_opt_lineno; /* lineno of last exec or import * */
 	struct symtable *ste_table;
! } PySTEntryObject;
 
! extern DL_IMPORT(PyTypeObject) PySTEntry_Type;
 
! #define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
 
! extern DL_IMPORT(PySTEntryObject *) \
! 	PySTEntry_New(struct symtable *, identifier, block_ty, void *, int);
! DL_IMPORT(int) PyST_GetScope(PyObject *, PyObject *);
 
 DL_IMPORT(struct symtable *) PyNode_CompileSymtable(struct _node *, char *);
***************
*** 65,69 ****
 #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */
 #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */
! #define DEF_FREE 2<<6 /* name used but not defined in nested scope */
 #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */
 #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */
--- 65,69 ----
 #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */
 #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */
! #define DEF_FREE 2<<6 /* name used but not defined in nested block */
 #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */
 #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */
***************
*** 72,80 ****
 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
 
! #define LOCAL 1
! #define GLOBAL_EXPLICIT 2
! #define GLOBAL_IMPLICIT 3
! #define FREE 4
! #define CELL 5
 
 #define OPT_IMPORT_STAR 1
--- 72,83 ----
 #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
 
! /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
! table. GLOBAL is returned from PyST_GetScope() for either of them. 
! It is stored in ste_symbols at bits 12-14.
! */
! #define SCOPE_OFF 11
! #define SCOPE_MASK 7
! const int LOCAL = 1, GLOBAL_EXPLICIT = 2, GLOBAL_IMPLICIT = 3, FREE = 4,
! 	CELL = 5;
 
 #define OPT_IMPORT_STAR 1

AltStyle によって変換されたページ (->オリジナル) /