Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.8 KiB

  1. #ifndef Py_SYMTABLE_H
  2. #define Py_SYMTABLE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
  7. _Py_block_ty;
  8. struct _symtable_entry;
  9. struct symtable {
  10. const char *st_filename; /* name of file being compiled */
  11. struct _symtable_entry *st_cur; /* current symbol table entry */
  12. struct _symtable_entry *st_top; /* module entry */
  13. PyObject *st_symbols; /* dictionary of symbol table entries */
  14. PyObject *st_stack; /* stack of namespace info */
  15. PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
  16. int st_nblocks; /* number of blocks */
  17. PyObject *st_private; /* name of current class or NULL */
  18. int st_tmpname; /* temporary name counter */
  19. PyFutureFeatures *st_future; /* module's future features */
  20. };
  21. typedef struct _symtable_entry {
  22. PyObject_HEAD
  23. PyObject *ste_id; /* int: key in st_symbols */
  24. PyObject *ste_symbols; /* dict: name to flags */
  25. PyObject *ste_name; /* string: name of block */
  26. PyObject *ste_varnames; /* list of variable names */
  27. PyObject *ste_children; /* list of child ids */
  28. _Py_block_ty ste_type; /* module, class, or function */
  29. int ste_unoptimized; /* false if namespace is optimized */
  30. unsigned ste_nested : 1; /* true if block is nested */
  31. unsigned ste_free : 1; /* true if block has free variables */
  32. unsigned ste_child_free : 1; /* true if a child block has free vars,
  33. including free refs to globals */
  34. unsigned ste_generator : 1; /* true if namespace is a generator */
  35. unsigned ste_varargs : 1; /* true if block has varargs */
  36. unsigned ste_varkeywords : 1; /* true if block has varkeywords */
  37. unsigned ste_returns_value : 1; /* true if namespace uses return with
  38. an argument */
  39. int ste_lineno; /* first line of block */
  40. int ste_opt_lineno; /* lineno of last exec or import * */
  41. int ste_tmpname; /* counter for listcomp temp vars */
  42. struct symtable *ste_table;
  43. } PySTEntryObject;
  44. PyAPI_DATA(PyTypeObject) PySTEntry_Type;
  45. #define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
  46. PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
  47. PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *,
  48. PyFutureFeatures *);
  49. PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
  50. PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
  51. /* Flags for def-use information */
  52. #define DEF_GLOBAL 1 /* global stmt */
  53. #define DEF_LOCAL 2 /* assignment in code block */
  54. #define DEF_PARAM 2<<1 /* formal parameter */
  55. #define USE 2<<2 /* name is used */
  56. #define DEF_STAR 2<<3 /* parameter is star arg */
  57. #define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */
  58. #define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */
  59. #define DEF_FREE 2<<6 /* name used but not defined in nested block */
  60. #define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */
  61. #define DEF_FREE_CLASS 2<<8 /* free variable from class's method */
  62. #define DEF_IMPORT 2<<9 /* assignment occurred via import */
  63. #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
  64. /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
  65. table. GLOBAL is returned from PyST_GetScope() for either of them.
  66. It is stored in ste_symbols at bits 12-14.
  67. */
  68. #define SCOPE_OFF 11
  69. #define SCOPE_MASK 7
  70. #define LOCAL 1
  71. #define GLOBAL_EXPLICIT 2
  72. #define GLOBAL_IMPLICIT 3
  73. #define FREE 4
  74. #define CELL 5
  75. /* The following three names are used for the ste_unoptimized bit field */
  76. #define OPT_IMPORT_STAR 1
  77. #define OPT_EXEC 2
  78. #define OPT_BARE_EXEC 4
  79. #define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */
  80. #define GENERATOR 1
  81. #define GENERATOR_EXPRESSION 2
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif /* !Py_SYMTABLE_H */