Class ConstrainedTypeInstrs
ConstraintLowering,
ConstrainedConstruction, ConstrainedDelegation): the delegate and _viable field loads and
stores, the base value's copy, the _isSet of a base value and the call metadata of the base and
constrained constructors. Each is emitted the one way here.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String(package private) static final StringField holding whether THIS constrained value is usable - seeConstrainedTypeDfnGenerator.addFields.(package private) static final intThe index ofVIABLE_FIELD: added second, after the delegate. -
Constructor Summary
ConstructorsConstructorDescriptionConstrainedTypeInstrs(IRGenerationContext stackContext, ConstrainedTypeShape shape, SynthesisedCallMetaData synthesisedCallMetaData) -
Method Summary
Modifier and TypeMethodDescription(package private) CallMetaDataDetailsbaseConstructorMetaData(List<ISymbol> argumentTypes) Metadata for a constructor of the BASE type - every constrained-type lowering that materialises a base value (unset delegate, conversion, copy) calls one of these.(package private) CallMetaDataDetailsbaseMetaData(String methodName, List<ISymbol> argumentTypes) Metadata for the BASE type'smethodNametakingargumentTypes.(package private) CallMetaDataDetailsbooleanOperatorMetaData(String methodName) Metadata for the Boolean_and/_orthat chains constraint results.(package private) ISymbol(package private) CallMetaDataDetailsMetadata for the constrained type's own wrapping constructorCT(base).(package private) StringconstructorCall(List<IRInstr> instructions, String typeName, List<String> parameterTypes, List<String> arguments, CallMetaDataDetails metaData, DebugInfo debugInfo) THE constructor call on a type made here:CALL typeName.<init>(arguments)- its +1 result's owner is the caller's to state.(package private) StringcopyBaseValue(List<IRInstr> instructions, String sourceVar, DebugInfo debugInfo) Produce the constrained type's own copy of a base-type value, on both boundaries - storing a constructor argument (copy-in) and returning a promoted value (copy-out) - so a later in-place change to the caller's value does not reach the constrained value and bypass its constraint.(package private) BasicBlockInstrcreateBasicBlock(List<IRInstr> instructions) (package private) ISymboldefiningTypeOf(String methodName, List<ISymbol> argumentTypes) The type that DECLARES the base method a call forwards to, via THE sharedDefiningType- so the descriptor owner here is derived exactly as at every other phase-7 call site (Base.balanceOf, neverDerived.balanceOf).(package private) Stringsubject._isSet()on a BASE value, through THE?call (IsSetCallDetailsCreator): its +1 Boolean is dropped atscopeId's exit (registered only - as a branch condition it is not kept).(package private) StringThe delegate ofobjectVar(a value of this constrained type), borrowed for the scope: THE delegate load (DelegateLoad).(package private) ConstrainedTypeShapeshape()(package private) voidstoreDelegate(List<IRInstr> instructions, String value, DebugInfo debugInfo) THE first store intothis._delegate(in _i_init, or a constructor): the field takes its own reference to a value its scope owns - FIELD_ASSIGN [copy, init].(package private) voidstoreFirstViable(List<IRInstr> instructions, String value, DebugInfo debugInfo) THE first store intothis._viable(in _i_init): FIELD_ASSIGN [copy, init] of a value its scope owns.(package private) voidstoreViable(List<IRInstr> instructions, String scopeId, DebugInfo debugInfo) THE store ofthis._viable = true: after a value has been accepted by the constraint check (a breach Panics before reaching here).(package private) FieldTargetviableField(String objectVar) The_viablefield ofobjectVar, by its index.
-
Field Details
-
VIABLE_FIELD
Field holding whether THIS constrained value is usable - seeConstrainedTypeDfnGenerator.addFields.- See Also:
-
VIABLE_FIELD_INDEX
static final int VIABLE_FIELD_INDEXThe index ofVIABLE_FIELD: added second, after the delegate.- See Also:
-
BOOLEAN_FQN
- See Also:
-
-
Constructor Details
-
ConstrainedTypeInstrs
ConstrainedTypeInstrs(IRGenerationContext stackContext, ConstrainedTypeShape shape, SynthesisedCallMetaData synthesisedCallMetaData)
-
-
Method Details
-
shape
ConstrainedTypeShape shape() -
baseConstructorMetaData
Metadata for a constructor of the BASE type - every constrained-type lowering that materialises a base value (unset delegate, conversion, copy) calls one of these. -
constrainedConstructorMetaData
CallMetaDataDetails constrainedConstructorMetaData()Metadata for the constrained type's own wrapping constructorCT(base). -
booleanType
ISymbol booleanType() -
booleanOperatorMetaData
Metadata for the Boolean_and/_orthat chains constraint results. These carry a virtual flag (unlikeBooleanOperatorCallDetails), so the descriptor stays inline at its sites; only the metadata is shared. -
baseMetaData
Metadata for the BASE type'smethodNametakingargumentTypes. -
constructorCall
-
isSetOf
-
definingTypeOf
The type that DECLARES the base method a call forwards to, via THE sharedDefiningType- so the descriptor owner here is derived exactly as at every other phase-7 call site (Base.balanceOf, neverDerived.balanceOf).🔑 Since FE11 a constrained type over a class in a HIERARCHY carries operators its base only INHERITS (
_eq(Base),_gt(Integer), ...), and itsconstrain as > 0check calls the base's>- which may also be inherited. Naming the constraining type for those produced calls toDerived._eq(Base): a methodDeriveddoes not declare. The JVM found it by virtual lookup; natively it is a DIRECT call to a symbol no object file defines, so linking failed. Callers must takeisTraitCallfrom the SAME returned type (the CallTargetResolution invariant). Falls back to the constraining type when nothing resolves. -
copyBaseValue
Produce the constrained type's own copy of a base-type value, on both boundaries - storing a constructor argument (copy-in) and returning a promoted value (copy-out) - so a later in-place change to the caller's value does not reach the constrained value and bypass its constraint.The copy is the base's public copy constructor
Base(source), which phase-2PopulateConstrainedTypeOrErrorrequires (E06131, decision D10). It copies exactly as deeply as that constructor does - the built-in value types copy their value; a developer's record or class copies what its copy constructor's author wrote. There is no other mechanism: the old fallback,Base()then:=:, was a shallow copy nobody wrote and is gone.The copy is a fresh (+1) value and its owner is the caller's to state: a field's pre-take, or a move into the return variable - one helper with two destinations (J13) states neither.
- Returns:
- the temp holding the fresh, independent copy
-
loadDelegate
-
storeDelegate
-
storeViable
-
storeFirstViable
-
viableField
The_viablefield ofobjectVar, by its index. -
createBasicBlock
-