OneOperandArgNoBlockCallInstr.java

  1. package org.jruby.ir.instructions.specialized;

  2. import org.jruby.ir.IRVisitor;
  3. import org.jruby.ir.Operation;
  4. import org.jruby.ir.instructions.CallInstr;
  5. import org.jruby.ir.instructions.Instr;
  6. import org.jruby.ir.operands.Operand;
  7. import org.jruby.ir.operands.Variable;
  8. import org.jruby.ir.transformations.inlining.CloneInfo;
  9. import org.jruby.parser.StaticScope;
  10. import org.jruby.runtime.CallType;
  11. import org.jruby.runtime.DynamicScope;
  12. import org.jruby.runtime.ThreadContext;
  13. import org.jruby.runtime.builtin.IRubyObject;

  14. public class OneOperandArgNoBlockCallInstr extends CallInstr {
  15.     public OneOperandArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
  16.         super(Operation.CALL_1O, CallType.NORMAL, result, name, receiver, args, null);
  17.     }

  18.     @Override
  19.     public Instr clone(CloneInfo ii) {
  20.         return new OneOperandArgNoBlockCallInstr(ii.getRenamedVariable(result), getName(), receiver.cloneForInlining(ii),
  21.                 cloneCallArgs(ii));
  22.     }

  23.     @Override
  24.     public String toString() {
  25.         return super.toString() + "{1O}";
  26.     }

  27.     public Operand getArg1() {
  28.         return getCallArgs()[0];
  29.     }

  30.     @Override
  31.     public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
  32.         IRubyObject object = (IRubyObject) receiver.retrieve(context, self, currScope, dynamicScope, temp);
  33.         IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, currScope, dynamicScope, temp);
  34.         return getCallSite().call(context, self, object, arg1);
  35.     }

  36.     @Override
  37.     public void visit(IRVisitor visitor) {
  38.         visitor.OneOperandArgNoBlockCallInstr(this);
  39.     }
  40. }