P_Lookup Module
Primitive: Resolve the given fully qualified module name, and answer the loaded module having that name. Fail if such a module is not currently loaded.
Author
Mark van Gulik
Functions
Record that some number of nanoseconds were just expended checking the type of the value returned by this primitive.
Record that some number of nanoseconds were just expended running this primitive.
Attempt this primitive with the given Interpreter. The interpreter's argument list must be set up prior to this call. If the primitive fails, it should set the primitive failure code by calling Interpreter.primitiveFailure and returning its result from the primitive. Otherwise it should set the interpreter's primitive result by calling Interpreter.primitiveSuccess and then return its result from the primitive. For unusual primitives that replace the current continuation, Result.CONTINUATION_CHANGED is more appropriate, and the latestResult need not be set. For primitives that need to cause a context switch, Result.FIBER_SUSPENDED should be returned.
Return a function type that restricts actual primitive blocks defined using that primitive. The actual block's argument types must be at least as specific as this function type's argument types, and the actual block's return type must be at least as general as this function type's return type. That's equivalent to the condition that the actual block's type is a subtype of this function type.
Answer whether a raw function using this primitive can/should have nybblecode instructions.
Answer the fallibility of the primitive for a call site with the given argument types.
Write a JVM invocation of this primitive. This sets up the interpreter, calls Interpreter.beforeAttemptPrimitive, calls Primitive.attempt, calls Interpreter.afterAttemptPrimitive, and records statistics as needed. It also deals with primitive failures, suspensions, and reifications.
Test whether the specified Flag is set for this primitive.
Answer the type of the result that will be produced by a call site with the given argument types. Don't include semantic restrictions defined in the Avail code, but if convenient answer something stronger than the return type in the primitive's basic function type.
The primitive couldn't be folded out, so see if alternative instructions can be generated for its invocation. If so, answer true, ensure control flow will go to the appropriate CallSiteHelper exit point, and leave the translator NOT at a currentReachable() point. If the alternative instructions could not be generated for this primitive, answer false, and generate nothing.
Generate suitable primitive failure code on the given L1InstructionWriter. Some primitives may have special requirements, but most (fallible) primitives follow the same pattern.
Properties
The number of arguments the primitive expects. The value -1 is used by the special primitive P_PushConstant to indicate it may have any number of arguments. However, note that that primitive cannot be used explicitly in Avail code.
A type to constrain the A_Type.writeType of the variable declaration within the primitive declaration of a block. The actual variable's inner type must be this or a supertype.
The Statistic for abandoning the stack due to a primitive attempt answering Result.CONTINUATION_CHANGED.
The Statistic for reification prior to invoking a primitive that does not have Flag.CanInline set.