@Override
 public void visit(FunctionCall call) {
   result =
       new FunctionCall(
           substitute(call.getFunction()),
           substituteArgumentList(call.getArguments()),
           call.getAttributes());
 }
 @Override
 public void visit(FunctionCall call) {
   if (includeFunctionNames) {
     call.getFunction().accept(this);
   }
   for (SEXP expr : call.getArguments().values()) {
     expr.accept(this);
   }
 }
Exemple #3
0
  /**
   * Executes the default the standard R initialization sequence:
   *
   * <ol>
   *   <li>Load the base package (/org/renjin/library/base/R/base)
   *   <li>Execute the system profile (/org/renjin/library/base/R/Rprofile)
   *   <li>Evaluate .OptRequireMethods()
   *   <li>Evaluate .First.Sys()
   * </ol>
   */
  public void init() throws IOException {
    BaseFrame baseFrame = (BaseFrame) session.getBaseEnvironment().getFrame();
    baseFrame.load(this);

    evaluate(FunctionCall.newCall(Symbol.get(".onLoad")), session.getBaseNamespaceEnv());

    //    evalBaseResource("/org/renjin/library/base/R/Rprofile");
    //
    //    // FunctionCall.newCall(new Symbol(".OptRequireMethods")).evaluate(this, environment);
    //    evaluate( FunctionCall.newCall(Symbol.get(".First.sys")), environment);
  }
  private static SEXP R_loadMethod(Context context, SEXP def, String fname, Environment ev) {

    /* since this is called every time a method is dispatched with a
    definition that has a class, it should be as efficient as
    possible => we build in knowledge of the standard
    MethodDefinition and MethodWithNext slots.  If these (+ the
    class slot) don't account for all the attributes, regular
    dispatch is done. */
    int found = 1; /* we "know" the class attribute is there */

    found++; // we also have our fake __S4_BIt for renjin

    PairList attrib = def.getAttributes().asPairList();
    for (PairList.Node s : attrib.nodes()) {
      SEXP t = s.getTag();
      if (t == R_target) {
        ev.setVariable(R_dot_target, s.getValue());
        found++;
      } else if (t == R_defined) {
        ev.setVariable(R_dot_defined, s.getValue());
        found++;
      } else if (t == R_nextMethod) {
        ev.setVariable(R_dot_nextMethod, s.getValue());
        found++;
      } else if (t == Symbols.SOURCE) {
        /* ignore */ found++;
      }
    }
    ev.setVariable(R_dot_Method, def);

    /* this shouldn't be needed but check the generic being
    "loadMethod", which would produce a recursive loop */
    if (fname.equals("loadMethod")) {
      return def;
    }
    if (found < attrib.length()) {
      FunctionCall call =
          FunctionCall.newCall(R_loadMethod_name, def, StringArrayVector.valueOf(fname), ev);
      return context.evaluate(call, ev);

      //      SEXP e, val;
      //      PROTECT(e = allocVector(LANGSXP, 4));
      //      SETCAR(e, R_loadMethod_name); val = CDR(e);
      //      SETCAR(val, def); val = CDR(val);
      //      SETCAR(val, fname); val = CDR(val);
      //      SETCAR(val, ev);
      //      val = eval(e, ev);
      //      return val;
    } else {
      return def;
    }
  }
Exemple #5
0
 public SEXP getFunctionName() {
   return call.getFunction();
 }
Exemple #6
0
 private SEXP evaluateCall(FunctionCall call, Environment rho) {
   clearInvisibleFlag();
   Function functionExpr = evaluateFunction(call.getFunction(), rho);
   return functionExpr.apply(this, rho, call, call.getArguments());
 }
  private SEXP do_inherited_table(
      Context context, SEXP class_objs, SEXP fdef, SEXP mtable, Environment ev) {
    SEXP fun = methodsNamespace.findFunction(context, Symbol.get(".InheritForDispatch"));

    return context.evaluate(FunctionCall.newCall(fun, class_objs, fdef, mtable), ev);
  }