Exemplo n.º 1
0
  @Specialization
  protected Object doInternal(VirtualFrame frame, RPromise x) {
    if (builtinCallNode == null) {
      RNode call = (RNode) x.getRep();
      RNode operand = (RNode) RASTUtils.unwrap(call);

      if (!(operand instanceof RCallNode)) {
        errorProfile.enter();
        throw RError.error(this, RError.Message.INVALID_INTERNAL);
      }

      RCallNode callNode = (RCallNode) operand;
      RNode func = callNode.getFunctionNode();
      String name = ((ReadVariableNode) func).getIdentifier();
      RFunction function = RContext.lookupBuiltin(name);
      if (function == null
          || function.isBuiltin() && function.getRBuiltin().getKind() != RBuiltinKind.INTERNAL) {
        errorProfile.enter();
        if (function == null && notImplemented(name)) {
          throw RInternalError.unimplemented(".Internal " + name);
        }
        throw RError.error(this, RError.Message.NO_SUCH_INTERNAL, name);
      }

      // .Internal function is validated
      CompilerDirectives.transferToInterpreterAndInvalidate();
      builtinCallNode = insert(RCallNode.createInternalCall(callNode, function));
    }
    return builtinCallNode.execute(frame);
  }
Exemplo n.º 2
0
 @Specialization
 protected int doNArgs(VirtualFrame frame) {
   int result = 0;
   if (RArguments.getFunction(frame) == null) {
     return RRuntime.INT_NA;
   }
   int l = RArguments.getArgumentsLength(frame);
   for (int i = 0; i < l; i++) {
     Object arg = RArguments.getArgument(frame, i);
     if (arg instanceof RPromise) {
       isPromiseProfile.enter();
       RPromise promise = (RPromise) arg;
       if (!promise.isDefault()) {
         result++;
       }
     } else if (arg instanceof RArgsValuesAndNames) {
       result += ((RArgsValuesAndNames) arg).getLength();
     } else if (!(arg instanceof RMissing)) {
       result++;
     }
   }
   return result;
 }