def _make_index_dict_filter(syms, flag1, flag2): names = syms.keys() string_sort(names) # return cell vars in alphabetical order i = 0 result = {} for name in names: scope = syms[name] if scope in (flag1, flag2): result[name] = i i += 1 return result
def __init__(self, space, name, first_lineno, scope, compile_info): self.space = space self.name = name self.first_lineno = first_lineno self.compile_info = compile_info self.first_block = self.new_block() self.use_block(self.first_block) self.names = {} self.var_names = _list_to_dict(scope.varnames) self.cell_vars = _make_index_dict_filter(scope.symbols, symtable.SCOPE_CELL) string_sort(scope.free_vars) # return free vars in alphabetical order self.free_vars = _list_to_dict(scope.free_vars, len(self.cell_vars)) self.w_consts = space.newdict() self.argcount = 0 self.lineno_set = False self.lineno = 0 self.add_none_to_final_return = True