Class MemoryInstr
java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.MemoryInstr
- All Implemented Interfaces:
INode
Specialized IR instruction for memory operations (LOAD, STORE, ALLOCA, REFERENCE).
Memory instructions handle variable access, allocation, and reference declaration in the EK9 IR.
-
Method Summary
Modifier and TypeMethodDescriptionaddOperand(String operand) Add operand to this instruction.addOperands(String... operands) Add multiple operands to this instruction.static MemoryInstrfunctionInstance(String result, String functionType, DebugInfo debugInfo) Create FUNCTION_INSTANCE instruction with debug info: FUNCTION_INSTANCE result = FunctionType.static MemoryInstrCreate IS_NULL instruction with debug info: IS_NULL result = operand.static MemoryInstrCreate LOAD instruction: LOAD dest = source_location.static MemoryInstrCreate LOAD instruction with debug info: LOAD dest = source_location.static MemoryInstrloadConstant(String result, String constantName, String moduleName, String typeName, DebugInfo debugInfo) Create LOAD_CONSTANT instruction: load from module constant storage.static MemoryInstrloadField(String destination, String objectVar, String fieldName, String ownerType, String fieldType, DebugInfo debugInfo) Create LOAD_FIELD instruction: load field value from object.static MemoryInstrloadStaticField(String result, String fieldName, String ownerType, String fieldType, DebugInfo debugInfo) Create LOAD_STATIC_FIELD instruction: load static field from class.static MemoryInstrCreate REFERENCE instruction: REFERENCE variable_name, type_info.static MemoryInstrCreate REFERENCE instruction with debug info: REFERENCE variable_name, type_info.static MemoryInstrCreate RELEASE instruction: RELEASE object, decrement ARC.static MemoryInstrCreate RELEASE instruction with debug info: RELEASE object, decrement ARC.static MemoryInstrCreate RETAIN instruction with debug info: RETAIN object, i.e.static MemoryInstrCreate STORE instruction with debug info: STORE dest_location = source.static MemoryInstrstoreField(String objectVar, String fieldName, String ownerType, String fieldType, String value, DebugInfo debugInfo) Create STORE_FIELD instruction: store value into object field.static MemoryInstrstoreStaticField(String fieldName, String ownerType, String fieldType, String value, DebugInfo debugInfo) Create STORE_STATIC_FIELD instruction: store value into static field.static MemoryInstrtypedReference(String variableName, String typeInfo, DebugInfo debugInfo) Create TYPED_REFERENCE instruction: like REFERENCE but emits CHECKCAST after ACONST_NULL so ASM records the variable's type (not "Null") for correct stackmap frame computation.Methods inherited from class IRInstr
accept, equals, getDebugInfo, getEscapeMetaData, getOpcode, getOperands, getResult, hasEscapeMetaData, hashCode, hasResult, isControlFlow, isLabel, isMemoryManagement, isMethodCall, setEscapeMetaData, toString
-
Method Details
-
load
Create LOAD instruction: LOAD dest = source_location. -
load
Create LOAD instruction with debug info: LOAD dest = source_location. -
store
Create STORE instruction with debug info: STORE dest_location = source. -
loadField
public static MemoryInstr loadField(String destination, String objectVar, String fieldName, String ownerType, String fieldType, DebugInfo debugInfo) Create LOAD_FIELD instruction: load field value from object. Format: LOAD_FIELD dest = objectVar, fieldName, ownerType, fieldType- Parameters:
destination- variable to store the field valueobjectVar- variable containing the object referencefieldName- name of the field to accessownerType- fully qualified type that owns the fieldfieldType- fully qualified type of the fielddebugInfo- source location
-
storeField
public static MemoryInstr storeField(String objectVar, String fieldName, String ownerType, String fieldType, String value, DebugInfo debugInfo) Create STORE_FIELD instruction: store value into object field. Format: STORE_FIELD objectVar, fieldName, ownerType, fieldType, value- Parameters:
objectVar- variable containing the object referencefieldName- name of the field to store toownerType- fully qualified type that owns the fieldfieldType- fully qualified type of the fieldvalue- variable or temp containing the value to storedebugInfo- source location
-
reference
Create REFERENCE instruction: REFERENCE variable_name, type_info. -
reference
Create REFERENCE instruction with debug info: REFERENCE variable_name, type_info. -
typedReference
Create TYPED_REFERENCE instruction: like REFERENCE but emits CHECKCAST after ACONST_NULL so ASM records the variable's type (not "Null") for correct stackmap frame computation. Use when the variable participates in while-loop back-edges with branching control flow. -
retain
Create RETAIN instruction with debug info: RETAIN object, i.e. increment the ARC (automatic reference counting) -
release
Create RELEASE instruction: RELEASE object, decrement ARC. -
release
Create RELEASE instruction with debug info: RELEASE object, decrement ARC. -
isNull
Create IS_NULL instruction with debug info: IS_NULL result = operand. -
loadConstant
public static MemoryInstr loadConstant(String result, String constantName, String moduleName, String typeName, DebugInfo debugInfo) Create LOAD_CONSTANT instruction: load from module constant storage. Format: LOAD_CONSTANT result = constantName, moduleName, typeName- Parameters:
result- destination temp variableconstantName- the constant's field namemoduleName- the module where the constant is definedtypeName- the constant's fully qualified typedebugInfo- source location
-
loadStaticField
public static MemoryInstr loadStaticField(String result, String fieldName, String ownerType, String fieldType, DebugInfo debugInfo) Create LOAD_STATIC_FIELD instruction: load static field from class. Format: LOAD_STATIC_FIELD result = fieldName, ownerType, fieldTypeUsed for accessing static fields like enum constants (Colour.Red). Unlike LOAD_CONSTANT which assumes _Constants class, this loads from any class's static field.
- Parameters:
result- destination temp variablefieldName- the static field nameownerType- fully qualified type that owns the static fieldfieldType- fully qualified type of the fielddebugInfo- source location
-
storeStaticField
public static MemoryInstr storeStaticField(String fieldName, String ownerType, String fieldType, String value, DebugInfo debugInfo) Create STORE_STATIC_FIELD instruction: store value into static field. Format: STORE_STATIC_FIELD fieldName, ownerType, fieldType, valueUsed for initializing static fields like enum constants in c_init.
- Parameters:
fieldName- the static field nameownerType- fully qualified type that owns the static fieldfieldType- fully qualified type of the fieldvalue- variable holding the value to storedebugInfo- source location
-
functionInstance
Create FUNCTION_INSTANCE instruction with debug info: FUNCTION_INSTANCE result = FunctionType. Gets the singleton instance of the specified function type. -
addOperand
Description copied from class:IRInstrAdd operand to this instruction.- Overrides:
addOperandin classIRInstr
-
addOperands
Description copied from class:IRInstrAdd multiple operands to this instruction.- Overrides:
addOperandsin classIRInstr
-