A_RawFunction

interface A_RawFunction : A_BasicObject

A_RawFunction is an interface that specifies the operations specific to function implementations in Avail.

An A_Function refers to its raw function, plus any outer values captured during function closure.

Author

Mark van Gulik

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun becomeIndirectionTo(anotherObject: A_BasicObject)

Turn the receiver into an indirection to the specified object.

Link copied to clipboard
open fun codePrimitive(): Primitive?

Answer this raw function's Primitive or null.

Link copied to clipboard
abstract fun declarationKind(): DeclarationPhraseDescriptor.DeclarationKind
Link copied to clipboard
abstract fun describeForDebugger(): Array<AvailObjectFieldHelper>

Utility method for decomposing this object in the debugger.

Link copied to clipboard
abstract fun descriptor(): AbstractDescriptor

Retrieve the object's {@linkplain AbstractDescriptor descriptor}.

Link copied to clipboard
abstract fun enumerationIncludesInstance(potentialInstance: AvailObject): Boolean
Link copied to clipboard
abstract fun equals(another: A_BasicObject): Boolean

Answer whether the receiver and the argument, both A_BasicObjects, are equal in value.

abstract operator override fun equals(other: Any?): Boolean

{@inheritDoc}

Link copied to clipboard
abstract fun equalsAnyTuple(aTuple: A_Tuple): Boolean

Answer whether the receiver, an object, and the argument, a tuple, are equal in value.

Link copied to clipboard
abstract fun equalsByteArrayTuple(aByteArrayTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsByteBufferTuple(aByteBufferTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsByteString(aByteString: A_String): Boolean

Answer whether the receiver, an object, and the argument, a byte string, are equal in value.

Link copied to clipboard
abstract fun equalsByteTuple(aByteTuple: A_Tuple): Boolean

Answer whether the receiver, an object, and the argument, a byte tuple, are equal in value.

Link copied to clipboard
abstract fun equalsCompiledCode(aCompiledCode: A_RawFunction): Boolean

Answer whether the arguments, an object and a compiled code, are equal.

Link copied to clipboard
abstract fun equalsCompiledCodeType(aCompiledCodeType: A_Type): Boolean
Link copied to clipboard
abstract fun equalsContinuation(aContinuation: A_Continuation): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun equalsContinuationType(aContinuationType: A_Type): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun equalsEnumerationType(anEnumerationType: A_BasicObject): Boolean
Link copied to clipboard
abstract fun equalsEnumerationWithSet(aSet: A_Set): Boolean

Determine whether the receiver is an enumeration with the given set of instances.

Link copied to clipboard
abstract fun equalsEqualityRawPojoFor(otherEqualityRawPojo: AvailObject, otherJavaObject: Any?): Boolean
Link copied to clipboard
abstract fun equalsFiberType(aFiberType: A_Type): Boolean

Answer whether the receiver, an object, and the argument, a fiber type, are equal in value.

Link copied to clipboard
abstract fun equalsFunction(aFunction: A_Function): Boolean

Answer whether the receiver, an object, and the argument, a function, are equal in value.

Link copied to clipboard
abstract fun equalsFunctionType(aFunctionType: A_Type): Boolean

Answer whether the receiver, an object, and the argument, a function type, are equal.

Link copied to clipboard
abstract fun equalsInstanceTypeFor(anInstanceType: AvailObject): Boolean
Link copied to clipboard
abstract fun equalsIntegerIntervalTuple(anIntegerIntervalTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsIntegerRangeType(anIntegerRangeType: A_Type): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun equalsIntTuple(anIntTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsListNodeType(listNodeType: A_Type): Boolean

Answer whether this value equals the given list phrase type.

Link copied to clipboard
abstract fun equalsLiteralTokenType(aLiteralTokenType: A_Type): Boolean
Link copied to clipboard
abstract fun equalsLongTuple(aLongTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsMap(aMap: A_Map): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun equalsMapType(aMapType: A_Type): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun equalsNybbleTuple(aNybbleTuple: A_Tuple): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsObject(anObject: AvailObject): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsObjectTuple(anObjectTuple: A_Tuple): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsObjectType(anObjectType: AvailObject): Boolean
Link copied to clipboard
abstract fun equalsPhrase(aPhrase: A_Phrase): Boolean
Link copied to clipboard
abstract fun equalsPhraseType(aPhraseType: A_Type): Boolean
Link copied to clipboard
abstract fun equalsPojo(aPojo: AvailObject): Boolean
Link copied to clipboard
abstract fun equalsPojoBottomType(): Boolean
Link copied to clipboard
abstract fun equalsPojoField(field: AvailObject, receiver: AvailObject): Boolean
Link copied to clipboard
abstract fun equalsPojoType(aPojoType: AvailObject): Boolean
Link copied to clipboard
abstract fun equalsPrimitiveType(aPrimitiveType: A_Type): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsRawPojoFor(otherRawPojo: AvailObject, otherJavaObject: Any?): Boolean
Link copied to clipboard
abstract fun equalsRepeatedElementTuple(aRepeatedElementTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsReverseTuple(aTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsSetType(aSetType: A_Type): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsSmallIntegerIntervalTuple(aSmallIntegerIntervalTuple: A_Tuple): Boolean
Link copied to clipboard
abstract fun equalsToken(aToken: A_Token): Boolean
Link copied to clipboard
abstract fun equalsTokenType(aTokenType: A_Type): Boolean
Link copied to clipboard
abstract fun equalsTupleType(aTupleType: A_Type): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsTwoByteString(aTwoByteString: A_String): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun equalsVariableType(aVariableType: A_Type): Boolean

Answer whether the receiver equals the argument.

Link copied to clipboard
abstract fun fieldAt(field: A_Atom): AvailObject

Extract a field from an object.

Link copied to clipboard
abstract fun fieldAtIndex(index: Int): AvailObject

Extract a field from an object, using a one-based index into the field slots. This requires knowledge of the ObjectLayoutVariant, since the same field is at different indices in different variants.

Link copied to clipboard
abstract fun fieldAtOrNull(field: A_Atom): AvailObject?

Extract a field from an object, or answer null if it's not present.

Link copied to clipboard
abstract fun fieldAtPuttingCanDestroy(    field: A_Atom,     value: A_BasicObject,     canDestroy: Boolean): A_BasicObject

Add or replace a field of an object.

Link copied to clipboard
abstract fun fieldMap(): A_Map

Dispatch to the descriptor.

Link copied to clipboard
abstract fun fieldTuple(): A_Tuple
Link copied to clipboard
abstract fun fieldTypeAt(field: A_Atom): A_Type

Extract a field type from an object type.

Link copied to clipboard
abstract fun fieldTypeAtIndex(index: Int): A_Type

Extract a field type from an object type, using the given field index, which is specific to an ObjectLayoutVariant.

Link copied to clipboard
abstract fun fieldTypeAtOrNull(field: A_Atom): A_Type?

Extract a field type from an object type, or null if it's not present.

Link copied to clipboard
open fun functionType(): A_Type

Answer the function type associated with this raw function's closures.

Link copied to clipboard
abstract fun hash(): Int

Compute the 32-bit hash of the receiver.

Link copied to clipboard
abstract override fun hashCode(): Int
Link copied to clipboard
abstract fun hashOrZero(): Int

Dispatch to the descriptor.

Link copied to clipboard
open fun <T : A_BasicObject> ifNil(action: () -> T): T

If the receiver isNil, evaluate the action. Answer either the non-nil receiver, or the result of the action.

Link copied to clipboard
open fun <T : A_BasicObject> ifNotNil(action: (T) -> Unit)

If the receiver is notNil, evaluate the action with it.

Link copied to clipboard
abstract fun integerSlotsCount(): Int

Answer the number of integer slots. All variable integer slots occur following the last fixed integer slot.

Link copied to clipboard
abstract fun isInstanceOf(aType: A_Type): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun isInstanceOfKind(aType: A_Type): Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract fun javaAncestors(): AvailObject
Link copied to clipboard
abstract fun javaClass(): A_BasicObject
Link copied to clipboard
abstract fun <T : Any> javaObject(): T?
Link copied to clipboard
abstract fun <T : Any> javaObjectNotNull(): T
Link copied to clipboard
abstract fun kind(): A_Type

Dispatch to the descriptor.

Link copied to clipboard
abstract fun <T> lock(body: () -> T): T

Lock the fiber during evaluation of the Supplier, and return the produced value.

Link copied to clipboard
abstract fun makeImmutable(): AvailObject

Dispatch to the descriptor.

Link copied to clipboard
abstract fun makeImmutableInternal(queueToProcess: MutableList<AvailObject>, fixups: MutableList<() -> Unit>)

The receiver is marked with an IMMUTABLE descriptor, but its subobjects have not yet been made immutable. Scan them now, and do any additional fix-ups necessary for the kind of object.

Link copied to clipboard
abstract fun makeShared(): AvailObject

Dispatch to the descriptor.

Link copied to clipboard
abstract fun makeSharedInternal(queueToProcess: MutableList<AvailObject>, fixups: MutableList<() -> Unit>)

The receiver is marked with a SHARED descriptor, but its subobjects have not yet been made shared. Scan them now, and do any additional fix-ups necessary for the kind of object.

Link copied to clipboard
abstract fun makeSubobjectsImmutable(): AvailObject

Dispatch to the descriptor.

Link copied to clipboard
abstract fun makeSubobjectsShared(): AvailObject

Dispatch to the descriptor.

Link copied to clipboard
open fun <T : A_BasicObject, O : A_BasicObject> mapNotNil(action: (T) -> O): O

If the receiver is notNil, evaluate the action with it, answering the value produced by the action. If the receiver was nil, answer nil cast to the action's output type.

Link copied to clipboard
abstract fun marshalToJava(classHint: Class<*>?): Any?
Link copied to clipboard
abstract fun nameForDebugger(): String

Answer a name suitable for labeling a field containing this object.

Link copied to clipboard
abstract fun objectSlotsCount(): Int

Answer the number of object slots in this AvailObject. All variable object slots occur following the last fixed object slot.

Link copied to clipboard
abstract fun pojoSelfType(): A_Type
Link copied to clipboard
abstract fun printOnAvoidingIndent(    builder: StringBuilder,     recursionMap: IdentityHashMap<A_BasicObject, Void>,     indent: Int)

Recursively print the receiver to the builder unless it is already present in the recursionMap. Printing will begin at the specified indent level, measured in horizontal tab characters.

Link copied to clipboard
abstract fun rawPojo(): AvailObject
Link copied to clipboard
abstract fun representationCostOfTupleType(): Int

Dispatch to the descriptor.

Link copied to clipboard
abstract fun resultType(): A_Type
Link copied to clipboard
abstract fun sameAddressAs(anotherObject: A_BasicObject): Boolean

Answer whether the objects occupy the same memory addresses.

Link copied to clipboard
abstract fun scanSubobjects(visitor: (AvailObject) -> AvailObject)

Dispatch to the descriptor.

Link copied to clipboard
abstract fun serializerOperation(): SerializerOperation
Link copied to clipboard
abstract fun setDescriptor(newDescriptor: AbstractDescriptor)

Replace the object's {@linkplain AbstractDescriptor descriptor}.

Link copied to clipboard
abstract fun setHashOrZero(value: Int)

Dispatch to the descriptor.

Link copied to clipboard
abstract fun setToInvalidDescriptor()

Replace my descriptor field with a FillerDescriptor. This blows up for most messages, catching incorrect (all, by definition) further accidental uses of this object.

Link copied to clipboard
abstract fun setUpInstructionDecoder(instructionDecoder: CompiledCodeDescriptor.L1InstructionDecoder)

Helper method for transferring this object's longSlots into an L1InstructionDecoder. The receiver's descriptor must be a CompiledCodeDescriptor.

Link copied to clipboard
abstract fun showValueInNameForDebugger(): Boolean

Answer whether to show value-specific content in the file name for the debugger.

Link copied to clipboard
abstract fun traversed(): AvailObject

Follow indirections until a non-indirection is reached. Replace each indirection's target with the ultimate target.

Link copied to clipboard
abstract fun traversedWhileMakingImmutable(): AvailObject

Follow indirections until a non-indirection is reached. Replace each indirection's target with the ultimate target, even if it would cause the otherwise-forbidden immutable->mutable references. Only used during makeImmutable.

Link copied to clipboard
abstract fun traversedWhileMakingShared(): AvailObject

Follow indirections until a non-indirection is reached. Replace each indirection's target with the ultimate target, even if it would cause the otherwise-forbidden shared->unshared references. Only used during makeShared.

Link copied to clipboard
abstract fun variableIntegerSlotsCount(): Int

Answer the number of variable integer slots in this object. This does not include the fixed integer slots.

Link copied to clipboard
abstract fun variableObjectSlotsCount(): Int

Answer the number of variable object slots in this AvailObject. This does not include the fixed object slots.

Link copied to clipboard
abstract fun writeSummaryTo(writer: JSONWriter)
Link copied to clipboard
abstract fun writeTo(writer: JSONWriter)

Properties

Link copied to clipboard
abstract val isAbstract: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isAtom: Boolean

Is the receiver an Avail atom?

Link copied to clipboard
abstract val isBoolean: Boolean

Is the receiver an Avail boolean?

Link copied to clipboard
abstract val isByteArrayTuple: Boolean
Link copied to clipboard
abstract val isByteBufferTuple: Boolean
Link copied to clipboard
abstract val isByteString: Boolean

Is the receiver an Avail byte string?

Link copied to clipboard
abstract val isByteTuple: Boolean

Is the receiver an Avail byte tuple?

Link copied to clipboard
abstract val isExtendedInteger: Boolean

Is the receiver an Avail extended integer?

Link copied to clipboard
abstract val isFinite: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isFunction: Boolean

Is the receiver an Avail function?

Link copied to clipboard
abstract val isInitializedWriteOnceVariable: Boolean
Link copied to clipboard
abstract val isInstanceMeta: Boolean
Link copied to clipboard
abstract val isIntegerIntervalTuple: Boolean
Link copied to clipboard
abstract val isIntegerRangeType: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isIntTuple: Boolean

Is the receiver an Avail IntTupleDescriptor? This is conservative, in that some object tuples may only contain ints but not be reported as being int tuples.

Link copied to clipboard
abstract val isLiteralTokenType: Boolean
Link copied to clipboard
abstract val isLongTuple: Boolean

Is the receiver an Avail LongTupleDescriptor? This is conservative, in that some object tuples may only contain longs but not be reported as being long tuples.

Link copied to clipboard
abstract val isMap: Boolean

Is the receiver an Avail map?

Link copied to clipboard
abstract val isMapType: Boolean

Dispatch to the descriptor.

Link copied to clipboard
open val isNil: Boolean

Test if the receiver is the nil value.

Link copied to clipboard
abstract val isNybble: Boolean

Is the receiver an Avail nybble?

Link copied to clipboard
abstract val isPojo: Boolean
Link copied to clipboard
abstract val isPojoArrayType: Boolean
Link copied to clipboard
abstract val isPojoFusedType: Boolean
Link copied to clipboard
abstract val isPojoSelfType: Boolean
Link copied to clipboard
abstract val isPojoType: Boolean
Link copied to clipboard
abstract val isRawPojo: Boolean
Link copied to clipboard
abstract val isRepeatedElementTuple: Boolean
Link copied to clipboard
abstract val isSetType: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isSmallIntegerIntervalTuple: Boolean
Link copied to clipboard
abstract val isString: Boolean

Is the receiver an Avail string?

Link copied to clipboard
abstract val isTokenType: Boolean
Link copied to clipboard
abstract val isTuple: Boolean

Is the receiver an Avail tuple?

Link copied to clipboard
abstract val isTupleType: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isTwoByteString: Boolean

Is the receiver an Avail two-byte string?

Link copied to clipboard
abstract val isType: Boolean

Dispatch to the descriptor.

Link copied to clipboard
abstract val isUnsignedByte: Boolean

Is the receiver an Avail unsigned byte?

Link copied to clipboard
open val jsonFormattedString: String
Link copied to clipboard
open val jsonPrettyPrintedFormattedString: String
Link copied to clipboard
open val notNil: Boolean

Test if the receiver is not the nil value.

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
val A_RawFunction.codeStartingLineNumber: Int

Answer the starting line number for the block phrase that defines this raw function.

Link copied to clipboard
fun A_RawFunction.constantTypeAt(index: Int): A_Type

Answer the type of the index-th local constant.

Link copied to clipboard
fun A_RawFunction.countdownToReoptimize(value: Long)

Set the countdown until reoptimization by the Level Two translator.

Link copied to clipboard
val A_RawFunction.declarationNames: A_Tuple

For this raw function, compute the tuple of its declaration names (arguments, locals, constants, 0..1 labels, outers). This is useful for decompilation, for giving meaningful names to registers in L2 translations, and for presenting reified continuations. Note that the outers are not part of the stack frame, and apply to the continuation's function instead.

Link copied to clipboard
val A_RawFunction.declarationNamesWithoutOuters: A_Tuple

For this raw function, compute the tuple of its declaration names (arguments, locals, constants, 0..1 labels). This is useful for decompilation, for giving meaningful names to registers in L2 translations, and for presenting reified continuations.

Link copied to clipboard
fun A_RawFunction.decreaseCountdownToReoptimizeFromPoll(delta: Long)

This raw function was found to be running in an interpreter during a periodic poll. Decrease its countdown to reoptimization by the indicated amount, being careful not to drop below one (1).

Link copied to clipboard
fun A_RawFunction.decrementCountdownToReoptimize(continuation: (Boolean) -> Unit): Boolean

Atomically decrement the countdown to reoptimization by the L2Generator. If the count reaches zero (0), then lock this raw function, thereby blocking concurrent applications of A_Functions derived from this raw function, and then evaluate the argument in order to effect reoptimization.

Link copied to clipboard
val A_RawFunction.lineNumberEncodedDeltas: A_Tuple

Answer the tuple of line number deltas for this ram function. Each entry encodes a signed offset in an unsigned entry. There's an entry for each nybblecode (not for each nybble). The encoding uses the absolute value of the delta from the previous instruction's line number, shifted left once, adding one for negatives. This allows nybble tuples and byte tuples to be the usual representations for small functions.

Link copied to clipboard
fun A_RawFunction.literalAt(index: Int): AvailObject

Answer the index-th literal value of this A_RawFunction.

Link copied to clipboard
fun A_RawFunction.localTypeAt(index: Int): A_Type

Answer the type of the index-th local variable.

Link copied to clipboard
val A_RawFunction.maxStackDepth: Int

Answer the maximum depth of the stack needed by an A_Continuation representing the invocation of some A_Function that closes this A_RawFunction.

Link copied to clipboard
var A_RawFunction.methodName: A_String

Read or write the name of the method associated with this raw function, or some other descriptive A_String if it's not a method body.

Link copied to clipboard
val A_RawFunction.module: A_Module

Answer the A_Module that contains the block phrase that defines this raw function.

Link copied to clipboard
fun A_RawFunction.numArgs(): Int

Answer the number of arguments expected by this raw function.

Link copied to clipboard
val A_RawFunction.numConstants: Int

Answer the number of local constants specified by this A_RawFunction.

Link copied to clipboard
val A_RawFunction.numLiterals: Int

Answer the number of literal values embedded into this A_RawFunction.

Link copied to clipboard
val A_RawFunction.numLocals: Int

Answer the number of local variables specified by this A_RawFunction.

Link copied to clipboard
val A_RawFunction.numNybbles: Int

Answer how many nybbles are taken up by the nybblecodes of this raw function.

Link copied to clipboard
val A_RawFunction.numOuters: Int

Answer the number of outer variables specified by this A_RawFunction.

Link copied to clipboard
val A_RawFunction.numSlots: Int

Answer the number of slots to reserve in a A_Continuation based on this raw function. This is the arity, plus number of local variables and constants, plus number of stack slots.

Link copied to clipboard
val A_RawFunction.nybbles: A_Tuple

Answer the tuple of nybblecodes that implements this raw function.

Link copied to clipboard
val A_RawFunction.originatingPhrase: A_Phrase

Answer the block phrase from which this raw function was constructed. Answer nil if this information is not available.

Link copied to clipboard
var A_RawFunction.originatingPhraseIndex: Int

The index into the module's lazily-loaded tuple of phrases, or -1 if the phrase was not written to a module, in which case originatingPhrase must already contain the A_Phrase. If this code was generated (say from a pragma), this may be -1, and the originatingPhrase will be nil.

Link copied to clipboard
fun A_RawFunction.outerTypeAt(index: Int): A_Type

Answer the type of the index-th outer variable.

Link copied to clipboard
val A_RawFunction.packedDeclarationNames: A_String

Answer an A_String containing the concatenated names of the originating block's declarations.

Link copied to clipboard
val A_RawFunction.returneeCheckStat: Statistic

Answer a Statistic for recording returns into this raw function.

Link copied to clipboard
val A_RawFunction.returnerCheckStat: Statistic

Answer a Statistic for recording returns from this raw function.

Link copied to clipboard
val A_RawFunction.returnTypeIfPrimitiveFails: A_Type

Answer the type that this raw function will produce if there is no primitive, or if the primitive fails and the nybblecodes run.

fun A_RawFunction.setStartingChunkAndReoptimizationCountdown(chunk: L2Chunk, countdown: Long)

Set the chunk that implements this A_RawFunction, and the countdown to reoptimization by the L2Generator.

Link copied to clipboard
val A_RawFunction.startingChunk: L2Chunk

Answer the L2Chunk that the interpreter will run to simulate execution of this A_RawFunction.

Link copied to clipboard
fun A_RawFunction.tallyInvocation()

Atomically increment the total number of invocations of A_Functions based on this A_RawFunction.

Link copied to clipboard
val A_RawFunction.totalInvocations: Long

Answer the total number of invocations of this raw function.