public static Cons javaTranslateFunctionCall(Cons tree, MethodSlot method) {
    tree = tree.rest;
    { Symbol functionname = ((Symbol)(tree.value));
      Cons functionargs = Cons.copyConsList(tree.rest);
      Stella_Object firstarg = functionargs.value;
      MethodSlot function = ((method != null) ? method : Symbol.lookupFunction(functionname));
      Cons operator = Symbol.javaLookupOperatorTable(functionname.softPermanentify());
      Cons otree = null;

      if ((functionname == Stella.SYM_STELLA_GET_SYM) &&
          Stella_Object.isaP(firstarg, Stella.SGT_STELLA_INTEGER_WRAPPER)) {
        return (Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_SYMBOL, Cons.cons(Symbol.getSym(((IntegerWrapper)(firstarg)).wrapperValue), Cons.cons(Stella.NIL, Stella.NIL)))));
      }
      else if ((functionname == Stella.SYM_STELLA_GET_KWD) &&
          Stella_Object.isaP(firstarg, Stella.SGT_STELLA_INTEGER_WRAPPER)) {
        return (Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_SYMBOL, Cons.cons(Keyword.getKwd(((IntegerWrapper)(firstarg)).wrapperValue), Cons.cons(Stella.NIL, Stella.NIL)))));
      }
      else if ((functionname == Stella.SYM_STELLA_GET_SGT) &&
          Stella_Object.isaP(firstarg, Stella.SGT_STELLA_INTEGER_WRAPPER)) {
        return (Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_SYMBOL, Cons.cons(Surrogate.getSgt(((IntegerWrapper)(firstarg)).wrapperValue), Cons.cons(Stella.NIL, Stella.NIL)))));
      }
      if (operator != null) {
        otree = Cons.javaTranslateOperatorCall(operator, functionargs, functionargs.length());
      }
      else if (function == null) {
        Stella.STANDARD_WARNING.nativeStream.println("Warning: Can't translate function call: Undefined function or method `" + functionname + "'");
        otree = Stella.NIL;
      }
      else {
        { Object old$Varargstatements$000 = Stella.$VARARGSTATEMENTS$.get();

          try {
            Native.setSpecial(Stella.$VARARGSTATEMENTS$, Stella.NIL);
            { Cons actuals = (((BooleanWrapper)(KeyValueList.dynamicSlotValue(function.dynamicSlots, Stella.SYM_STELLA_METHOD_VARIABLE_ARGUMENTSp, Stella.FALSE_WRAPPER))).wrapperValue ? Cons.javaTranslateVariableLengthActuals(functionargs, function) : Cons.javaTranslateActualParameters(functionargs));

              if (!((function.methodReturnTypeSpecifiers().rest() == Stella.NIL) ||
                  ((actuals.length() - 1) > function.methodParameterNames().length()))) {
                actuals = actuals.concatenate(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_MAKE_ARRAY, Cons.cons(StandardObject.javaTranslateTypeSpec(Stella.SGT_STELLA_NATIVE_OBJECT_POINTER), Cons.cons(Cons.cons(IntegerWrapper.wrapInteger(function.methodReturnTypeSpecifiers().length() - 1), Stella.NIL), Stella.NIL)))), Stella.NIL), Stella.NIL);
              }
              otree = Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_FUNCTION_CALL, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_IDENT, Cons.cons(StringWrapper.wrapString(MethodSlot.javaYieldClassNameForFunction(function)), Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_JAVA_IDENT, Cons.cons(MethodSlot.javaTranslateFunctionName(function), Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(actuals, Cons.cons(Stella.NIL, Stella.NIL))))));
              if (!(((Cons)(Stella.$VARARGSTATEMENTS$.get())) == Stella.NIL)) {
                otree = Cons.javaWrapMethodBodyWithVarargValueSetup(otree);
              }
            }

          } finally {
            Stella.$VARARGSTATEMENTS$.set(old$Varargstatements$000);
          }
        }
      }
      return (otree);
    }
  }