BoxInstr.java

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

  2. import org.jruby.ir.Operation;
  3. import org.jruby.ir.instructions.Instr;
  4. import org.jruby.ir.instructions.ResultInstr;
  5. import org.jruby.ir.operands.Operand;
  6. import org.jruby.ir.operands.Variable;

  7. public abstract class BoxInstr extends Instr implements ResultInstr {
  8.     private Variable result;
  9.     private Operand val;

  10.     public BoxInstr(Operation op, Variable result, Operand val) {
  11.         super(op);
  12.         this.result = result;
  13.         this.val = val;
  14.     }

  15.     public Operand[] getOperands() {
  16.         return new Operand[]{val};
  17.     }

  18.     public Variable getResult() {
  19.         return result;
  20.     }

  21.     public void updateResult(Variable v) {
  22.         this.result = v;
  23.     }

  24.     public Operand getValue() {
  25.         return val;
  26.     }

  27.     @Override
  28.     public String toString() {
  29.         return getResult() + " = " + getOperation() + "(" + val + ")";
  30.     }
  31. }