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
("defFree", 2<<4), # name used but not defined in nested block
51
+
("defFreeClass", 2<<5),# free variable from class's method
52
+
("defImport", 2<<6), # assignment occurred via import
53
+
)
54
+
55
+
BLOCK_TYPES= {
56
+
"function": "FunctionBlock",
57
+
"class": "ClassBlock",
58
+
"module": "ModuleBlock",
59
+
}
60
+
61
+
defdump_symtable(st):
62
+
"""Dump the symtable"""
63
+
out="&SymTable{\n"
64
+
out+='Type:%s,\n'%BLOCK_TYPES[st.get_type()] # Return the type of the symbol table. Possible values are 'class', 'module', and 'function'.
65
+
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
+
67
+
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.
69
+
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.
72
+
out+='Symbols: Symbols{\n'
73
+
fornameinst.get_identifiers():
74
+
value=st.lookup(name)
75
+
out+='"%s":%s,\n'% (name, dump_symbol(value))
76
+
out+='},\n'
77
+
# out += 'children:"%s",\n' % st.get_children() # Return a list of the nested symbol tables.
78
+
out+="}"
79
+
returnout
80
+
81
+
defdump_symbol(s):
82
+
"""Dump a symbol"""
83
+
#class symtable.Symbol
84
+
# An entry in a SymbolTable corresponding to an identifier in the source. The constructor is not public.
85
+
out="Symbol{\n"
86
+
out+='Name:"%s",\n'%s.get_name() # Return the symbol’s name.
0 commit comments