<ulclass="crumbs"><li><ahref="../index.html">Home</a></li><li><ahref="../inform7n.html">Inform7</a></li><li><ahref="index.html">runtime</a></li><li><ahref="index.html#P">Preliminaries</a></li><li><b>What This Module Does</b></li></ul></div>
<ulclass="toc"><li><ahref="P-wtmd.html#SP1">§1. Prerequisites</a></li><li><ahref="P-wtmd.html#SP2">§2. About this layer of Inform</a></li><li><ahref="P-wtmd.html#SP3">§3. The Inter hierarchy</a></li></ul><hrclass="tocbar">
<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. Prerequisites. </b>The runtime module is a part of the Inform compiler toolset. It is
presented as a literate program or "web". Before diving in:
full details, but essentially: it's C without predeclarations or header files,
and where functions have names like <spanclass="extract"><spanclass="extract-syntax">Tags::add_by_name</span></span> rather than just <spanclass="extract"><spanclass="extract-syntax">add_by_name</span></span>.
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. About this layer of Inform. </b>The <ahref="index.html"class="internal">runtime</a> and <ahref="../imperative-module/index.html"class="internal">imperative</a> modules (see <ahref="../imperative-module/P-wtmd.html"class="internal">What This Module Does (in imperative)</a>)
jointly make up a layer of Inform whose task is to take the conceptual structures
now build up — rules, phrases, tables, the world model — and turn them into
<pclass="commentary">Neither module is in charge of the other. <ahref="index.html"class="internal">runtime</a> makes extensive use of
<ahref="../imperative-module/3-fnc.html"class="internal">Functions (in imperative)</a>, while <ahref="../imperative-module/index.html"class="internal">imperative</a> uses <ahref="2-emt.html"class="internal">Emit (in runtime)</a> and
<ahref="2-hrr.html"class="internal">Hierarchy (in runtime)</a>. The demarcation line is that:
</p>
<ulclass="items"><li>●<ahref="../imperative-module/index.html"class="internal">imperative</a> provides general mechanisms for compiling Inter functions,
and uses them to construct the functions needed for rules and phrases.
</li><li>●<ahref="index.html"class="internal">runtime</a> organises the hierarchical structure of the Inter code being
made, and compiles the Inter representations of data structures like rulebooks
or tables, and any Inter functions needed to manage them at runtime.
</li></ul>
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. The Inter hierarchy. </b>Inter code is an intermediate-level representation of the program we are to
compile. Inter can exist in binary or textual forms: see <ahref="../inter/M-ui.html"class="internal">Manual (in inter)</a> for
a general introduction to programming it in textual form. We will compile
binary Inter for speed, but they are really very similar.
<pclass="commentary">The modest amount of global material is the same on every compilation, and just
sets up our conventions. Inter also requires the top-level package to be <spanclass="extract"><spanclass="extract-syntax">main</span></span>.
But it's our decision to then subdivide <spanclass="extract"><spanclass="extract-syntax">main</span></span> up into packages called "modules",
which have the package type <spanclass="extract"><spanclass="extract-syntax">_module</span></span>. These come from several sources:
</p>
<ulclass="items"><li>● The <spanclass="extract"><spanclass="extract-syntax">veneer</span></span> module is named after the veneer system in Inform 6, and provides
access to its (very modest) facilities.
</li><li>● The <spanclass="extract"><spanclass="extract-syntax">generic</span></span> module contains definitions which are built-in to the language:
for example, kinds like <spanclass="extract"><spanclass="extract-syntax">K_number</span></span>.
</li><li>● Each compilation unit of Inform 7 source text produces one module. See
</li><li>● Each included kit of Inter code is a module.
</li><li>● The <spanclass="extract"><spanclass="extract-syntax">synoptic</span></span> module contains material which gathers up references from all
<pclass="commentary">The role of <ahref="index.html"class="internal">runtime</a> and <ahref="../imperative-module/index.html"class="internal">imperative</a> is to build the generic, synoptic
and compilation-unit modules; the modules from kits will come later in the
<pclass="commentary">Modules then have sub-departments called submodules, which are packages of type
<spanclass="extract"><spanclass="extract-syntax">_submodule</span></span>. For example, the rules created in any given compilation unit live
in the <spanclass="extract"><spanclass="extract-syntax">rules</span></span> submodule of its module; the properties in <spanclass="extract"><spanclass="extract-syntax">properties</span></span>; and
so on. This is all very orderly, but there are a great many different structures
to compile for a large number of different reasons. The <ahref="2-hrr.html"class="internal">Hierarchy</a> section
of code provides a detailed specification of exactly where everything goes.
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. </b><ahref="index.html"class="internal">runtime</a> and <ahref="../imperative-module/index.html"class="internal">imperative</a> should not make raw Inter code directly, but
<ulclass="items"><li>●<ahref="index.html"class="internal">runtime</a> and <ahref="../imperative-module/index.html"class="internal">imperative</a> call the functions in <ahref="2-hrr.html"class="internal">Chapter 2: Emission</a>
to "emit" code and find out where to put it.
</li><li>● Those functions in turn call the <ahref="../building-module/index.html"class="internal">building</a> module, which gives
general code (not tied to the Inform compiler) for constructing Inter.
</li><li>● The <ahref="../building-module/index.html"class="internal">building</a> module then calls down to <ahref="../bytecode-module/index.html"class="internal">bytecode</a> to put the actual
bytes in memory.
</li></ul>
<pclass="commentary">In effect, then, <ahref="2-hrr.html"class="internal">Chapter 2: Emission</a> is the bridge (or the shaft?) between the upper
levels of Inform and the lower, and it provides an API for the rest of <ahref="index.html"class="internal">runtime</a>
and <ahref="../imperative-module/index.html"class="internal">imperative</a> to use.