Functions that have a compiled version: switched to interpreted before a state image is written and compiled again after one is loaded, with a list of which are compiled.
CompiledA function that has a compiled version: its interpreted version, the function that compiles it, and the function that installs either. (Compiled make …) adds one to the list and compiles it; (Compiled report) prints the list.
nameWhat the list calls the function
Field: data carried by a Compiled instance.
interpretedThe interpreted version, which is installed whenever the compiled one is not
Field: data carried by a Compiled instance.
compile(fn (_)) answering the compiled version; a raise fails, and answering the interpreted version declines
Field: data carried by a Compiled instance.
install(fn (_ version)) installing a version where the function is called from
Field: data carried by a Compiled instance.
statecompiled, interpreted or failed
Field: data carried by a Compiled instance.
reasonThe text of the raise that failed the compile, or the empty string
Field: data carried by a Compiled instance.
compiledThe compiled version while it is installed, and nil otherwise
Field: data carried by a Compiled instance.
(%install! version state reason)Instance method: called on a Compiled instance.
(compile!)Compile the function and install the compiled version. A compile that raises has failed: the interpreted version is installed and the raise’s text is kept as the reason. A compile that answers the interpreted version has declined, and the interpreted version is installed.
Instance method: called on a Compiled instance.
Returns: SYMBOL — The state the entry is left in: compiled, interpreted or failed
Examples:
((new Compiled name 'f interpreted first compile (fn (_) (Err raise 'value "no compiler here" ())) install (fn (_ v) v)) compile!) => 'failed
((new Compiled name 'f interpreted first compile (fn (_) first) install (fn (_ v) v)) compile!) => 'interpreted(interpret!)Install the interpreted version and let go of the compiled one, so that nothing the entry holds is this process’s alone.
Instance method: called on a Compiled instance.
Returns: SYMBOL — interpreted
Examples:
(do (def c (new Compiled name 'f interpreted first compile (fn (_) rest) install (fn (_ v) v))) (c compile!) (list (c interpret!) (c compiled))) => ('interpreted ())allEvery entry, newest first
Static field: data held by Compiled itself, not by its instances.
(Compiled make name interpreted compile install)Add a function to the list and compile it. Every entry is switched to interpreted before a state image is written, and compiled again after one is loaded, in the order the entries were made.
Parameters:
SYMBOL — What the list calls the functionANY — The interpreted version, installed alreadyCALLABLE — (fn (_)) answering the compiled version; a raise fails, and answering the interpreted version declinesCALLABLE — (fn (_ version)) installing a version; see into-name and into-cellReturns: Compiled — The entry
See also: make-on-demand into-name into-cell
(Compiled make-on-demand name interpreted compile install)Add a function to the list and compile it, as make does, for a compile that is dear and not always wanted. The entry is switched to interpreted with every other before a state image is written, and stays interpreted after one is loaded until its owner sends it compile!.
Parameters:
SYMBOL — What the list calls the functionANY — The interpreted version, installed alreadyCALLABLE — (fn (_)) answering the compiled version; a raise fails, and answering the interpreted version declinesCALLABLE — (fn (_ version)) installing a version; see into-name and into-cellReturns: Compiled — The entry
(Compiled into-name name env)An install function for a name’s binding: installing a version sets the name in that environment.
Parameters:
SYMBOL — The name to setANY — The environment the name is bound inReturns: CALLABLE — (fn (_ version))
Examples:
(do (def f 1) ((op () env ((Compiled into-name 'f env) 2))) f) => 2(Compiled into-cell cell)An install function for the first of a pair, such as one cell of a type’s handler list.
Parameters:
PAIR — The pair whose first holds the functionReturns: CALLABLE — (fn (_ version))
Examples:
(do (def cell (pair 1 2)) ((Compiled into-cell cell) 5) (first cell)) => 5(Compiled into-object target)An install function for the function object itself: installing a version writes its type and its two data words into TARGET, so every holder of TARGET calls that version. TARGET keeps its flags and its identity.
Parameters:
CALLABLE — The function object to rewriteReturns: CALLABLE — (fn (_ version))
Examples:
(do (def g (fn (_) 1)) ((Compiled into-object g) (fn (_) 2)) (g)) => 2See also: in-place
(Compiled in-place name target compile)Add a function to the list as make does, installed into TARGET itself (into-object). The interpreted version is a new function object holding TARGET’s two data words, which keeps TARGET’s body alive while TARGET holds the compiled version.
Parameters:
SYMBOL — What the list calls the functionCALLABLE — The function to compile where it standsCALLABLE — (fn (_)) answering the compiled version; a raise fails, and answering the interpreted version declinesReturns: Compiled — The entry
See also: make into-object
(Compiled named name)The newest entry of that name.
Parameters:
SYMBOL — An entry’s nameReturns: Compiled — The entry, or nil when no entry has the name
Examples:
(null? (Compiled named 'no-such-entry)) => #t(Compiled interpret-all!)Switch every entry to its interpreted version, newest first. The image writer does this before its walk.
Returns: NIL — nil
(Compiled compile-all!)Compile every entry, oldest first, so that an entry which reads an earlier one’s compiled version finds the one just made.
Returns: NIL — nil
(Compiled list)The state of every entry, oldest first.
Returns: LIST — One (name state reason) list for each entry
(Compiled report)Print the list, oldest first: each function’s name, its state, and the reason when its compile failed.
Returns: NIL — nil