def dispatch(self, x, assign=False):
        if isinstance(x, Code):
            return x
        assign_state = self.assign_state
        if assign:
            self.assign_state = assign
        lineno = self.get_lineno(x)
        if lineno is not None:
            self.last_lineno = lineno
        else:
            lineno = self.last_lineno
        try:
            if isinstance(x, Node):
                visit = getattr(self, 'node_%s' % type_repr(x.type), None)
                if visit is None:
                    raise self.TranslationError("No name for node type %s at %r" % (x.type, x))
            else:
                visit = getattr(self, 'leaf_%s' % type_repr(x.value), None)
                if visit is None:
                    if x.type in leaf_type:
                        visit = getattr(self, 'leaftype_%s' % leaf_type.get(x.type), None)
                    if visit is None:
                        if x.value in ['', '\n', '\r\n', ';']:
                            self.assign_state = assign_state
                            return
                        raise self.TranslationError("No name for leaf type %s at %r" % (x.type, x))
            code = visit(x)
            self.assign_state = assign_state
            return code
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            if isinstance(exc_value, self.TranslationError):
                if exc_value.lineno is None:
                    exc_value.lineno = lineno
                raise
            else:
                print "Error in %s at %s:" % (self.srcfile, lineno)
                raise
dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/translator_dict.py/Translator.dispatch/original