Class Monomorphisation
IRGenerationContext.monomorphisation(), and every emitted type through the context's
IRGenerationContext.resolveType(ISymbol) / IRGenerationContext.resolveTypeName(ISymbol) facades,
which delegate here. Never hold a second mapping or a second resolve cache anywhere else.
Scenario 3 generates a parameterised type's method BODIES by walking the GENERIC type's AST (there is only one AST,
shared by every parameterisation), so every symbol recorded against that AST carries TEMPLATE types - a bare
T, or a dependent parameterisation such as List of T and the Iterator of T that its
iterator() returns. Each must be re-pointed at its concrete counterpart before it is emitted. Signatures
and fields need none of this: those come from the parameterised symbol itself, already substituted by phase 6.
Outside a monomorphisation (within(PositionalConceptualLookupMapping.Mapping, Supplier) not running) every resolution is the identity, so nothing outside a
generic body moves.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontinueFrom(Monomorphisation outer) Continue the monomorphisation ofouterhere (in a fresh context): the same conceptual-to-concrete mapping and the same dynamic-construct copies.dynamicConstructCopyOf(ISymbol template) The copy already made of a dynamic construct for the monomorphisation in progress, if any.mapping()The conceptual-to-concrete mapping of the monomorphisation in progress, or empty outside one.voidrecordDynamicConstructCopy(ISymbol template, ISymbol monomorph) Record the copy made of a dynamic construct for the monomorphisation in progress; from now on every reference to the construct (its own body, its constructor call, a nested construct) resolves to the copy.resolveScopeTypeName(IScope scope) resolveTypeName(ISymbol)for an owning SCOPE that is usually - but not always - a symbol.resolveType(ISymbol typeSymbol) The concrete type a (possibly conceptual) type resolves to under the monomorphisation in progress; outside one the symbol is returned unchanged.resolveTypeName(ISymbol typeSymbol) The name form ofresolveType(ISymbol).<R> Rwithin(PositionalConceptualLookupMapping.Mapping mapping, Supplier<R> work) Runworkwith the Scenario 3 substitution of one parameterised type in force, then clear it (with the dynamic-construct copies) whatever happens.
-
Constructor Details
-
Monomorphisation
Monomorphisation(IRContext irContext)
-
-
Method Details
-
within
Runworkwith the Scenario 3 substitution of one parameterised type in force, then clear it (with the dynamic-construct copies) whatever happens.The mapping pairs the generic type's conceptual 'type parameters' with the concrete 'type arguments' it was parameterised with, positionally and by symbol - the SAME
PositionalConceptualLookupMapping.Mappingphase 6TypeSubstitutionuses, so both phases substitute identically.- Parameters:
mapping- The conceptual to concrete mapping of the parameterised type being generatedwork- The generation to run under it- Returns:
- what
workreturns
-
continueFrom
Continue the monomorphisation ofouterhere (in a fresh context): the same conceptual-to-concrete mapping and the same dynamic-construct copies. A dynamic function or class declared inside a generic body is generated in a context of its own (counter isolation); without this its body and signature would be emitted with the template's 'T' - a class no back-end ever writes. The resolve cache is not shared (it is only a cache).- Parameters:
outer- The monomorphisation of the context generating the body the dynamic construct is declared in
-
mapping
The conceptual-to-concrete mapping of the monomorphisation in progress, or empty outside one. -
recordDynamicConstructCopy
Record the copy made of a dynamic construct for the monomorphisation in progress; from now on every reference to the construct (its own body, its constructor call, a nested construct) resolves to the copy.- Parameters:
template- The dynamic construct as declared in the generic bodymonomorph- The copy re-typed for this parameterisation
-
dynamicConstructCopyOf
-
resolveType
The concrete type a (possibly conceptual) type resolves to under the monomorphisation in progress; outside one the symbol is returned unchanged. SeeIRGenerationContext.resolveType(ISymbol)for the rule.- Parameters:
typeSymbol- The (possibly conceptual) type symbol- Returns:
- The concrete type symbol to emit or reason about
-
resolveTypeName
The name form ofresolveType(ISymbol). -
resolveScopeTypeName
resolveTypeName(ISymbol)for an owning SCOPE that is usually - but not always - a symbol.
-