Exemplo n.º 1
0
    @ExplodeLoop
    @Override
    public RubyArray executeArray(VirtualFrame frame) {
      CompilerDirectives.transferToInterpreter();

      final Object[] executedValues = new Object[values.length];

      for (int n = 0; n < values.length; n++) {
        executedValues[n] = values[n].execute(frame);
      }

      final RubyArray array =
          RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), executedValues);
      final Object store = array.getStore();

      if (store == null) {
        replace(new EmptyArrayLiteralNode(getContext(), getSourceSection(), values));
      }
      if (store instanceof int[]) {
        replace(new IntegerFixnumArrayLiteralNode(getContext(), getSourceSection(), values));
      } else if (store instanceof long[]) {
        replace(new LongFixnumArrayLiteralNode(getContext(), getSourceSection(), values));
      } else if (store instanceof double[]) {
        replace(new FloatArrayLiteralNode(getContext(), getSourceSection(), values));
      } else {
        replace(new ObjectArrayLiteralNode(getContext(), getSourceSection(), values));
      }

      return array;
    }
Exemplo n.º 2
0
  @Override
  public Object execute(VirtualFrame frame) {
    while (true) {
      try {
        final Object result = tryPart.execute(frame);
        elsePart.executeVoid(frame);
        return result;
      } catch (ControlFlowException exception) {
        controlFlowProfile.enter();

        throw exception;
      } catch (RuntimeException exception) {
        CompilerDirectives.transferToInterpreter();

        try {
          return handleException(frame, exception);
        } catch (RetryException e) {
          continue;
        }
      }
    }
  }