コード例 #1
0
 static String toString(Iterable<SEXP> args) {
   StringBuilder list = new StringBuilder();
   for (SEXP arg : args) {
     if (arg == null) {
       break;
     }
     if (list.length() > 0) {
       list.append(", ");
     }
     list.append(arg.getTypeName());
   }
   return list.toString();
 }
コード例 #2
0
ファイル: Context.java プロジェクト: fosterac/renjin
 private Function evaluateFunction(SEXP functionExp, Environment rho) {
   if (functionExp instanceof Symbol) {
     Symbol symbol = (Symbol) functionExp;
     Function fn = rho.findFunction(this, symbol);
     if (fn == null) {
       throw new EvalException("could not find function '%s'", symbol.getPrintName());
     }
     return fn;
   } else {
     SEXP evaluated = evaluate(functionExp, rho).force(this);
     if (!(evaluated instanceof Function)) {
       throw new EvalException(
           "'function' of lang expression is of unsupported type '%s'", evaluated.getTypeName());
     }
     return (Function) evaluated;
   }
 }
コード例 #3
0
  private static SubstituteContext buildContext(Context context, SEXP evaluatedEnv) {
    if (evaluatedEnv instanceof Environment) {
      if (context.getGlobalEnvironment() == evaluatedEnv) {
        return new GlobalEnvironmentContext();
      } else {
        return new EnvironmentContext((Environment) evaluatedEnv);
      }
    } else if (evaluatedEnv instanceof ListVector) {
      return new ListContext((ListVector) evaluatedEnv);
    } else if (evaluatedEnv instanceof PairList) {
      return new PairListContext((PairList) evaluatedEnv);

    } else {
      throw new EvalException(
          "Cannot substitute using environment of type %s: expected list, pairlist, or environment",
          evaluatedEnv.getTypeName());
    }
  }