Class ExpressionRecoverer


  • public class ExpressionRecoverer
    extends Object
    Converts SSA IR instructions to source Expression trees.
    • Constructor Detail

      • ExpressionRecoverer

        public ExpressionRecoverer​(RecoveryContext context)
        Creates a recoverer bound to a recovery context, with its own type recoverer.
        Parameters:
        context - the per-method recovery state
    • Method Detail

      • recover

        public Expression recover​(IRInstruction instr)
        Recovers the source expression an instruction produces.
        Parameters:
        instr - the instruction to translate
        Returns:
        the expression, or null when the instruction has no expression form
      • recoverOperand

        public Expression recoverOperand​(Value value)
        Recovers an operand with no type hint, so booleans are inferred from the value alone.
        Parameters:
        value - the operand to translate
        Returns:
        the expression for the operand
      • recoverOperand

        public Expression recoverOperand​(Value value,
                                         SourceType typeHint)
        Recovers an operand, using the hint to tell a boolean from an int constant.
        Parameters:
        value - the operand to translate
        typeHint - the expected type, or null
        Returns:
        the expression for the operand
      • inliningWouldReorderEffects

        public boolean inliningWouldReorderEffects​(SSAValue value)
        True when inlining a side-effecting definition at its use would move it past another side effect.
        Parameters:
        value - the candidate for inlining, may be null
        Returns:
        true if the value must take a name and stay where it is defined
      • operandInlinesSideEffect

        public boolean operandInlinesSideEffect​(Value value)
        True when recovering value as an operand would inline an allocation or call - a side effect that must not be duplicated by re-emitting the expression.
        Parameters:
        value - the operand to inspect
        Returns:
        true if recovering it as an operand would inline an allocation or call
      • operandMayThrowInline

        public boolean operandMayThrowInline​(Value value)
        True when recovering value as an operand would inline an operation that can throw at runtime.
        Parameters:
        value - the operand to inspect
        Returns:
        true if recovering it as an operand would inline an operation that can throw
      • recoverConstant

        public Expression recoverConstant​(Constant c,
                                          SourceType typeHint)
        Recovers a constant as a literal, using the hint to tell an int apart from a boolean or char.
        Parameters:
        c - the constant to recover
        typeHint - the expected source type, may be null
        Returns:
        the literal expression, or a null literal for an unrecognized constant