Changeset 388 for python/vendor/current/Modules/symtablemodule.c
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Modules/symtablemodule.c
r2 r388 9 9 symtable_symtable(PyObject *self, PyObject *args) 10 10 { 11 12 11 struct symtable *st; 12 PyObject *t; 13 13 14 15 16 17 14 char *str; 15 char *filename; 16 char *startstr; 17 int start; 18 18 19 if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename, 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 t = st->st_symbols;37 38 39 40 19 if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename, 20 &startstr)) 21 return NULL; 22 if (strcmp(startstr, "exec") == 0) 23 start = Py_file_input; 24 else if (strcmp(startstr, "eval") == 0) 25 start = Py_eval_input; 26 else if (strcmp(startstr, "single") == 0) 27 start = Py_single_input; 28 else { 29 PyErr_SetString(PyExc_ValueError, 30 "symtable() arg 3 must be 'exec' or 'eval' or 'single'"); 31 return NULL; 32 } 33 st = Py_SymtableString(str, filename, start); 34 if (st == NULL) 35 return NULL; 36 t = (PyObject *)st->st_top; 37 Py_INCREF(t); 38 PyMem_Free((void *)st->st_future); 39 PySymtable_Free(st); 40 return t; 41 41 } 42 42 43 43 static PyMethodDef symtable_methods[] = { 44 {"symtable", symtable_symtable,METH_VARARGS,45 46 47 {NULL, NULL}/* sentinel */44 {"symtable", symtable_symtable, METH_VARARGS, 45 PyDoc_STR("Return symbol and scope dictionaries" 46 " used internally by compiler.")}, 47 {NULL, NULL} /* sentinel */ 48 48 }; 49 49 … … 51 51 init_symtable(void) 52 52 { 53 53 PyObject *m; 54 54 55 m = Py_InitModule("_symtable", symtable_methods); 56 if (m == NULL) 57 return; 58 PyModule_AddIntConstant(m, "USE", USE); 59 PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL); 60 PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL); 61 PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM); 62 PyModule_AddIntConstant(m, "DEF_STAR", DEF_STAR); 63 PyModule_AddIntConstant(m, "DEF_DOUBLESTAR", DEF_DOUBLESTAR); 64 PyModule_AddIntConstant(m, "DEF_INTUPLE", DEF_INTUPLE); 65 PyModule_AddIntConstant(m, "DEF_FREE", DEF_FREE); 66 PyModule_AddIntConstant(m, "DEF_FREE_GLOBAL", DEF_FREE_GLOBAL); 67 PyModule_AddIntConstant(m, "DEF_FREE_CLASS", DEF_FREE_CLASS); 68 PyModule_AddIntConstant(m, "DEF_IMPORT", DEF_IMPORT); 69 PyModule_AddIntConstant(m, "DEF_BOUND", DEF_BOUND); 55 if (PyType_Ready(&PySTEntry_Type) < 0) 56 return; 70 57 71 PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock); 72 PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock); 73 PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock); 58 m = Py_InitModule("_symtable", symtable_methods); 59 if (m == NULL) 60 return; 61 PyModule_AddIntConstant(m, "USE", USE); 62 PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL); 63 PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL); 64 PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM); 65 PyModule_AddIntConstant(m, "DEF_FREE", DEF_FREE); 66 PyModule_AddIntConstant(m, "DEF_FREE_CLASS", DEF_FREE_CLASS); 67 PyModule_AddIntConstant(m, "DEF_IMPORT", DEF_IMPORT); 68 PyModule_AddIntConstant(m, "DEF_BOUND", DEF_BOUND); 74 69 75 PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR);76 PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC);77 PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC);70 PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock); 71 PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock); 72 PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock); 78 73 79 PyModule_AddIntConstant(m, "LOCAL", LOCAL); 80 PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT); 81 PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT); 82 PyModule_AddIntConstant(m, "FREE", FREE); 83 PyModule_AddIntConstant(m, "CELL", CELL); 74 PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR); 75 PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC); 76 PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC); 84 77 85 PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFF); 86 PyModule_AddIntConstant(m, "SCOPE_MASK", SCOPE_MASK); 78 PyModule_AddIntConstant(m, "LOCAL", LOCAL); 79 PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT); 80 PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT); 81 PyModule_AddIntConstant(m, "FREE", FREE); 82 PyModule_AddIntConstant(m, "CELL", CELL); 83 84 PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFF); 85 PyModule_AddIntConstant(m, "SCOPE_MASK", SCOPE_MASK); 87 86 }
Note:
See TracChangeset
for help on using the changeset viewer.