Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Instruction Set   [Contents][Index]


9.3.7.2 Top-Level Environment Instructions

These instructions access values in the top-level environment: bindings that were not lexically apparent at the time that the code in question was compiled.

The location in which a toplevel binding is stored can be looked up once and cached for later. The binding itself may change over time, but its location will stay constant.

Instruction: current-module s24:dst

Store the current module in dst.

Instruction: resolve s24:dst b1:bound? x7:_ s24:sym

Resolve sym in the current module, and place the resulting variable in dst. An error will be signalled if no variable is found. If bound? is true, an error will be signalled if the variable is unbound.

Instruction: define! s12:dst s12:sym

Look up a binding for sym in the current module, creating it if necessary. Store that variable to dst.

Instruction: toplevel-box s24:dst r32:var-offset r32:mod-offset n32:sym-offset b1:bound? x31:_

Load a value. The value will be fetched from memory, var-offset 32-bit words away from the current instruction pointer. var-offset is a signed value. Up to here, toplevel-box is like static-ref.

Then, if the loaded value is a variable, it is placed in dst, and control flow continues.

Otherwise, we have to resolve the variable. In that case we load the module from mod-offset, just as we loaded the variable. Usually the module gets set when the closure is created. sym-offset specifies the name, as an offset to a symbol.

We use the module and the symbol to resolve the variable, placing it in dst, and caching the resolved variable so that we will hit the cache next time. If bound? is true, an error will be signalled if the variable is unbound.

Instruction: module-box s24:dst r32:var-offset n32:mod-offset n32:sym-offset b1:bound? x31:_

Like toplevel-box, except mod-offset points at a module identifier instead of the module itself. A module identifier is a module name, as a list, prefixed by a boolean. If the prefix is true, then the variable is resolved relative to the module’s public interface instead of its private interface.


Next: , Previous: , Up: Instruction Set   [Contents][Index]