mirror of
https://github.com/ganelson/inform.git
synced 2024-07-16 22:14:23 +03:00
196 lines
15 KiB
HTML
196 lines
15 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<title>What This Module Does</title>
|
|
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<meta name="viewport" content="width=device-width initial-scale=1">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta http-equiv="Content-Language" content="en-gb">
|
|
|
|
<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
|
|
|
|
</head>
|
|
<body class="commentary-font">
|
|
<nav role="navigation">
|
|
<h1><a href="../index.html">
|
|
<img src="../docs-assets/Inform.png" height=72">
|
|
</a></h1>
|
|
<ul><li><a href="../index.html">home</a></li>
|
|
</ul><h2>Compiler</h2><ul>
|
|
<li><a href="../structure.html">structure</a></li>
|
|
<li><a href="../inbuildn.html">inbuild</a></li>
|
|
<li><a href="../inform7n.html">inform7</a></li>
|
|
<li><a href="../intern.html">inter</a></li>
|
|
<li><a href="../services.html">services</a></li>
|
|
<li><a href="../secrets.html">secrets</a></li>
|
|
</ul><h2>Other Tools</h2><ul>
|
|
<li><a href="../inblorbn.html">inblorb</a></li>
|
|
<li><a href="../indocn.html">indoc</a></li>
|
|
<li><a href="../inform6.html">inform6</a></li>
|
|
<li><a href="../inpolicyn.html">inpolicy</a></li>
|
|
<li><a href="../inrtpsn.html">inrtps</a></li>
|
|
</ul><h2>Resources</h2><ul>
|
|
<li><a href="../extensions.html">extensions</a></li>
|
|
<li><a href="../kits.html">kits</a></li>
|
|
</ul><h2>Repository</h2><ul>
|
|
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=18> github</a></li>
|
|
</ul><h2>Related Projects</h2><ul>
|
|
<li><a href="../../../inweb/index.html">inweb</a></li>
|
|
<li><a href="../../../intest/index.html">intest</a></li>
|
|
|
|
</ul>
|
|
</nav>
|
|
<main role="main">
|
|
<!--Weave of 'What This Module Does' generated by Inweb-->
|
|
<div class="breadcrumbs">
|
|
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">runtime</a></li><li><a href="index.html#P">Preliminaries</a></li><li><b>What This Module Does</b></li></ul></div>
|
|
<p class="purpose">An overview of the runtime module's role and abilities.</p>
|
|
|
|
<ul class="toc"><li><a href="P-wtmd.html#SP1">§1. Prerequisites</a></li><li><a href="P-wtmd.html#SP2">§2. About this layer of Inform</a></li><li><a href="P-wtmd.html#SP3">§3. The Inter hierarchy</a></li></ul><hr class="tocbar">
|
|
|
|
<p class="commentary firstcommentary"><a id="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:
|
|
</p>
|
|
|
|
<ul class="items"><li>(a) It helps to have some experience of reading webs: see <a href="../../../inweb/index.html" class="internal">inweb</a> for more.
|
|
</li><li>(b) The module is written in C, in fact ANSI C99, but this is disguised by the
|
|
fact that it uses some extension syntaxes provided by the <a href="../../../inweb/index.html" class="internal">inweb</a> literate
|
|
programming tool, making it a dialect of C called InC. See <a href="../../../inweb/index.html" class="internal">inweb</a> for
|
|
full details, but essentially: it's C without predeclarations or header files,
|
|
and where functions have names like <span class="extract"><span class="extract-syntax">Tags::add_by_name</span></span> rather than just <span class="extract"><span class="extract-syntax">add_by_name</span></span>.
|
|
</li><li>(c) This module uses other modules drawn from the compiler (see <a href="../structure.html" class="internal">structure</a>), and also
|
|
uses a module of utility functions called <a href="../../../inweb/foundation-module/index.html" class="internal">foundation</a>.
|
|
For more, see <a href="../../../inweb/foundation-module/P-abgtf.html" class="internal">A Brief Guide to Foundation (in foundation)</a>.
|
|
</li></ul>
|
|
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>§2. About this layer of Inform. </b>The <a href="index.html" class="internal">runtime</a> and <a href="../imperative-module/index.html" class="internal">imperative</a> modules (see <a href="../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
|
|
Inter code. For the bigger picture, see <a href="../structure.html" class="internal">structure</a>.
|
|
</p>
|
|
|
|
<p class="commentary">Neither module is in charge of the other. <a href="index.html" class="internal">runtime</a> makes extensive use of
|
|
<a href="../imperative-module/3-fnc.html" class="internal">Functions (in imperative)</a>, while <a href="../imperative-module/index.html" class="internal">imperative</a> uses <a href="2-emt.html" class="internal">Emit (in runtime)</a> and
|
|
<a href="2-hrr.html" class="internal">Hierarchy (in runtime)</a>. The demarcation line is that:
|
|
</p>
|
|
|
|
<ul class="items"><li>● <a href="../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>● <a href="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>
|
|
<p class="commentary firstcommentary"><a id="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 <a href="../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.
|
|
</p>
|
|
|
|
<p class="commentary">You can get a rough idea of what the Inter hierarchy looks like by compiling
|
|
an Inform project with:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="identifier-syntax">Include</span><span class="plain-syntax"> </span><span class="identifier-syntax">Inter</span><span class="plain-syntax"> </span><span class="identifier-syntax">hierarchy</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">debugging</span><span class="plain-syntax"> </span><span class="identifier-syntax">log</span><span class="plain-syntax">.</span>
|
|
</pre>
|
|
<p class="commentary">...and then looking at the log file. This will give an inventory, a summarised
|
|
listing, at two stages: first when the main Inform compiler has completed, and
|
|
second when linking with kits is all done, and we've reached the final state.
|
|
</p>
|
|
|
|
<p class="commentary">Inter code is not a linear stream, like the assembly language produced by a
|
|
conventional compiler: rather, it is a hierarchy of nested "packages". Each
|
|
package can contain some symbols, some other packages, and some actual code
|
|
or data. This makes it possible for Inter code to be heavily structured, with
|
|
similar resources grouped appropriately together. A package also has a "type",
|
|
and this can be used to find resources of different sorts, or to regulate where
|
|
they are placed. Types are written with an initial underscore: for example,
|
|
one package type we will create is <span class="extract"><span class="extract-syntax">_module</span></span>.
|
|
</p>
|
|
|
|
<p class="commentary">The top of the final hierarchy might look like this:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax">version number --> version 1</span>
|
|
<span class="plain-syntax">package type declarations --> packagetype _plain</span>
|
|
<span class="plain-syntax"> packagetype _code</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax">pragmas --> pragma Inform6 "$ALLOC_CHUNK_SIZE=32000"</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax">primitive declarations --> primitive !font val -> void</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax">main --> package main _plain</span>
|
|
<span class="plain-syntax"> general material --> package veneer _module</span>
|
|
<span class="plain-syntax"> package generic _module</span>
|
|
<span class="plain-syntax"> package synoptic _module</span>
|
|
<span class="plain-syntax"> from compilation units --> package basic_inform_by_graham_nelson _module</span>
|
|
<span class="plain-syntax"> package english_language_by_graham_nelson _module</span>
|
|
<span class="plain-syntax"> package standard_rules_by_graham_nelson _module</span>
|
|
<span class="plain-syntax"> package source_text _module</span>
|
|
<span class="plain-syntax"> from kits --> package BasicInformKit _module</span>
|
|
<span class="plain-syntax"> package EnglishLanguageKit _module</span>
|
|
<span class="plain-syntax"> package WorldModelKit _module</span>
|
|
<span class="plain-syntax"> package CommandParserKit _module</span>
|
|
<span class="plain-syntax"> to do with linking --> package connectors _linkage</span>
|
|
<span class="plain-syntax"> package template _plain</span>
|
|
</pre>
|
|
<p class="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 <span class="extract"><span class="extract-syntax">main</span></span>.
|
|
But it's our decision to then subdivide <span class="extract"><span class="extract-syntax">main</span></span> up into packages called "modules",
|
|
which have the package type <span class="extract"><span class="extract-syntax">_module</span></span>. These come from several sources:
|
|
</p>
|
|
|
|
<ul class="items"><li>● The <span class="extract"><span class="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 <span class="extract"><span class="extract-syntax">generic</span></span> module contains definitions which are built-in to the language:
|
|
for example, kinds like <span class="extract"><span class="extract-syntax">K_number</span></span>.
|
|
</li><li>● Each compilation unit of Inform 7 source text produces one module. See
|
|
<a href="2-cu.html" class="internal">Compilation Units</a>; in particular, each included extension is a compilation unit,
|
|
and the main source text puts material into <span class="extract"><span class="extract-syntax">source_text</span></span>.
|
|
</li><li>● Each included kit of Inter code is a module.
|
|
</li><li>● The <span class="extract"><span class="extract-syntax">synoptic</span></span> module contains material which gathers up references from all
|
|
of the other modules.
|
|
</li></ul>
|
|
<p class="commentary">The role of <a href="index.html" class="internal">runtime</a> and <a href="../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
|
|
linking stage (see <a href="../pipeline-module/index.html" class="internal">pipeline</a>).
|
|
</p>
|
|
|
|
<p class="commentary">Modules then have sub-departments called submodules, which are packages of type
|
|
<span class="extract"><span class="extract-syntax">_submodule</span></span>. For example, the rules created in any given compilation unit live
|
|
in the <span class="extract"><span class="extract-syntax">rules</span></span> submodule of its module; the properties in <span class="extract"><span class="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 <a href="2-hrr.html" class="internal">Hierarchy</a> section
|
|
of code provides a detailed specification of exactly where everything goes.
|
|
</p>
|
|
|
|
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>§4. </b><a href="index.html" class="internal">runtime</a> and <a href="../imperative-module/index.html" class="internal">imperative</a> should not make raw Inter code directly, but
|
|
through a three-level process:
|
|
</p>
|
|
|
|
<ul class="items"><li>● <a href="index.html" class="internal">runtime</a> and <a href="../imperative-module/index.html" class="internal">imperative</a> call the functions in <a href="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 <a href="../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 <a href="../building-module/index.html" class="internal">building</a> module then calls down to <a href="../bytecode-module/index.html" class="internal">bytecode</a> to put the actual
|
|
bytes in memory.
|
|
</li></ul>
|
|
<p class="commentary">In effect, then, <a href="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 <a href="index.html" class="internal">runtime</a>
|
|
and <a href="../imperative-module/index.html" class="internal">imperative</a> to use.
|
|
</p>
|
|
|
|
<nav role="progress"><div class="progresscontainer">
|
|
<ul class="progressbar"><li class="progressprevoff">❮</li><li class="progresscurrentchapter">P</li><li class="progresscurrent">wtmd</li><li class="progresschapter"><a href="1-rm.html">1</a></li><li class="progresschapter"><a href="2-hrr.html">2</a></li><li class="progresschapter"><a href="3-gm.html">3</a></li><li class="progresschapter"><a href="4-enc.html">4</a></li><li class="progresschapter"><a href="5-act.html">5</a></li><li class="progresschapter"><a href="6-bd.html">6</a></li><li class="progresschapter"><a href="7-cg.html">7</a></li><li class="progressnext"><a href="1-rm.html">❯</a></li></ul></div>
|
|
</nav><!--End of weave-->
|
|
|
|
</main>
|
|
</body>
|
|
</html>
|
|
|