def dump_program(self, compiled_program): self._f.write('GBO/1.0\n') rtns = self._mangler.mangle_routines(compiled_program) rtns = utils.seq_sorted(rtns.items()) for mangled_name, (prog, rtn) in rtns: self.dump_routine(prog, rtn) self._f.write('%%\n')
def _followups(self, nonterm): """Return the set of token types that could follow the given nonterminal.""" res = {} for nonterm2, symb in self._parse_table.keys(): if nonterm == nonterm2: set_add(res, symb) return seq_sorted([Token.type_description(key) for key in res.keys()])
def show_liveness_info(self): """Return a string, showing liveness annotations made at this node by the static analysis tool. """ live_in = '' if self.live_in is not None: live_in = ''.join([ '{live_in: ', str(' '.join(utils.seq_sorted(self.live_in.keys()))), '}' ]) live_out = '' if self.live_out is not None: live_out = ''.join([ '{live_out: ', str(' '.join(utils.seq_sorted(self.live_out.keys()))), '}' ]) return live_in, live_out
def backtrace(self, msg): def describe(ar, indent_): loc = ar.routine.nearby_elems.get(ar.ip, self.program.tree).pos_begin.file_row() return '%s%s %s %s' % (' ' * indent_, ar.routine.prfn, ar.routine.name, loc) cs = self.callstack + [self.ar] res = '' res += msg + '\n\n' res += i18n.i18n('At:') + '\n' res += indent('\n'.join([ describe(x, y) for x, y in zip(cs, range(0, len(cs))) ])) + '\n' bindings = [(k, v) for k, v in seq_sorted(self.ar.bindings.items()) if k[0] != '_'] if len(bindings) > 0: res += i18n.i18n('Locals:') + '\n' res += indent('\n'.join(['%s: %s' % (k, v) for k, v in bindings])) return res
def __repr__(self): sr = seq_sorted(self.routines.values(), key=lambda r: r.name) return '\n\n'.join([repr(x) for x in sr])