Class LiteralInstruction
java.lang.Object
org.ek9lang.compiler.ir.IRInstruction
org.ek9lang.compiler.ir.LiteralInstruction
- All Implemented Interfaces:
INode
IR instruction for loading literal/constant values.
Handles string literals, numeric literals, boolean literals, etc.
Uses symbol-driven approach to get correct type information.
-
Method Summary
Modifier and TypeMethodDescriptionstatic LiteralInstruction
booleanLiteral
(String result, String literalValue, String literalType) static LiteralInstruction
booleanLiteral
(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a boolean literal.Get the literal type (could be decorated for generic contexts).Get the literal value.static LiteralInstruction
static LiteralInstruction
Create instruction to load any literal value.static LiteralInstruction
numericLiteral
(String result, String literalValue, String literalType) static LiteralInstruction
numericLiteral
(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a numeric literal.static LiteralInstruction
stringLiteral
(String result, String literalValue, String literalType) static LiteralInstruction
stringLiteral
(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a string literal.toString()
Methods inherited from class org.ek9lang.compiler.ir.IRInstruction
accept, addOperand, addOperands, equals, getDebugInfo, getOpcode, getOperands, getResult, hashCode, hasResult, isControlFlow, isMemoryManagement, isMethodCall
-
Method Details
-
stringLiteral
public static LiteralInstruction stringLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a string literal.- Parameters:
result
- Variable to store the literal valueliteralValue
- The actual string value (including quotes)literalType
- The resolved type name (could be decorated for generic contexts)debugInfo
- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for loading string literal
-
numericLiteral
public static LiteralInstruction numericLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a numeric literal.- Parameters:
result
- Variable to store the literal valueliteralValue
- The numeric value as stringliteralType
- The resolved type name (Integer, Float, etc.)debugInfo
- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for loading numeric literal
-
booleanLiteral
public static LiteralInstruction booleanLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a boolean literal.- Parameters:
result
- Variable to store the literal valueliteralValue
- The boolean value as string ("true" or "false")literalType
- The resolved type name (typically "Boolean")debugInfo
- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for loading boolean literal
-
literal
public static LiteralInstruction literal(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load any literal value.- Parameters:
result
- Variable to store the literal valueliteralValue
- The literal value as stringliteralType
- The resolved type name (could be decorated)debugInfo
- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for loading the literal
-
stringLiteral
public static LiteralInstruction stringLiteral(String result, String literalValue, String literalType) -
numericLiteral
public static LiteralInstruction numericLiteral(String result, String literalValue, String literalType) -
booleanLiteral
public static LiteralInstruction booleanLiteral(String result, String literalValue, String literalType) -
literal
-
getLiteralValue
Get the literal value. -
getLiteralType
Get the literal type (could be decorated for generic contexts). -
toString
- Overrides:
toString
in classIRInstruction
-