Here's a quick-reference summary of the assembler functions:
assembleConstant { k a -> } assembleConstantSlot { a -> i } assembleConstantGet { i a -> } assembleLabel { i a -> } assembleLabelGet { a -> i } assembleLineInFn { i a -> } assembleVariableGet { i a -> } assembleVariableSet { i a -> } assembleVariableSlot { n a -> i } assembleAfter { i a -> } assembleAfterChild { i a -> } assembleAlwaysDo { i a -> } assembleBeq { i a -> } assembleBne { i a -> } assembleBra { i a -> } assembleTag { i a -> } assembleCall { f a -> } assembleCalla { # a -> } assembleCatch { i a -> }
Decoding hints:
The 'a' operands are in each case an assembler instance. The 'i' operands are integer labels and offsets. The 'k' operands are arbitrary constants of any type whatever. The 'f' operands are function instances. The 'x' operands are executable (compiledFunction) instances. The '#' operands are integer arity declarations. The 'n' operands are names, normally strings.
Summary of assembler call semantics:
assembleAfter Assemble PUSH_PROTECT opcode linked to label i. assembleAfterChild Assemble PUSH_PROTECT_CHILD opcode linked to label i. assembleAlwaysDo Assemble BLANCH_PROTECT opcode linked to label i. assembleBeq Runtime: Pop stacktop, jump ifnil
. assembleBne Runtime: Pop stacktop, jump if notnil
. assembleBra Runtime: Jump unconditionally to label i. assembleCall Assemble call to fn f, inline bytecodes if a prim. assembleCalla Runtime: Check arity of top-of-stack fn & call it. assembleCatch Runtime: Push CATCHFRAME which will send any throws to label i. assembleConstant Runtime: Load constant K on the stack. assembleConstantSlot Compiletime: Return offset i of new constant slot. assembleLabel Compiletime: Internally note location of label i. assembleLabelGet Compiletime: Returns 0 1 2 ... on successive calls. assembleLineInFn Compiletime: Sets asm$s.lineInFn. assembleConstantGet Runtime: Load contents of const slot i onto stack. assembleTag Runtime: Push a TAG stackframe . assembleVariableGet Runtime: Load contents of local var i onto stack. assembleVariableSet Runtime: Set contents of local var i from stack. assembleVariableSlot Compiletime: Return offset i of new localvar slot. ? # f a finishAssembly Compiletime: Return executable for fn.
Note: 'f' argument to finishAssembly
is the function
being compiled. '#' argument is the arity of the function,
if known from declaration, else -1. This is an integer interpreted
as a set of bitfields. See section explodeArity. See section implodeArity.
'?' is nil
normally, non-nil
to force
the assembler to accept the given arity without arguing.
For examples of using the Muq assembler, see the Muq compilers, for example the mufInMuf compiler in the library files:
12-C-muf.t 13-C-muf-syntax.t
Go to the first, previous, next, last section, table of contents.