Class LiteralInstr
java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.LiteralInstr
- 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 TypeMethodDescriptionGet the literal type (could be decorated for generic contexts).Get the literal value.static LiteralInstrobjectFromLiteral(String result, String literalValue, String literalType) static LiteralInstrobjectFromLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a literal value as an EK9 object.static PrimitiveLiteralInstrprimitiveFromLiteral(String result, String literalValue, String primitiveType, DebugInfo debugInfo) Create instruction to load a literal value as a primitive (int, boolean, java.lang.String).Methods inherited from class IRInstr
accept, addOperand, addOperands, equals, getDebugInfo, getEscapeMetaData, getOpcode, getOperands, getResult, hasEscapeMetaData, hashCode, hasResult, isControlFlow, isLabel, isMemoryManagement, isMethodCall, setEscapeMetaData, toString
-
Method Details
-
objectFromLiteral
public static LiteralInstr objectFromLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo) Create instruction to load a literal value as an EK9 object.This creates an actual EK9 object (Integer, String, Boolean, etc.) from the literal representation - not a raw primitive value.
- Parameters:
result- Variable to store the created objectliteralValue- The literal value as stringliteralType- The resolved type name (could be decorated)debugInfo- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for creating the object from literal
-
objectFromLiteral
public static LiteralInstr objectFromLiteral(String result, String literalValue, String literalType) -
primitiveFromLiteral
public static PrimitiveLiteralInstr primitiveFromLiteral(String result, String literalValue, String primitiveType, DebugInfo debugInfo) Create instruction to load a literal value as a primitive (int, boolean, java.lang.String).This creates a raw primitive value - not an EK9 object. Used for: - int: Java primitive int - boolean: Java primitive boolean - java.lang.String: Java String object (not EK9 String)
The LOAD_PRIMITIVE opcode signals the bytecode generator to use primitive literal loading (BIPUSH/SIPUSH/LDC for int, ICONST_0/1 for boolean, LDC for String) instead of creating EK9 wrapper objects.
- Parameters:
result- Variable to store the primitive valueliteralValue- The literal value as stringprimitiveType- The primitive type name ("int", "boolean", "java.lang.String")debugInfo- Debug information for source mapping (can be null)- Returns:
- LiteralInstruction for loading the primitive value
-
getLiteralValue
Get the literal value. -
getLiteralType
Get the literal type (could be decorated for generic contexts).
-