Class OwnershipInstr
java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.OwnershipInstr
- All Implemented Interfaces:
INode
The ownership form of the IR (EK9_IR_OWNERSHIP_MODEL.md ยง10):
OWN, DROP, DROP_AT_EXIT,
SLOT_DECLARE, SLOT_ASSIGN, FIELD_ASSIGN. Ownership is stated per value, slot and field, so
nothing is implied by the position of a RETAIN. No back end reads these: OwnershipLowering rewrites
them into today's opcodes at the end of IR_OPTIMISATION.
Rendering follows every other instruction - OPCODE operand, operand - with the facts that are not operands
appended in brackets: SLOT_ASSIGN total, _temp4 [consume, init].
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow a slot or field assignment takes its value. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe owner of a parameter or the return variable: the CALLER.static final intAfieldAssign(String, String, String, String, String, int, OwnershipInstr.AssignMode, boolean, DebugInfo)whose field is stored without an index (STORE_FIELD's look-up-by-name form).static final StringThe owner of a property: the OBJECT that holds it, which drops it when the object is destroyed. -
Method Summary
Modifier and TypeMethodDescriptionstatic OwnershipInstrDROP value: the end of an OWNED value on this path (lowered:RELEASE).static OwnershipInstrdropAtExit(String value, String scopeId, DebugInfo debugInfo) DROP_AT_EXIT value, scope: the end of an OWNED value at every exit of the scope's current activation (lowered:SCOPE_REGISTER).booleanstatic OwnershipInstrfieldAssign(String objectVar, String fieldName, String ownerType, String fieldType, String value, int fieldIndex, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) FIELD_ASSIGN object, field, ownerType, fieldType, value, index [consume|copy] [init]: drop the field's value and store the new one.FIELD_ASSIGN's field description in STORE_FIELD order: object, field name, owner type, field type, and the index when the field is stored by index (absent where STORE_FIELD looks it up by name).getMode()CONSUME or COPY for an assignment; null otherwise.The scope of DROP_AT_EXIT, or the owner (a scope id orCALLER) of SLOT_DECLARE; null otherwise.getSlot()The slot declared or assigned (SLOT_DECLARE, SLOT_ASSIGN); null otherwise.getType()The declared type of a SLOT_DECLARE; null otherwise.getValue()The value this instruction acts on: OWN/DROP/DROP_AT_EXIT's operand, the value assigned by SLOT_ASSIGN, FIELD_ASSIGN and STATIC_FIELD_ASSIGN; null for SLOT_DECLARE and STATIC_FIELD_TAKE (whose value is its result).inthashCode()booleanTrue when the slot is owned by the caller (a parameter or the return variable).booleanisInit()True when SLOT_ASSIGN or FIELD_ASSIGN carries the[init]fact: the slot or field is provably empty, nothing to drop.booleanbooleanisTyped()True when SLOT_DECLARE carries[typed](lowered to TYPED_REFERENCE).static OwnershipInstrOWN value: a new OWNED reference to the value's object (lowered:RETAIN).static OwnershipInstrslotAssign(String slot, String value, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) SLOT_ASSIGN slot, value [consume|copy] [init]: drop the slot's value (unlessinit- a fact that it is empty) and store the new one.static OwnershipInstrslotDeclare(String slot, String type, String owner, boolean typed, DebugInfo debugInfo) SLOT_DECLARE slot, type, owner [typed]: an empty slot owned by a scope, or byCALLER.static OwnershipInstrstaticFieldAssign(String fieldName, String ownerType, String fieldType, String value, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) STATIC_FIELD_ASSIGN field, ownerType, fieldType, value [consume|copy] [init]: store into a static field, described exactly asSTORE_STATIC_FIELDdescribes it.static OwnershipInstrstaticFieldTake(String result, String fieldName, String ownerType, String fieldType, DebugInfo debugInfo) result = STATIC_FIELD_TAKE field, ownerType, fieldType: the static's value, OWNED - its count moves to the result.toString()Methods inherited from class IRInstr
accept, addOperand, addOperands, getDebugInfo, getEscapeMetaData, getOpcode, getOperands, getResult, hasEscapeMetaData, hasResult, isControlFlow, isLabel, isMemoryManagement, isMethodCall, setEscapeMetaData
-
Field Details
-
CALLER
The owner of a parameter or the return variable: the CALLER. Such a slot is never dropped by a region here.- See Also:
-
OBJECT
The owner of a property: the OBJECT that holds it, which drops it when the object is destroyed. Such a slot is never dropped by a region here.- See Also:
-
NO_FIELD_INDEX
public static final int NO_FIELD_INDEXAfieldAssign(String, String, String, String, String, int, OwnershipInstr.AssignMode, boolean, DebugInfo)whose field is stored without an index (STORE_FIELD's look-up-by-name form).- See Also:
-
-
Method Details
-
own
OWN value: a new OWNED reference to the value's object (lowered:RETAIN). -
drop
DROP value: the end of an OWNED value on this path (lowered:RELEASE). -
dropAtExit
DROP_AT_EXIT value, scope: the end of an OWNED value at every exit of the scope's current activation (lowered:SCOPE_REGISTER). -
slotDeclare
-
slotAssign
public static OwnershipInstr slotAssign(String slot, String value, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) SLOT_ASSIGN slot, value [consume|copy] [init]: drop the slot's value (unlessinit- a fact that it is empty) and store the new one. -
fieldAssign
public static OwnershipInstr fieldAssign(String objectVar, String fieldName, String ownerType, String fieldType, String value, int fieldIndex, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) FIELD_ASSIGN object, field, ownerType, fieldType, value, index [consume|copy] [init]: drop the field's value and store the new one. The field is described exactly asSTORE_FIELDdescribes it.[init]is the same fact as onSLOT_ASSIGN: the field is provably empty here (a constructor's first store into it), so there is nothing to drop. -
staticFieldAssign
public static OwnershipInstr staticFieldAssign(String fieldName, String ownerType, String fieldType, String value, OwnershipInstr.AssignMode mode, boolean init, DebugInfo debugInfo) STATIC_FIELD_ASSIGN field, ownerType, fieldType, value [consume|copy] [init]: store into a static field, described exactly asSTORE_STATIC_FIELDdescribes it. -
staticFieldTake
-
getValue
The value this instruction acts on: OWN/DROP/DROP_AT_EXIT's operand, the value assigned by SLOT_ASSIGN, FIELD_ASSIGN and STATIC_FIELD_ASSIGN; null for SLOT_DECLARE and STATIC_FIELD_TAKE (whose value is its result). -
getSlot
The slot declared or assigned (SLOT_DECLARE, SLOT_ASSIGN); null otherwise. -
getScopeId
-
getType
The declared type of a SLOT_DECLARE; null otherwise. -
isCallerOwned
public boolean isCallerOwned()True when the slot is owned by the caller (a parameter or the return variable). -
isRegionOwned
-
getFieldOperands
-
getMode
CONSUME or COPY for an assignment; null otherwise. -
isTyped
public boolean isTyped()True when SLOT_DECLARE carries[typed](lowered to TYPED_REFERENCE). -
isInit
public boolean isInit()True when SLOT_ASSIGN or FIELD_ASSIGN carries the[init]fact: the slot or field is provably empty, nothing to drop. -
toString
-
equals
-
hashCode
-