Class ExtractLiteralOperand

java.lang.Object
org.ek9lang.compiler.support.ExtractLiteralOperand
All Implemented Interfaces:
Function<EK9Parser.ExpressionContext, EK9Parser.LiteralContext>

public final class ExtractLiteralOperand extends Object implements Function<EK9Parser.ExpressionContext, EK9Parser.LiteralContext>
Extracts the literal an expression resolves to, or null if it is not a (possibly negated) literal. A bare literal is returned directly; a unary-minus applied to a literal unwraps to that inner literal so that '-1' is recognised as a constant operand.

Shared by the constant-comparison and constant-coalescing checks, where the subtle unary-minus unwrap rule must stay in one place rather than being fixed in one copy and missed in another.