Package org.renjin.eval

Examples of org.renjin.eval.EvalException


    } else if(source instanceof PairList) {
      return getSingleVectorElement(((PairList) source).toVector(), subscript, exact);
    } else if(source instanceof Vector) {
      return getSingleVectorElement((Vector)source, subscript, exact);
    }
    throw new EvalException("object of type '%s' is not subsettable", source.getTypeName());
  }
View Full Code Here


 
  private Object eval(Context context, SEXP source) {
    try {
      return context.evaluate( source, context.getEnvironment());
    } catch(BreakException e) {
      throw new EvalException("no loop for break");
    } catch(NextException e) {
      throw new EvalException("no loop for next");

    }
  }
View Full Code Here

    } else if(source instanceof Vector) {
      return getSubset((Vector)source, subscripts, drop);

    } else {
      throw new EvalException("invalid source");
    }
  }
View Full Code Here

  @Internal
  public static boolean identical(SEXP x, SEXP y, boolean numericallyEqual,
      boolean singleNA, boolean attributesAsSet, boolean ignoreByteCode) {
    if (!attributesAsSet) {
      throw new EvalException(
          "identical implementation only supports attrib.as.set = TRUE");
    }

    return identical(x,y, !numericallyEqual, !singleNA);
  }
View Full Code Here

      if(formatters[0].isFormattedString(i) && !(argument instanceof StringVector)) {
        argument = context.evaluate( FunctionCall.newCall(Symbol.get("as.character"), argument),
            rho);
      }
      if(!(argument instanceof AtomicVector)) {
        throw new EvalException("Format argument %d is not an atomic vector", i);
      }
      formatArgs[i] = (AtomicVector)argument;
    }
   
    // count cycles
View Full Code Here

  @Internal
  public static Vector agrep(String pattern, StringVector x,  boolean ignoreCase, boolean value,
                              Vector costs, Vector bounds, boolean useBytes, boolean fixed) {

    if(!fixed) {
      throw new EvalException("fixed = FALSE not impelmented for agrep.");
    }
 
    int maxDistance = maxDistance(bounds, pattern);
   
    FuzzyMatcher matcher = new FuzzyMatcher(pattern, ignoreCase);
View Full Code Here

  }
 
  private static int maxDistance(Vector bounds, String pattern) {

    if(bounds.length() != 5) {
      throw new EvalException("Expected bounds argument of length 5");
    }
    if(!bounds.isElementNA(1) || !bounds.isElementNA(2) || !bounds.isElementNA(3) ||
       !bounds.isElementNA(4)) {
      throw new EvalException("max distance with specific components (all, insertions, deletions, substitutions not implemented");
    }
    double maxDistance = bounds.getElementAsDouble(0);
    if(maxDistance < 1) {
      maxDistance = maxDistance * pattern.length();
    }
View Full Code Here

            
              // TODO: not sure how to handle fractional seconds here
              builder.appendSecondOfMinute(2);
              break;
            default:
              throw new EvalException("%O[dHImMUVwWy] not yet implemented");
             
            }
          }
          break;
        case 'S':
          // Second as decimal number (00-61), allowing for up to two
          // leap-seconds (but POSIX-complaint implementations will ignore
          // leap seconds).
          // TODO: I have no idea what the docs are talking about in relation
          // to leap seconds
          builder.appendSecondOfDay(2);
          break;
          // case 'U':
          // Week of the year as decimal number (00-53) using Sunday as
          // the first day 1 of the week (and typically with the first
          //  Sunday of the year as day 1 of week 1).  The US convention.
          // case 'w':
          // Weekday as decimal number (0-6, Sunday is 0).

          // case 'W':
          // Week of the year as decimal number (00-53) using Monday as
          // the first day of week (and typically with the first Monday of
          // the year as day 1 of week 1). The UK convention.
        
          // ‘%x’ Date.  Locale-specific on output, ‘"%y/%m/%d"’ on input.

        
          //‘%X’ Time.  Locale-specific on output, ‘"%H:%M:%S"’ on input.

        case 'y':
          // Year without century (00-99). Values 00 to 68 are prefixed by
          // 20 and 69 to 99 by 19 - that is the behaviour specified by
          // the 2004 POSIX standard, but it does also say ‘it is expected
          // that in a future version the default century inferred from a
          // 2-digit year will change’.
          builder.appendTwoDigitYear(1968, true);
          break;
        case 'Y':
          // Year with century
          builder.appendYear(1,4);
          break;
        case 'z':
          // Signed offset in hours and minutes from UTC, so ‘-0800’ is 8
          // hours behind UTC.
          builder.appendTimeZoneOffset(null /* always show offset, even when zero */,
              true /* show seperators */,
              1 /* min fields (hour, minute, etc) */,
              2 /* max fields */ );
          break;
        case 'Z':
          // (output only.) Time zone as a character string (empty if not
          // available).
          builder.appendTimeZoneName();
          break;
        default:
          throw new EvalException("%" + specifier + " not yet implemented. (Implement me!)");
        }
      } else {
        builder.appendLiteral(patterns.substring(i,i+1));
      }
    }
View Full Code Here

  }

  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call, PairList args) {
    if(call.length() < 1) {
      throw new EvalException("first argument must be character string");
    }
    SEXP name = context.evaluate(call.getArgument(0), rho);
    if(!(name instanceof StringVector) || name.length() != 1) {
      throw new EvalException("first argument must be character string");
    }

    return new FunctionCall(Symbol.get(((StringVector) name).getElementAsString(0)),
        ((PairList.Node)call.getArguments()).getNextNode());
  }
View Full Code Here

      } else if(input instanceof ListVector) {
        SEXP element = ((ListVector) input).getElementAsSEXP(index % input.length());
        return listElementToString(element);

      } else {
        throw new EvalException(String.format("Cannot coerce argument of type '%s' to character.",
            input.getTypeName()));
      }
    }
View Full Code Here

TOP

Related Classes of org.renjin.eval.EvalException

Copyright © 2018 www.massapicom. 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.