PyObject *ste_children; /* list of child blocks */
PyObject *ste_directives;/* locations of global and nonlocal statements */
_Py_block_ty ste_type; /* module, class, or function */
- int ste_unoptimized; /* false if namespace is optimized */
int ste_nested; /* true if block is nested */
unsigned ste_free : 1; /* true if block has free variables */
unsigned ste_child_free : 1; /* true if a child block has free vars,
#define FREE 4
#define CELL 5
-/* The following two names are used for the ste_unoptimized bit field */
-#define OPT_IMPORT_STAR 1
-#define OPT_TOPLEVEL 2 /* top-level names, including eval and exec */
-
#define GENERATOR 1
#define GENERATOR_EXPRESSION 2
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM,
- DEF_IMPORT, DEF_BOUND, OPT_IMPORT_STAR, SCOPE_OFF, SCOPE_MASK, FREE,
+ DEF_IMPORT, DEF_BOUND, SCOPE_OFF, SCOPE_MASK, FREE,
LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
return self._table.lineno
def is_optimized(self):
- return bool(self._table.type == _symtable.TYPE_FUNCTION
- and not self._table.optimized)
+ return bool(self._table.type == _symtable.TYPE_FUNCTION)
def is_nested(self):
return bool(self._table.nested)
"""Return true if the scope uses exec. Deprecated method."""
return False
- def has_import_star(self):
- """Return true if the scope uses import *"""
- return bool(self._table.optimized & OPT_IMPORT_STAR)
-
def get_identifiers(self):
return self._table.symbols.keys()
PyModule_AddIntConstant(m, "TYPE_CLASS", ClassBlock);
PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock);
- PyModule_AddIntMacro(m, OPT_IMPORT_STAR);
- PyModule_AddIntMacro(m, OPT_TOPLEVEL);
-
PyModule_AddIntMacro(m, LOCAL);
PyModule_AddIntMacro(m, GLOBAL_EXPLICIT);
PyModule_AddIntMacro(m, GLOBAL_IMPLICIT);
optype = OP_FAST;
break;
case GLOBAL_IMPLICIT:
- if (c->u->u_ste->ste_type == FunctionBlock &&
- !c->u->u_ste->ste_unoptimized)
+ if (c->u->u_ste->ste_type == FunctionBlock)
optype = OP_GLOBAL;
break;
case GLOBAL_EXPLICIT:
int flags = 0;
Py_ssize_t n;
if (ste->ste_type == FunctionBlock) {
- flags |= CO_NEWLOCALS;
- if (!ste->ste_unoptimized)
- flags |= CO_OPTIMIZED;
+ flags |= CO_NEWLOCALS | CO_OPTIMIZED;
if (ste->ste_nested)
flags |= CO_NESTED;
if (ste->ste_generator)
ste->ste_directives = NULL;
ste->ste_type = block;
- ste->ste_unoptimized = 0;
ste->ste_nested = 0;
ste->ste_free = 0;
ste->ste_varargs = 0;
{"symbols", T_OBJECT, OFF(ste_symbols), READONLY},
{"varnames", T_OBJECT, OFF(ste_varnames), READONLY},
{"children", T_OBJECT, OFF(ste_children), READONLY},
- {"optimized",T_INT, OFF(ste_unoptimized), READONLY},
{"nested", T_INT, OFF(ste_nested), READONLY},
{"type", T_INT, OFF(ste_type), READONLY},
{"lineno", T_INT, OFF(ste_lineno), READONLY},
}
st->st_top = st->st_cur;
- st->st_cur->ste_unoptimized = OPT_TOPLEVEL;
switch (mod->kind) {
case Module_kind:
seq = mod->v.Module.body;
break;
case Import_kind:
VISIT_SEQ(st, alias, s->v.Import.names);
- /* XXX Don't have the lineno available inside
- visit_alias */
- if (st->st_cur->ste_unoptimized && !st->st_cur->ste_opt_lineno) {
- st->st_cur->ste_opt_lineno = s->lineno;
- st->st_cur->ste_opt_col_offset = s->col_offset;
- }
break;
case ImportFrom_kind:
VISIT_SEQ(st, alias, s->v.ImportFrom.names);
- /* XXX Don't have the lineno available inside
- visit_alias */
- if (st->st_cur->ste_unoptimized && !st->st_cur->ste_opt_lineno) {
- st->st_cur->ste_opt_lineno = s->lineno;
- st->st_cur->ste_opt_col_offset = s->col_offset;
- }
break;
case Global_kind: {
int i;
Py_DECREF(store_name);
return 0;
}
- st->st_cur->ste_unoptimized |= OPT_IMPORT_STAR;
Py_DECREF(store_name);
return 1;
}