Package org.renjin.primitives.special

Source Code of org.renjin.primitives.special.RecallFunction

package org.renjin.primitives.special;

import org.renjin.eval.Context;
import org.renjin.eval.EvalException;
import org.renjin.sexp.*;

public class RecallFunction extends SpecialFunction {

  public RecallFunction() {
    super("Recall");
  }

  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call,
      PairList args) {
   
    // this is an .Internal function, so we need to go up one context.
    Context originalContext = context.getParent();
   
    Closure closure = originalContext.getClosure();
    if(closure == null) {
      throw new EvalException("Recall() must be called from within a closure");
    }
   
    PairList newArguments = (PairList)rho.getVariable(Symbols.ELLIPSES);
    FunctionCall newCall = new FunctionCall(originalContext.getCall().getFunction(), newArguments);
   
    return closure.apply(originalContext,
          originalContext.getEnvironment(),
          newCall,
          newArguments);
  }

 
 
}
TOP

Related Classes of org.renjin.primitives.special.RecallFunction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.