You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
("defImport", 2<<6), # assignment occurred via import
53
53
)
54
54
55
+
#opt flags flags to names (from symtable.h)
56
+
OPT_FLAGS= (
57
+
("optImportStar", 1),
58
+
("optTopLevel", 2),
59
+
)
60
+
55
61
BLOCK_TYPES= {
56
62
"function": "FunctionBlock",
57
63
"class": "ClassBlock",
58
64
"module": "ModuleBlock",
59
65
}
60
66
67
+
defdump_flags(flag_bits, flags_dict):
68
+
"""Dump the bits in flag_bits using the flags_dict"""
69
+
flags= []
70
+
forname, maskinflags_dict:
71
+
if (flag_bits&mask) !=0:
72
+
flags.append(name)
73
+
ifnotflags:
74
+
flags= ["0"]
75
+
return"|".join(flags)
76
+
61
77
defdump_symtable(st):
62
78
"""Dump the symtable"""
63
79
out="&SymTable{\n"
64
80
out+='Type:%s,\n'%BLOCK_TYPES[st.get_type()] # Return the type of the symbol table. Possible values are 'class', 'module', and 'function'.
65
81
out+='Name:"%s",\n'%st.get_name() # Return the table’s name. This is the name of the class if the table is for a class, the name of the function if the table is for a function, or 'top' if the table is global (get_type() returns 'module').
66
82
67
83
out+='Lineno:%s,\n'%st.get_lineno() # Return the number of the first line in the block this table represents.
68
-
out+='Optimized:%s,\n'%dump_bool(st.is_optimized())# Return True if the locals in this table can be optimized.
84
+
out+='Unoptimized:%s,\n'%dump_flags(st._table.optimized, OPT_FLAGS)# Return False if the locals in this table can be optimized.
69
85
out+='Nested:%s,\n'%dump_bool(st.is_nested()) # Return True if the block is a nested class or function.
70
-
out+='Exec:%s,\n'%dump_bool(st.has_exec()) # Return True if the block uses exec.
71
-
out+='ImportStar:%s,\n'%dump_bool(st.has_import_star()) # Return True if the block uses a starred from-import.
86
+
#out += 'Exec:%s,\n' % dump_bool(st.has_exec()) # Return True if the block uses exec.
87
+
#out += 'ImportStar:%s,\n' % dump_bool(st.has_import_star()) # Return True if the block uses a starred from-import.
0 commit comments