mirror of
https://github.com/ganelson/inform.git
synced 2024-07-07 17:44:22 +03:00
218 lines
15 KiB
HTML
218 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>Inform Organisation</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="../compiler.html">compiler tools</a></li>
|
|
<li><a href="../other.html">other tools</a></li>
|
|
<li><a href="../extensions.html">extensions and kits</a></li>
|
|
<li><a href="../units.html">unit test tools</a></li>
|
|
</ul><h2>Compiler Webs</h2><ul>
|
|
<li><a href="../inbuild/index.html">inbuild</a></li>
|
|
<li><a href="../inform7/index.html">inform7</a></li>
|
|
<li><a href="index.html"><span class="selectedlink">inter</span></a></li>
|
|
</ul><h2>Inbuild Modules</h2><ul>
|
|
<li><a href="../supervisor-module/index.html">supervisor</a></li>
|
|
</ul><h2>Inform7 Modules</h2><ul>
|
|
<li><a href="../core-module/index.html">core</a></li>
|
|
<li><a href="../assertions-module/index.html">assertions</a></li>
|
|
<li><a href="../values-module/index.html">values</a></li>
|
|
<li><a href="../knowledge-module/index.html">knowledge</a></li>
|
|
<li><a href="../imperative-module/index.html">imperative</a></li>
|
|
<li><a href="../runtime-module/index.html">runtime</a></li>
|
|
<li><a href="../if-module/index.html">if</a></li>
|
|
<li><a href="../multimedia-module/index.html">multimedia</a></li>
|
|
<li><a href="../index-module/index.html">index</a></li>
|
|
</ul><h2>Inter Modules</h2><ul>
|
|
<li><a href="../bytecode-module/index.html">bytecode</a></li>
|
|
<li><a href="../building-module/index.html">building</a></li>
|
|
<li><a href="../pipeline-module/index.html">pipeline</a></li>
|
|
<li><a href="../final-module/index.html">final</a></li>
|
|
</ul><h2>Services</h2><ul>
|
|
<li><a href="../arch-module/index.html">arch</a></li>
|
|
<li><a href="../calculus-module/index.html">calculus</a></li>
|
|
<li><a href="../html-module/index.html">html</a></li>
|
|
<li><a href="../inflections-module/index.html">inflections</a></li>
|
|
<li><a href="../kinds-module/index.html">kinds</a></li>
|
|
<li><a href="../linguistics-module/index.html">linguistics</a></li>
|
|
<li><a href="../problems-module/index.html">problems</a></li>
|
|
<li><a href="../syntax-module/index.html">syntax</a></li>
|
|
<li><a href="../words-module/index.html">words</a></li>
|
|
<li><a href="../../../inweb/docs/foundation-module/index.html">foundation</a></li>
|
|
|
|
</ul>
|
|
</nav>
|
|
<main role="main">
|
|
<!--Weave of 'Inform Organisation' generated by Inweb-->
|
|
<div class="breadcrumbs">
|
|
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../compiler.html">Compiler Tools</a></li><li><a href="index.html">inter</a></li><li><a href="index.html#M">Manual</a></li><li><b>Inform Organisation</b></li></ul></div>
|
|
<p class="purpose">The standard hierarchy of inter code generated by Inform.</p>
|
|
|
|
<ul class="toc"><li><a href="M-io.html#SP1">§1. Status</a></li><li><a href="M-io.html#SP2">§2. Global area and main</a></li><li><a href="M-io.html#SP3">§3. Compilation modules</a></li><li><a href="M-io.html#SP5">§5. Function packages</a></li></ul><hr class="tocbar">
|
|
|
|
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>§1. Status. </b>The Inter specification allows great flexibility in how packages are used
|
|
to structure a program, and requires very little.
|
|
</p>
|
|
|
|
<p class="commentary">The Inform compiler, however, uses this flexibility in a systematic way,
|
|
as follows.
|
|
</p>
|
|
|
|
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>§2. Global area and main. </b>Inform opens with a version number, then declares package types (as needed
|
|
below), issues pragmas for I6 compiler memory settings, then declares
|
|
primitives for the standard Inform set: it always declares the same set
|
|
of primitives on every run.
|
|
</p>
|
|
|
|
<p class="commentary">As required, the rest of the program is in the <span class="extract"><span class="extract-syntax">main</span></span> package, which has
|
|
type <span class="extract"><span class="extract-syntax">_plain</span></span>.
|
|
</p>
|
|
|
|
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>§3. Compilation modules. </b>Inform divides up its material into compilation modules, as follows. Each
|
|
one becomes an inter package of type <span class="extract"><span class="extract-syntax">_module</span></span>, and is a subpackage of <span class="extract"><span class="extract-syntax">main</span></span>.
|
|
</p>
|
|
|
|
<ul class="items"><li>(a) The "generic module" contains built-in definitions of kinds, and the like.
|
|
No source text directly leads to this, and indeed, it can entirely be defined
|
|
without having seen any source text: it will be the same on every run. The
|
|
package is <span class="extract"><span class="extract-syntax">/main/generic</span></span>.
|
|
</li><li>(b) Material from the Inform 6 template is assimilated into inter code in
|
|
the "template module", which is <span class="extract"><span class="extract-syntax">/main/template</span></span>.
|
|
</li><li>(c) Each extension is a compilation module, including of course the Standard
|
|
Rules, which is <span class="extract"><span class="extract-syntax">/main/standard_rules</span></span>. Subsequent extensions have
|
|
longer names, such as <span class="extract"><span class="extract-syntax">/main/locksmith_by_emily_short</span></span>.
|
|
</li><li>(d) Material in the main source text is a single compilation module, and
|
|
goes into <span class="extract"><span class="extract-syntax">/main/source_text</span></span>.
|
|
</li><li>(e) The "synoptic module" contains material which was synthesised from all
|
|
of the source material in the other modules, and which can't meaningfully
|
|
be localised. For example, a function at run-time which returns the default
|
|
value for a kind given its weak kind ID has to be synoptic, because its
|
|
definition will include references to every kind defined in the program.
|
|
Such a function doesn't belong to any one block of source text. The
|
|
package is <span class="extract"><span class="extract-syntax">/main/synoptic</span></span>.
|
|
</li></ul>
|
|
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>§4. </b>Except for the template module, which is necessarily more free-form,
|
|
each module package then contains some or all of a standard set of
|
|
subpackages (and nothing else). Suppose the module name is <span class="extract"><span class="extract-syntax">M</span></span>. The
|
|
range of possible subpackages is:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> /main/M/actions</span>
|
|
<span class="plain-syntax"> /main/M/activities</span>
|
|
<span class="plain-syntax"> /main/M/adjectives</span>
|
|
<span class="plain-syntax"> /main/M/chronology</span>
|
|
<span class="plain-syntax"> /main/M/conjugations</span>
|
|
<span class="plain-syntax"> /main/M/equations</span>
|
|
<span class="plain-syntax"> /main/M/extensions</span>
|
|
<span class="plain-syntax"> /main/M/functions</span>
|
|
<span class="plain-syntax"> /main/M/grammar</span>
|
|
<span class="plain-syntax"> /main/M/instances</span>
|
|
<span class="plain-syntax"> /main/M/kinds</span>
|
|
<span class="plain-syntax"> /main/M/listing</span>
|
|
<span class="plain-syntax"> /main/M/phrases</span>
|
|
<span class="plain-syntax"> /main/M/properties</span>
|
|
<span class="plain-syntax"> /main/M/relations</span>
|
|
<span class="plain-syntax"> /main/M/rulebooks</span>
|
|
<span class="plain-syntax"> /main/M/rules</span>
|
|
<span class="plain-syntax"> /main/M/tables</span>
|
|
<span class="plain-syntax"> /main/M/variables</span>
|
|
</pre>
|
|
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>§5. Function packages. </b>All functions compiled by Inform 7 are expressed in inter code by packages
|
|
of type <span class="extract"><span class="extract-syntax">_function</span></span>. The only externally visible symbol is <span class="extract"><span class="extract-syntax">call</span></span>, which is
|
|
what is invoked. For example:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">symbol</span><span class="plain-syntax"> X </span><span class="reserved-syntax">--></span><span class="plain-syntax"> /main/kinds/kind_6/gpr_fn/call</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> X</span>
|
|
</pre>
|
|
<p class="commentary">invokes the function defined by the package:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> /main/kinds/kind_6/gpr_fn</span>
|
|
</pre>
|
|
<p class="commentary">(Inform conventionally uses names ending in <span class="extract"><span class="extract-syntax">_fn</span></span> for function packages.)
|
|
Functions assimilated from template files are almost exactly similar,
|
|
except that rather than <span class="extract"><span class="extract-syntax">call</span></span> the call symbol has the name of the original
|
|
template function. For example, <span class="extract"><span class="extract-syntax">RELATION_TY_Distinguish</span></span> is assimilated as:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> /template/functions/RELATION_TY_Distinguish_fn/RELATION_TY_Distinguish</span>
|
|
</pre>
|
|
<p class="commentary">It is possible for function packages to avoid defining any actual code, by
|
|
defining <span class="extract"><span class="extract-syntax">call</span></span> as an alias for a routine which we'll simply have to assume
|
|
will be present at eventual compile time. For example:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> print_fn _function</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">symbol</span><span class="plain-syntax"> </span><span class="reserved-syntax">public</span><span class="plain-syntax"> </span><span class="reserved-syntax">misc</span><span class="plain-syntax"> call </span><span class="element-syntax">`REAL_NUMBER_TY_Say</span><span class="plain-syntax">`</span>
|
|
</pre>
|
|
<p class="commentary">More often, however, and always for functions derived from Inform 7 source
|
|
text, the package contains a code subpackage, and then defines <span class="extract"><span class="extract-syntax">call</span></span> to
|
|
be that code package:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> gpr_fn _function</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> code_block_1 _code</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">constant</span><span class="plain-syntax"> call </span><span class="identifier-syntax">K_phrase_nothing____nothing</span><span class="plain-syntax"> = code_block_1</span>
|
|
</pre>
|
|
<p class="commentary">In fact, though, the package can be much more elaborate. If the code needs
|
|
to manipulate or refer to data not expressible in single words, such as
|
|
lists or texts, then it will probably need to create and subsequently destroy
|
|
a stack frame. The mechanism will then be:
|
|
</p>
|
|
|
|
<pre class="displayed-code all-displayed-code code-font">
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> gpr_fn _function</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> code_block_1 _code</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">constant</span><span class="plain-syntax"> kernel </span><span class="identifier-syntax">K_phrase_nothing____nothing</span><span class="plain-syntax"> = code_block_1</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">package</span><span class="plain-syntax"> code_block_2 _code</span>
|
|
<span class="plain-syntax"> ...</span>
|
|
<span class="plain-syntax"> </span><span class="reserved-syntax">constant</span><span class="plain-syntax"> call </span><span class="identifier-syntax">K_phrase_nothing____nothing</span><span class="plain-syntax"> = code_block_2</span>
|
|
</pre>
|
|
<p class="commentary">The "shell" routine of code, the one receiving the <span class="extract"><span class="extract-syntax">call</span></span>, creates a stack
|
|
fram and then calls the "kernel" routine, which does the actual work; when
|
|
that returns to the "shell", the stack frame is disposed of again.
|
|
</p>
|
|
|
|
<p class="commentary">Function packages will also contain definitions of any static data they
|
|
need: for example, if an Inform 7 phrase contains a reference to the
|
|
constant <span class="extract"><span class="extract-syntax">{ 1 , 2 , 3 }</span></span> then a function package for it will define a
|
|
constant with a name such as <span class="extract"><span class="extract-syntax">block_constant_1</span></span>. In short, as far as
|
|
possible, function packages are self-contained.
|
|
</p>
|
|
|
|
<nav role="progress"><div class="progresscontainer">
|
|
<ul class="progressbar"><li class="progressprev"><a href="M-ia.html">❮</a></li><li class="progresscurrentchapter">M</li><li class="progresssection"><a href="M-ui.html">ui</a></li><li class="progresssection"><a href="M-ti.html">ti</a></li><li class="progresssection"><a href="M-dpiti.html">dpiti</a></li><li class="progresssection"><a href="M-cpiti.html">cpiti</a></li><li class="progresssection"><a href="M-ip.html">ip</a></li><li class="progresssection"><a href="M-ia.html">ia</a></li><li class="progresscurrent">io</li><li class="progresssection"><a href="M-pas.html">pas</a></li><li class="progresssection"><a href="M-rc.html">rc</a></li><li class="progresschapter"><a href="1-mn.html">1</a></li><li class="progressnext"><a href="M-pas.html">❯</a></li></ul></div>
|
|
</nav><!--End of weave-->
|
|
|
|
</main>
|
|
</body>
|
|
</html>
|
|
|