private PairList unpackPromiseList(PromisePairList dotExp) {
   PairList.Builder unpacked = new PairList.Node.Builder();
   for (PairList.Node node : dotExp.nodes()) {
     unpacked.add(node.getRawTag(), unpromise(node.getValue()));
   }
   return unpacked.build();
 }
 private PairList substituteArgumentList(PairList arguments) {
   PairList.Builder builder = PairList.Node.newBuilder();
   for (PairList.Node node : arguments.nodes()) {
     if (node.getValue().equals(Symbols.ELLIPSES)) {
       SEXP extraArguments = context.getVariable(Symbols.ELLIPSES);
       if (extraArguments != Symbol.UNBOUND_VALUE) {
         builder.addAll(unpackPromiseList((PromisePairList) extraArguments));
       } else {
         builder.add(Symbols.ELLIPSES);
       }
     } else {
       builder.add(node.getRawTag(), substitute(node.getValue()));
     }
   }
   return builder.build();
 }
 @Override
 public void visit(PairList.Node pairList) {
   PairList.Builder builder = PairList.Node.newBuilder();
   for (PairList.Node node : pairList.nodes()) {
     builder.add(node.getRawTag(), substitute(node.getValue()));
   }
   result = builder.build();
 }
Beispiel #4
0
 /**
  * Replaces the
  *
  * @param index
  * @param value
  * @return
  */
 public Builder set(int index, SEXP value) {
   if (index < 0) {
     throw new IndexOutOfBoundsException("index must be > 0");
   }
   if (head == null) {
     add(Null.INSTANCE);
   }
   Node node = head;
   int nodeIndex = 0;
   while (nodeIndex != index) {
     if (node.nextNode == Null.INSTANCE) {
       add(Null.INSTANCE);
     }
     node = node.getNextNode();
     nodeIndex++;
   }
   node.setValue(value);
   return this;
 }
  private SEXP R_S_MethodsListSelect(Context context, SEXP fname, SEXP ev, SEXP mlist, SEXP f_env) {
    PairList.Builder args = new PairList.Builder();
    args.add(fname);
    args.add(ev);
    args.add(mlist);
    if (f_env != Null.INSTANCE) {
      args.add(f_env);
    }

    try {
      return context.evaluate(
          new FunctionCall(s_MethodsListSelect, args.build()), methodsNamespace);
    } catch (EvalException e) {
      throw new EvalException(
          String.format(
              "S language method selection got an error when called from"
                  + " internal dispatch for function '%s'",
              fname),
          e);
    }
  }
Beispiel #6
0
 public Builder addAll(ListVector list) {
   for (NamedValue namedValue : list.namedValues()) {
     add(namedValue.getName(), namedValue.getValue());
   }
   return this;
 }
Beispiel #7
0
 public Builder addAll(PairList list) {
   for (Node node : list.nodes()) {
     add(node.getRawTag(), node.getValue());
   }
   return this;
 }