ObjectLayoutVariantDecisionStep

class ObjectLayoutVariantDecisionStep<Element : A_BasicObject, Result : A_BasicObject>(thisInternalLookupTree: InternalLookupTree<Element, Result>, argumentPositionToTest: Int, signatureExtrasExtractor: (Element) -> Pair<A_Type?, List<A_Type>>, variantToElements: Map<ObjectLayoutVariant, List<Element>>, alreadyVariantTestedArgumentsForChildren: A_Number) : DecisionStep<Element, Result>

This is a DecisionStep which dispatches to subtrees by looking up the argument's ObjectLayoutVariant. It can only be used when the argument has been constrained to an object.

The idea is to filter out most variants based on the fields that they define, and the fields they specifically don't define. If variant #1 has fields {x, y}, and variant #2 has fields {y, z}, then an object with variant #1 can't ever be an instance of an object type using variant #2.

Note that only the variants which have occurred have entries in this step; new variants arriving will be dynamically added to this step.

Also note that when an argument position is specified with a type that is an enumeration of multiple objects, the corresponding Result is duplicated for each of the objects' variants, ensuring a lookup of any of those actual objects can reach the correct solution.

Constructors

Link copied to clipboard
constructor(thisInternalLookupTree: InternalLookupTree<Element, Result>, argumentPositionToTest: Int, signatureExtrasExtractor: (Element) -> Pair<A_Type?, List<A_Type>>, variantToElements: Map<ObjectLayoutVariant, List<Element>>, alreadyVariantTestedArgumentsForChildren: A_Number)

Construct the new instance.

Properties

Link copied to clipboard

The argument position to test. If the index is within bounds for the arguments, use the indicated argument, otherwise index the extraValues as though they were concatenated to the end of the arguments.

Functions

Link copied to clipboard
open override fun addChildrenTo(list: MutableList<Pair<LookupTree<Element, Result>, List<L2SemanticValue>>>, semanticValues: List<L2SemanticValue>, extraSemanticValues: List<L2SemanticValue>)

Add the children LookupTrees, coupled with the available L2SemanticValues at that point, to the given list.

Link copied to clipboard
open override fun describe(node: InternalLookupTree<Element, Result>, indent: Int, builder: StringBuilder)

Output a description of this step on the given builder. Do not expand any subtrees that are still lazy.

Link copied to clipboard
Link copied to clipboard
fun extractArgumentType(argTypes: A_Tuple, extraValues: List<A_Type>): AvailObject
fun extractArgumentType(argTypes: List<A_Type>, extraValues: List<A_Type>): AvailObject
Link copied to clipboard
fun extractValue(probeValue: A_BasicObject, extraValues: List<A_BasicObject>): AvailObject
Link copied to clipboard
open override fun generateEdgesFor(semanticArguments: List<L2SemanticValue>, extraSemanticArguments: List<L2SemanticValue>, callSiteHelper: L1Translator.CallSiteHelper): List<Triple<L2BasicBlock, LookupTree<A_Definition, A_Tuple>, List<L2SemanticValue>>>

Generate suitable branch instructions via the CallSiteHelper, and answer a list of Triples that coordinate each target L2BasicBlock with the LookupTree responsible for generating code in that block, plus the list of extra L2SemanticValues that will be present at that block.

Link copied to clipboard

Perform one step of looking up the most-specific Result that matches the provided tuple of argument types. Answer another LookupTree with which to continue the search.

Perform one step of looking up the most-specific Result that matches the provided list of argument types. Answer another LookupTree with which to continue the search.

Link copied to clipboard

Perform one step of looking up the most-specific Result that matches the provided value. Answer another LookupTree with which to continue the search.

Link copied to clipboard

Perform one step of looking up the most-specific Result that matches the provided list of arguments. Answer another LookupTree with which to continue the search.

Link copied to clipboard

Add the children LookupTrees to the given list. This can be used for scanning the tree for some condition, without recursion.

Link copied to clipboard
fun sourceSemanticValue(semanticValues: List<L2SemanticValue>, extraSemanticValues: List<L2SemanticValue>): L2SemanticValue

Extract the L2SemanticValue that is providing the value operated on by this step.

Link copied to clipboard
open fun updateExtraValuesByTypes(argTypes: A_Tuple, extraValues: List<A_Type>): List<A_Type>
open fun updateExtraValuesByTypes(types: List<A_Type>, extraValues: List<A_Type>): List<A_Type>

Given an optional list of values used to supplement the lookup, answer the updated list of values that takes this step into account. The given and resulting lists must not be modified by subsequent steps.

Link copied to clipboard
open fun updateExtraValuesByValue(probeValue: A_BasicObject, extraValues: List<Element>): List<Element>

Given an optional list of values used to supplement the lookup, answer the updated list of values that takes this step into account. The given and resulting lists must not be modified by subsequent steps.

Link copied to clipboard
open fun updateExtraValuesByValues(argValues: List<A_BasicObject>, extraValues: List<Element>): List<Element>

Given an optional list of values used to supplement the lookup, answer the updated list of values that takes this step into account. The given and resulting lists must not be modified by subsequent steps.

Link copied to clipboard
open fun <Memento> updateSignatureExtrasExtractor(adaptor: LookupTreeAdaptor<Element, Result, Memento>, extrasTypeExtractor: (Element) -> Pair<A_Type?, List<A_Type>>, numArgs: Int): (Element) -> Pair<A_Type?, List<A_Type>>

Given a function that produces a list of types from an Element due to an ancestor tree node, produce a new function for producing a lists of types that takes this DecisionStep into account. The function also optionally produces the type signature of the element, for reuse by subsequent wrapped functions.