def _callfunc_code(self, v, current_klass, is_statement=False, optlocal_var=False):

        self.ignore_debug = False
        method_name = None
        if isinstance(v.node, self.ast.Name):
            name_type, pyname, jsname, depth, is_local = self.lookup(v.node.name)
            if name_type == '__pyjamas__':
                try:
                    raw_js = getattr(__pyjamas__, v.node.name)
                    if callable(raw_js):
                        raw_js, has_js_return = raw_js(self, v, current_klass,
                                                       is_statement=is_statement)
                        if has_js_return:
                            self.has_js_return = True
                    else:
                        raw_js = self.translate_escaped_names(raw_js, current_klass)
                    return raw_js
                except __HOLE__, e:
                    raise TranslationError(
                        "Unknown __pyjamas__ function %s" % pyname,
                         v.node, self.module_name)
                except TranslationError, e:
                    raise TranslationError(e.msg, v, self.module_name)
            elif v.node.name == 'locals':
                return """$p.dict({%s})""" % (",".join(["'%s': %s" % (pyname, self.lookup_stack[-1][pyname][2]) for pyname in self.lookup_stack[-1] if self.lookup_stack[-1][pyname][0] not in ['__pyjamas__', 'global']]))
            elif v.node.name == 'globals':
                # XXX: Should be dictproxy, to handle changes
                return "@{{_globals}}(%s)" % self.modpfx()[:-1]
            elif v.node.name == 'len' and depth == -1 and len(v.args) == 1:
                expr = self.expr(v.args[0], current_klass)
                return self.inline_len_code(expr)
            else:
                if name_type is None:
                    # What to do with a (yet) unknown name?
                    # Just nothing...
                    if optlocal_var:
                        call_name = '(typeof %s == "undefined"?%s:%s)' % (
                            v.node.name,
                            self.scopeName(v.node.name, depth, is_local),
                            v.node.name,
                        )
                    else:
                        call_name = self.scopeName(v.node.name, depth, is_local)
                else:
                    call_name = jsname
            call_args = []
        elif isinstance(v.node, self.ast.Getattr):
            attrname = self.attrib_remap(v.node.attrname)
            if isinstance(v.node.expr, self.ast.Name):
                call_name, method_name = self._name2(v.node.expr, current_klass, attrname)
                call_args = []
            elif isinstance(v.node.expr, self.ast.Getattr):
                call_name = self._getattr2(v.node.expr, current_klass, v.node.attrname)
                method_name = call_name.pop()
                call_name = self.attrib_join(call_name)
                call_args = []
            elif isinstance(v.node.expr, self.ast.CallFunc):
                call_name = self._callfunc(v.node.expr, current_klass)
                method_name = attrname
                call_args = []
            elif isinstance(v.node.expr, self.ast.Subscript):
                call_name = self._subscript(v.node.expr, current_klass)
                method_name = attrname
                call_args = []
            elif isinstance(v.node.expr, self.ast.Const):
                call_name = self.expr(v.node.expr, current_klass)
                method_name = attrname
                call_args = []
            elif isinstance(v.node.expr, self.ast.Slice):
                call_name = self._slice(v.node.expr, current_klass)
                method_name = attrname
                call_args = []
            else:
                raise TranslationError(
                    "unsupported type (in _callfunc)", v.node.expr, self.module_name)
        elif isinstance(v.node, self.ast.CallFunc):
            call_name = self._callfunc(v.node, current_klass)
            call_args = []
        elif isinstance(v.node, self.ast.Subscript):
            call_name = self._subscript(v.node, current_klass)
            call_args = []
        else:
            raise TranslationError(
                "unsupported type (in _callfunc)", v.node, self.module_name)

        if method_name in pyjs_attrib_remap:
            method_name = pyjs_attrib_remap[method_name]

        call_name = strip_py(call_name)

        kwargs = []
        star_arg_name = None
        if v.star_args:
            star_arg_name = self.expr(v.star_args, current_klass)
        dstar_arg_name = None
        if v.dstar_args:
            dstar_arg_name = self.expr(v.dstar_args, current_klass)

        for ch4 in v.args:
            if isinstance(ch4, self.ast.Keyword):
                kwarg = self.vars_remap(ch4.name) + ":" + \
                        self.expr(ch4.expr, current_klass)
                kwargs.append(kwarg)
            else:
                arg = self.expr(ch4, current_klass)
                call_args.append(arg)

        if kwargs:
            fn_args = ", ".join(['{' + ', '.join(kwargs) + '}']+call_args)
        else:
            fn_args = ", ".join(['{}']+call_args)

        if kwargs or star_arg_name or dstar_arg_name:
            if not star_arg_name:
                star_arg_name = 'null'
            if not dstar_arg_name:
                dstar_arg_name = 'null'
            if method_name is None:
                call_code = ("$pyjs_kwargs_call(null, "+call_name+", "
                                  + star_arg_name
                                  + ", " + dstar_arg_name
                                  + ", ["+fn_args+"]"
                                  + ")")
            else:
                call_code = ("$pyjs_kwargs_call("+call_name+", '"+method_name+"', "
                                  + star_arg_name
                                  + ", " + dstar_arg_name
                                  + ", ["+fn_args+"]"
                                  + ")")
        else:
            if not method_name is None:
                call_name = "%s['%s']" % (call_name, method_name)
            call_code = call_name + "(" + ", ".join(call_args) + ")"
        return call_code
dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/translator_proto.py/Translator._callfunc_code