LCOV - code coverage report
Current view: top level - Modules - symtablemodule.c (source / functions) Hit Total Coverage
Test: CPython lcov report Lines: 0 46 0.0 %
Date: 2017-04-19 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "Python.h"
       2             : 
       3             : #include "code.h"
       4             : #include "compile.h"
       5             : #include "Python-ast.h"
       6             : #include "symtable.h"
       7             : 
       8             : static PyObject *
       9           0 : symtable_symtable(PyObject *self, PyObject *args)
      10             : {
      11             :     struct symtable *st;
      12             :     PyObject *t;
      13             : 
      14             :     char *str;
      15             :     char *filename;
      16             :     char *startstr;
      17             :     int start;
      18             : 
      19           0 :     if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename,
      20             :                           &startstr))
      21           0 :         return NULL;
      22           0 :     if (strcmp(startstr, "exec") == 0)
      23           0 :         start = Py_file_input;
      24           0 :     else if (strcmp(startstr, "eval") == 0)
      25           0 :         start = Py_eval_input;
      26           0 :     else if (strcmp(startstr, "single") == 0)
      27           0 :         start = Py_single_input;
      28             :     else {
      29           0 :         PyErr_SetString(PyExc_ValueError,
      30             :            "symtable() arg 3 must be 'exec' or 'eval' or 'single'");
      31           0 :         return NULL;
      32             :     }
      33           0 :     st = Py_SymtableString(str, filename, start);
      34           0 :     if (st == NULL)
      35           0 :         return NULL;
      36           0 :     t = (PyObject *)st->st_top;
      37           0 :     Py_INCREF(t);
      38           0 :     PyMem_Free((void *)st->st_future);
      39           0 :     PySymtable_Free(st);
      40           0 :     return t;
      41             : }
      42             : 
      43             : static PyMethodDef symtable_methods[] = {
      44             :     {"symtable",        symtable_symtable,      METH_VARARGS,
      45             :      PyDoc_STR("Return symbol and scope dictionaries"
      46             :                " used internally by compiler.")},
      47             :     {NULL,              NULL}           /* sentinel */
      48             : };
      49             : 
      50             : PyMODINIT_FUNC
      51           0 : init_symtable(void)
      52             : {
      53             :     PyObject *m;
      54             : 
      55           0 :     if (PyType_Ready(&PySTEntry_Type) < 0)
      56           0 :         return;
      57             : 
      58           0 :     m = Py_InitModule("_symtable", symtable_methods);
      59           0 :     if (m == NULL)
      60           0 :         return;
      61           0 :     PyModule_AddIntConstant(m, "USE", USE);
      62           0 :     PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL);
      63           0 :     PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL);
      64           0 :     PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM);
      65           0 :     PyModule_AddIntConstant(m, "DEF_FREE", DEF_FREE);
      66           0 :     PyModule_AddIntConstant(m, "DEF_FREE_CLASS", DEF_FREE_CLASS);
      67           0 :     PyModule_AddIntConstant(m, "DEF_IMPORT", DEF_IMPORT);
      68           0 :     PyModule_AddIntConstant(m, "DEF_BOUND", DEF_BOUND);
      69             : 
      70           0 :     PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock);
      71           0 :     PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock);
      72           0 :     PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock);
      73             : 
      74           0 :     PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR);
      75           0 :     PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC);
      76           0 :     PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC);
      77             : 
      78           0 :     PyModule_AddIntConstant(m, "LOCAL", LOCAL);
      79           0 :     PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT);
      80           0 :     PyModule_AddIntConstant(m, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT);
      81           0 :     PyModule_AddIntConstant(m, "FREE", FREE);
      82           0 :     PyModule_AddIntConstant(m, "CELL", CELL);
      83             : 
      84           0 :     PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFF);
      85           0 :     PyModule_AddIntConstant(m, "SCOPE_MASK", SCOPE_MASK);
      86             : }

Generated by: LCOV version 1.10