예제 #1
0
  @Test
  public void namedEllipsesToBuiltin() {
    ListVector x = (ListVector) eval("list(... = 1, b = 2, 3) ");

    assertThat(x.length(), equalTo(3));
    assertThat(x.getNames().getElementAsString(0), equalTo("..."));
    assertThat(x.getNames().getElementAsString(1), equalTo("b"));
  }
예제 #2
0
 @Override
 public SEXP getVariable(Symbol name) {
   int index = list.getIndexByName(name.getPrintName());
   if (index == -1) {
     return Symbol.UNBOUND_VALUE;
   } else {
     return list.getElementAsSEXP(index);
   }
 }
예제 #3
0
 @Override
 public void visit(ListVector list) {
   ListVector.Builder builder = ListVector.newBuilder();
   for (SEXP exp : list) {
     builder.add(substitute(exp));
   }
   builder.copyAttributesFrom(list);
   result = builder.build();
 }
예제 #4
0
파일: Files.java 프로젝트: prasaadk/renjin
  /**
   * Utility function to extract information about files on the user's file systems.
   *
   * @param context current call Context
   * @param paths the list of files for which to return information
   * @return list column-oriented table of file information
   * @throws FileSystemException
   */
  @Internal("file.info")
  public static ListVector fileInfo(@Current Context context, StringVector paths)
      throws FileSystemException {

    DoubleArrayVector.Builder size = new DoubleArrayVector.Builder();
    LogicalArrayVector.Builder isdir = new LogicalArrayVector.Builder();
    IntArrayVector.Builder mode =
        (IntArrayVector.Builder)
            new IntArrayVector.Builder()
                .setAttribute(Symbols.CLASS, StringVector.valueOf("octmode"));
    DoubleArrayVector.Builder mtime = new DoubleArrayVector.Builder();
    StringVector.Builder exe = new StringVector.Builder();

    for (String path : paths) {
      if (StringVector.isNA(path)) {
        throw new EvalException("invalid filename argument");
      }
      FileObject file = context.resolveFile(path);
      if (file.exists()) {
        if (file.getType() == FileType.FILE) {
          size.add((int) file.getContent().getSize());
        } else {
          size.add(0);
        }
        isdir.add(file.getType() == FileType.FOLDER);
        mode.add(mode(file));
        try {
          mtime.add(file.getContent().getLastModifiedTime());
        } catch (Exception e) {
          mtime.add(0);
        }
        exe.add(file.getName().getBaseName().endsWith(".exe") ? "yes" : "no");
      } else {
        size.addNA();
        isdir.addNA();
        mode.addNA();
        mtime.addNA();
        exe.addNA();
      }
    }

    return ListVector.newNamedBuilder()
        .add("size", size)
        .add("isdir", isdir)
        .add("mode", mode)
        .add("mtime", mtime)
        .add("ctime", mtime)
        .add("atime", mtime)
        .add("exe", exe)
        .build();
  }
예제 #5
0
파일: System.java 프로젝트: prasaadk/renjin
 @Internal
 public static ListVector Version() {
   // this is just copied from my local R installation
   // we'll have to see later what makes the most sense to put here,
   // whether we need to pretend to be some version of R
   return ListVector.newNamedBuilder()
       .add("platform", "i386-pc-mingw32")
       .add("arch", "i386")
       .add("os", "mingw32")
       .add("system", "i386, mingw32")
       .add("status", "")
       .add("major", RVersion.MAJOR)
       .add("minor", RVersion.MINOR)
       .add("year", "2009")
       .add("month", "12")
       .add("day", "14")
       .add("language", "R")
       .add("svn rev", "50720")
       .add(
           "version.string", "R version " + RVersion.MAJOR + "." + RVersion.MINOR + "(2009-12-14)")
       .build();
 }
예제 #6
0
 public Builder addAll(ListVector list) {
   for (NamedValue namedValue : list.namedValues()) {
     add(namedValue.getName(), namedValue.getValue());
   }
   return this;
 }
예제 #7
0
 @Override
 public boolean hasVariable(Symbol name) {
   return list.getIndexByName(name.getPrintName()) != -1;
 }