示例#1
0
文件: TryNode.java 项目: jruby/jruby
  @Override
  public Object execute(VirtualFrame frame) {
    while (true) {
      Object result;

      try {
        result = tryPart.execute(frame);
      } catch (RaiseException exception) {
        raiseExceptionProfile.enter();

        try {
          return handleException(frame, exception);
        } catch (RetryException e) {
          getContext().getSafepointManager().poll(this);
          continue;
        }
      } catch (ControlFlowException exception) {
        controlFlowProfile.enter();
        throw exception;
      }

      elseProfile.enter();

      if (elsePart != null) {
        result = elsePart.execute(frame);
      }

      return result;
    }
  }
示例#2
0
 public TaintResultNode(boolean taintFromSelf, int taintFromParameter, RubyNode method) {
   super(method.getContext(), method.getEncapsulatingSourceSection());
   this.taintFromSelf = taintFromSelf;
   this.taintFromParameter = taintFromParameter;
   this.method = method;
   this.isTaintedNode = IsTaintedNodeGen.create(getContext(), getSourceSection(), null);
 }
示例#3
0
  @Override
  public Object execute(VirtualFrame frame) {
    final DynamicObject result;

    try {
      result = method.executeDynamicObject(frame);
    } catch (DoNotTaint e) {
      return e.getResult();
    } catch (UnexpectedResultException e) {
      throw new UnsupportedOperationException(e);
    }

    if (result != nil()) {
      if (taintFromSelf) {
        maybeTaint((DynamicObject) RubyArguments.getSelf(frame.getArguments()), result);
      }

      // It's possible the taintFromParameter value was misconfigured by the user, but the far more
      // likely
      // scenario is that the argument at that position is a NotProvided argument, which doesn't
      // take up
      // a space in the frame.
      if (taintFromParameter < RubyArguments.getArgumentsCount(frame.getArguments())) {
        final Object argument = RubyArguments.getArgument(frame.getArguments(), taintFromParameter);

        if (argument instanceof DynamicObject) {
          final DynamicObject taintSource = (DynamicObject) argument;
          maybeTaint(taintSource, result);
        }
      }
    }

    return result;
  }
示例#4
0
 @Override
 public Object execute(VirtualFrame frame) {
   try {
     return body.execute(frame);
   } catch (RetryException e) {
     CompilerDirectives.transferToInterpreter();
     throw new RaiseException(getContext().getCoreLibrary().syntaxError("Invalid retry", this));
   }
 }
  public Object execute(VirtualFrame frame) {
    final Object childValue = child.execute(frame);

    if (!(RubyGuards.isRubyString(childValue)) && childValue != nil()) {
      CompilerDirectives.transferToInterpreter();
      throw new RaiseException(getContext().getCoreLibrary().typeErrorMustBe("$/", "String", this));
    }

    return childValue;
  }
  @Override
  public void executeVoid(VirtualFrame frame) {
    final Object value = primitive.execute(frame);

    if (primitiveSucceededCondition.profile(value != null)) {
      // If the primitive didn't fail its value is returned in the calling method

      throw new ReturnException(returnID, value);
    }

    // Primitives may return null to indicate that they have failed, in which case we continue with
    // the fallback
  }
示例#7
0
  @Override
  public Object execute(VirtualFrame frame) {
    final DynamicObject module = (DynamicObject) definingModule.execute(frame);
    final InternalMethod definition =
        prepareLexicalScope(module, definitionMethod.executeMethod(frame));

    return callModuleDefinitionNode.call(
        frame,
        definition.getCallTarget(),
        RubyArguments.pack(
            null,
            null,
            definition,
            DeclarationContext.MODULE,
            null,
            module,
            null,
            new Object[] {}));
  }
示例#8
0
  public CallTarget compile(String format) {
    if (format.length() > context.getOptions().PACK_RECOVER_LOOP_MIN) {
      format = LoopRecovery.recoverLoop(format);
    }

    final SimpleUnpackTreeBuilder builder = new SimpleUnpackTreeBuilder(context, currentNode);

    builder.enterSequence();

    final SimplePackParser parser =
        new SimplePackParser(builder, format.getBytes(StandardCharsets.US_ASCII));
    parser.parse();

    builder.exitSequence();

    return Truffle.getRuntime()
        .createCallTarget(
            new UnpackRootNode(
                context, currentNode.getEncapsulatingSourceSection(), builder.getNode()));
  }
 public void executeVoid(VirtualFrame frame) {
   value.executeVoid(frame);
   CompilerDirectives.transferToInterpreter();
   throw new RaiseException(getContext().getCoreLibrary().nameErrorReadOnly(name, this));
 }