Class Operand

java.lang.Object
org.jruby.ir.operands.Operand
Direct Known Subclasses:
Array, BuiltinClass, CurrentScope, DynamicSymbol, Filename, Hash, ImmutableLiteral, IRException, Label, MutableString, Reference, Scope, ScopeModule, Splat, StandardError, SValue, UndefinedValue, Variable, WrappedIRClosure

public abstract class Operand extends Object
  • Field Details

    • EMPTY_ARRAY

      public static final Operand[] EMPTY_ARRAY
  • Constructor Details

    • Operand

      public Operand()
  • Method Details

    • getOperandType

      public abstract OperandType getOperandType()
    • hasKnownValue

      public boolean hasKnownValue()
      Do we know the value of this operand at compile-time? If we do then it may be possible to constant propagate (one case: We also know it is also an ImmutableLiteral).
      Returns:
      true if a known compile-time value.
    • canCopyPropagate

      public boolean canCopyPropagate()
      Can we replace every use of a variable 'v' that contains the value of this operand with the operand itself? This takes importance when there are at least two uses of 'v' within this scope. Ex: v = [1,2,3]; x = v; y = v In this case, we cannot replace the occurrences of 'v' because we would then get x = [1,2,3]; y = [1,2,3] which would then result in two different array objects being constructed instead of a single one.
      Returns:
      true if it is safe to copy-propagate the operand.
    • getSimplifiedOperand

      public Operand getSimplifiedOperand(Map<Operand,Operand> valueMap, boolean force)
    • getValue

      public Operand getValue(Map<Operand,Operand> valueMap)
    • isTruthyImmediate

      public boolean isTruthyImmediate()
      Returns true if this is an immediate value that will always be considered truthy (true, numbers, etc)
      Returns:
    • isFalseyImmediate

      public boolean isFalseyImmediate()
    • addUsedVariables

      public abstract void addUsedVariables(List<Variable> l)
      Append the list of variables used in this operand to the input list -- force every operand to implement this because a missing implementation can cause bad failures.
    • cloneForInlining

      public abstract Operand cloneForInlining(CloneInfo ii)
    • encode

      public void encode(IRWriterEncoder e)
    • retrieve

      public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp)
    • visit

      public void visit(IRVisitor visitor)