1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 10:04:21 +03:00
inform7/docs/final-module/2-cg.html
2021-11-08 10:16:46 +00:00

602 lines
146 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Code Generation</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">
<script>
function togglePopup(material_id) {
var popup = document.getElementById(material_id);
popup.classList.toggle("show");
}
</script>
<link href="../docs-assets/Popups.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="../inter/index.html">inter</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="index.html"><span class="selectedlink">final</span></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 'Code Generation' generated by Inweb-->
<div class="breadcrumbs">
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../compiler.html">Inter Modules</a></li><li><a href="index.html">final</a></li><li><a href="index.html#2">Chapter 2: Mechanism</a></li><li><b>Code Generation</b></li></ul></div>
<p class="purpose">To generate final code from intermediate code.</p>
<ul class="toc"><li><a href="2-cg.html#SP1">&#167;1. Pipeline stage</a></li><li><a href="2-cg.html#SP4">&#167;4. Ad hoc generation</a></li><li><a href="2-cg.html#SP5">&#167;5. Literal text modes</a></li><li><a href="2-cg.html#SP6">&#167;6. Segmentation</a></li><li><a href="2-cg.html#SP14">&#167;14. Transients</a></li><li><a href="2-cg.html#SP16">&#167;16. Value pairs</a></li></ul><hr class="tocbar">
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Pipeline stage. </b>This whole module exists to provide a single pipeline stage, making the final
generation of code from a tree of fully-linked and generally complete Inter.
</p>
<p class="commentary">It comes in two forms (the optional one writes nothing if no filename is supplied
to it; the compulsory one throws an error in that case), but note that both call
the same function.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::create_pipeline_stage</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">CodeGen::Stage::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"generate"</span><span class="plain-syntax">, </span><a href="2-cg.html#SP1" class="function-link"><span class="function-syntax">CodeGen::run_pipeline_stage</span></a><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEXT_OUT_STAGE_ARG</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">CodeGen::Stage::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"optionally-generate"</span><span class="plain-syntax">, </span><a href="2-cg.html#SP1" class="function-link"><span class="function-syntax">CodeGen::run_pipeline_stage</span></a><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">OPTIONAL_TEXT_OUT_STAGE_ARG</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::run_pipeline_stage</span><span class="plain-syntax">(</span><span class="identifier-syntax">pipeline_step</span><span class="plain-syntax"> *</span><span class="identifier-syntax">step</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">generator_argument</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP2" class="function-link"><span class="function-syntax">CodeGen::new_generation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">parsed_filename</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">to_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">repository</span><span class="plain-syntax">, </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">package_argument</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">generator_argument</span><span class="plain-syntax">, </span><span class="identifier-syntax">step</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">for_VM</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP4" class="function-link"><span class="function-syntax">Generators::go</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>A "generation" is a single act of translating inter code into final code.
It will be carried out by the "generator", using the data held in the following
object.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generator</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">target_vm</span><span class="plain-syntax"> *</span><span class="identifier-syntax">for_VM</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generator_private_data</span><span class="plain-syntax">; </span><span class="comment-syntax"> depending on the target generated to</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_file</span><span class="plain-syntax">; </span><span class="comment-syntax"> filename of output, and/or...</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_stream</span><span class="plain-syntax">; </span><span class="comment-syntax"> stream for textual output</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">from</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">just_this_package</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">segmentation</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">void_level</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">literal_text_mode</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">global_variables</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text_literals</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">assimilated_properties</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">unassimilated_properties</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">instances</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">kinds</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">kinds_in_declaration_order</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">instances_in_declaration_order</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">true_action_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">fake_action_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">actions</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">text_stream</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">dword_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">words</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">vanilla_dword</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">dword_dictionary</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">vanilla_dword</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">verbs</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">vanilla_dword</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">verb_grammar</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">text_stream</span></span>
<span class="plain-syntax"> </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="function-syntax">CodeGen::new_generation</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">CodeGen::new_generation</span></span>:<br/><a href="2-cg.html#SP1">&#167;1</a>, <a href="2-cg.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">just</span><span class="plain-syntax">, </span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generator</span><span class="plain-syntax">, </span><span class="identifier-syntax">target_vm</span><span class="plain-syntax"> *</span><span class="identifier-syntax">VM</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">temp</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">to_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">F</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">to_stream</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">VM</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">generator</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no way to determine format"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">VM</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">VM</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TargetVMs::find</span><span class="plain-syntax">(</span><span class="identifier-syntax">generator</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generator_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">for_VM</span><span class="plain-syntax"> = </span><span class="identifier-syntax">VM</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">from</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">generator</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">just</span><span class="plain-syntax">) </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">just_this_package</span><span class="plain-syntax"> = </span><span class="identifier-syntax">just</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">just_this_package</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Site::main_package</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP7" class="function-link"><span class="function-syntax">CodeGen::new_segmentation_data</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">void_level</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">literal_text_mode</span><span class="plain-syntax"> = </span><span class="constant-syntax">REGULAR_LTM</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">global_variables</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">text_literals</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">text_literal_holder</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">assimilated_properties</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unassimilated_properties</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">instances</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_in_declaration_order</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">instances_in_declaration_order</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">true_action_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">fake_action_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">actions</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">dword_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">words</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">vanilla_dword</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">dword_dictionary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dictionaries::new</span><span class="plain-syntax">(1024, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">verb_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">verbs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">vanilla_dword</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">verb_grammar</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_stream</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">temp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-cg.html#SP2_1" class="named-paragraph-link"><span class="named-paragraph">Traverse for global bric-a-brac</span><span class="named-paragraph-number">2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure code_generation is accessed in 2/cg2, 2/vnl, 2/vc, 2/vf, 2/vo, 2/vc2, 2/vi, 3/fti, 3/fbi, 3/fi, 4/fi6, 4/i6c, 4/i6o, 4/i6c2, 5/fnc, 5/cnm, 5/crf, 5/cmm, 5/cpc, 5/ccn, 5/clt, 5/com, 5/cfm and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2_1" class="paragraph-anchor"></a><b>&#167;2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Traverse for global bric-a-brac</span><span class="named-paragraph-number">2.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">InterTree::traverse</span><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">from</span><span class="plain-syntax">, </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::gather_up</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::sort_symbol_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds_in_declaration_order</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::in_declaration_order</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::sort_symbol_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">instances_in_declaration_order</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">instances</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::in_declaration_order</span></a><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-cg.html#SP2">&#167;2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::gather_up</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">CodeGen::gather_up</span></span>:<br/><a href="2-cg.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">state</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">W</span><span class="plain-syntax">.</span><span class="identifier-syntax">data</span><span class="plain-syntax">[</span><span class="identifier-syntax">ID_IFLD</span><span class="plain-syntax">]) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">VARIABLE_IST:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">var_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTables::symbol_from_frame_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">DEFN_VAR_IFLD</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">var_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">global_variables</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">PROPERTY_IST:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTables::symbol_from_frame_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">DEFN_PROP_IFLD</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Inter::Symbols::read_annotation</span><span class="plain-syntax">(</span><span class="identifier-syntax">prop_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">ASSIMILATED_IANN</span><span class="plain-syntax">) == </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">prop_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">assimilated_properties</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">prop_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">unassimilated_properties</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">INSTANCE_IST:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">inst_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTables::symbol_from_frame_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">DEFN_KIND_IFLD</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inst_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">instances</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">KIND_IST:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">kind_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTables::symbol_from_frame_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">DEFN_INST_IFLD</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kinds</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::sort_symbol_list</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">CodeGen::sort_symbol_list</span></span>:<br/><a href="2-cg.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_L</span><span class="plain-syntax">, </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> (*</span><span class="identifier-syntax">sorter</span><span class="plain-syntax">)(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem2</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">L</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **</span><span class="identifier-syntax">array</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **)</span>
<span class="plain-syntax"> (</span><span class="identifier-syntax">Memory::calloc</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="reserved-syntax">sizeof</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *), </span><span class="constant-syntax">CODE_GENERATION_MREASON</span><span class="plain-syntax">));</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sym</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">sym</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">sym</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">qsort</span><span class="plain-syntax">(</span><span class="identifier-syntax">array</span><span class="plain-syntax">, (</span><span class="identifier-syntax">size_t</span><span class="plain-syntax">) </span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="reserved-syntax">sizeof</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *), </span><span class="identifier-syntax">sorter</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">j</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">N</span><span class="plain-syntax">; </span><span class="identifier-syntax">j</span><span class="plain-syntax">++) </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">array</span><span class="plain-syntax">[</span><span class="identifier-syntax">j</span><span class="plain-syntax">], </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax">, </span><span class="identifier-syntax">to_L</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Memory::I7_array_free</span><span class="plain-syntax">(</span><span class="identifier-syntax">array</span><span class="plain-syntax">, </span><span class="constant-syntax">CODE_GENERATION_MREASON</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="reserved-syntax">sizeof</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *));</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::in_source_order</span><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::in_annotation_order</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="identifier-syntax">elem2</span><span class="plain-syntax">, </span><span class="identifier-syntax">SOURCE_ORDER_IANN</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::in_declaration_order</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">CodeGen::in_declaration_order</span></span>:<br/><a href="2-cg.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::in_annotation_order</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="identifier-syntax">elem2</span><span class="plain-syntax">, </span><span class="identifier-syntax">DECLARATION_ORDER_IANN</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::in_annotation_order</span><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">elem2</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">annot</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **</span><span class="identifier-syntax">e1</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **) </span><span class="identifier-syntax">elem1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **</span><span class="identifier-syntax">e2</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> **) </span><span class="identifier-syntax">elem2</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((*</span><span class="identifier-syntax">e1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (*</span><span class="identifier-syntax">e2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"Disaster while sorting kinds"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">s1</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::sequence_number</span></a><span class="plain-syntax">(*</span><span class="identifier-syntax">e1</span><span class="plain-syntax">, </span><span class="identifier-syntax">annot</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">s2</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP3" class="function-link"><span class="function-syntax">CodeGen::sequence_number</span></a><span class="plain-syntax">(*</span><span class="identifier-syntax">e2</span><span class="plain-syntax">, </span><span class="identifier-syntax">annot</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">s1</span><span class="plain-syntax"> != </span><span class="identifier-syntax">s2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">s1</span><span class="plain-syntax">-</span><span class="identifier-syntax">s2</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Inter::Symbols::sort_number</span><span class="plain-syntax">(*</span><span class="identifier-syntax">e1</span><span class="plain-syntax">) - </span><span class="identifier-syntax">Inter::Symbols::sort_number</span><span class="plain-syntax">(*</span><span class="identifier-syntax">e2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::sequence_number</span><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">kind_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">annot</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Symbols::read_annotation</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">annot</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">100000000</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Ad hoc generation. </b>This module would be more elegant if the following function did not exist. But
it is a consequence of the <span class="extract"><span class="extract-syntax">(+</span></span> ... <span class="extract"><span class="extract-syntax">+)</span></span> feature of Inform, which plunges
right through all kinds of conceptual barriers better left unplunged-through.
Happily, it's both limited and little-used. The task is to turn a single Inter
value-pair into the text of an expression which will represent it at run-time.
</p>
<p class="commentary">This is called by Inform 7 during a drastically earlier phase of compilation,
long before the <a href="index.html" class="internal">final</a> module would otherwise be involved, and there's no
question of performing a full generation of an entire Inter tree. So we make
a sort of mock-generation object, the <span class="extract"><span class="extract-syntax">ad_hoc_generation</span></span>, just for the purpose
of this function call. We could make a new mock object every time, because there
aren't such a lot of calls to this function, but instead we make just one and
re-use it.
</p>
<p class="commentary">The mock generator makes no use of segmentation (see below) except for the
single temporary segement, which is set to <span class="extract"><span class="extract-syntax">OUT</span></span>.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::val_to_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val2</span><span class="plain-syntax">, </span><span class="identifier-syntax">target_vm</span><span class="plain-syntax"> *</span><span class="identifier-syntax">VM</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">VM</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no VM given"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generator</span><span class="plain-syntax"> = </span><a href="2-cg2.html#SP2" class="function-link"><span class="function-syntax">Generators::find_for</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">VM</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">generator</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"VM family with no generator"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax"> =</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP2" class="function-link"><span class="function-syntax">CodeGen::new_generation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">Inter::Bookmarks::tree</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">),</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">generator</span><span class="plain-syntax">, </span><span class="identifier-syntax">VM</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code_generator</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generator</span><span class="plain-syntax"> = </span><a href="2-cg2.html#SP2" class="function-link"><span class="function-syntax">Generators::find_for</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">VM</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">generator</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"VM family with no generator"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">for_VM</span><span class="plain-syntax"> = </span><span class="identifier-syntax">VM</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">generator</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP11" class="function-link"><span class="function-syntax">CodeGen::select_temporary</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP16" class="function-link"><span class="function-syntax">CodeGen::pair_at_bookmark</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax">, </span><span class="identifier-syntax">IBM</span><span class="plain-syntax">, </span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP11" class="function-link"><span class="function-syntax">CodeGen::deselect_temporary</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ad_hoc_generation</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Literal text modes. </b>There are three of these. <span class="extract"><span class="extract-syntax">PRINTING_LTM</span></span> is used when text is needed only
immediately as an operand for, say, <span class="extract"><span class="extract-syntax">!print</span></span> and will therefore never be a
value at runtime; <span class="extract"><span class="extract-syntax">BOX_LTM</span></span> for "quotation box" text; <span class="extract"><span class="extract-syntax">REGULAR_LTM</span></span> for
everything else.
</p>
<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">REGULAR_LTM</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">BOX_LTM</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">PRINTING_LTM</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::lt_mode</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">CodeGen::lt_mode</span></span>:<br/>Inform 6 Code - <a href="4-i6c2.html#SP6_9">&#167;6.9</a><br/>C Input-Output Model - <a href="5-cim.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">literal_text_mode</span><span class="plain-syntax"> = </span><span class="identifier-syntax">m</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Segmentation. </b>Generators have flexibility in how they go about their business, but if they are
making what amounts to a text file with a lot of internal structure then the
following system may be a convenience. It allows text to be assembled as a set
of "segments" which can be appended to in any order, and which are then put
together in a logical order at the end.
</p>
<p class="commentary">Segments are identified by ID numbers counting up from 0, 1, 2, ...: but
ID number 0 is <span class="extract"><span class="extract-syntax">no_I7CGS</span></span>, reserved to mean "not a segment".
</p>
<p class="commentary">A segment is itself internally stratified into numbered "layers", and these
are used to help generators cope with more nuanced ordering issues &mdash; e.g.,
where two declarations are of basically the same sort of thing, and should
be in the same segment as each other; but where one must nevertheless precede
the other. This can be achieved by putting the one to come first at a
lower-numbered level.
</p>
<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">no_I7CGS</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">MAX_LAYERS_PER_SEGMENT</span><span class="plain-syntax"> </span><span class="constant-syntax">128</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">layers</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">generated_code</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_LAYERS_PER_SEGMENT</span><span class="plain-syntax">];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="function-syntax">CodeGen::new_segment</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">CodeGen::new_segment</span></span>:<br/><a href="2-cg.html#SP8">&#167;8</a>, <a href="2-cg.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">seg</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">seg</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">layers</span><span class="plain-syntax"> = </span><span class="constant-syntax">MAX_LAYERS_PER_SEGMENT</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;seg-&gt;</span><span class="element-syntax">layers</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) </span><span class="identifier-syntax">seg</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generated_code</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">seg</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure generated_segment is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>Each generation has its own copy of every possible numbered segment, though
by default those are <span class="extract"><span class="extract-syntax">NULL</span></span>.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_data</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">NO_DEFINED_I7CGS_VALUES</span><span class="plain-syntax">];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">segment_sequence</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">generated_segment</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">additional_segment_sequence</span><span class="plain-syntax">; </span><span class="comment-syntax"> of </span><span class="extract"><span class="extract-syntax">generated_segment</span></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">temporarily_diverted_to</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">temporarily_diverted</span><span class="plain-syntax">; </span><span class="comment-syntax"> to the temporary segment</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">pos</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">segmentation_data</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">current_segment</span><span class="plain-syntax">; </span><span class="comment-syntax"> the one currently being written to</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">current_layer</span><span class="plain-syntax">; </span><span class="comment-syntax"> within that segment: in the range 0 to current_segment-&gt;layers - 1</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">segmentation_data</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::new_segmentation_data</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">CodeGen::new_segmentation_data</span></span>:<br/><a href="2-cg.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">segment_sequence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">additional_segment_sequence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted_to</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">NO_DEFINED_I7CGS_VALUES</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="identifier-syntax">current_segment</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="identifier-syntax">current_layer</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure segmentation_data is accessed in 5/fnc and here.</li><li>The structure segmentation_pos is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>If a generator wants to use this system, it should call <a href="2-cg.html#SP8" class="internal">CodeGen::create_segments</a>
to say which segments it wants to be created, passing an array of ID numbers. The
order of these is significant &mdash; it's the order in which they will appear in the final
output.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::create_segments</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">CodeGen::create_segments</span></span>:<br/>Generating Inform 6 - <a href="4-fi6.html#SP4">&#167;4</a><br/>Final C - <a href="5-fnc.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">codes</span><span class="plain-syntax">[]) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segment_sequence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] &gt;= </span><span class="identifier-syntax">NO_DEFINED_I7CGS_VALUES</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax"> (</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] == </span><span class="constant-syntax">no_I7CGS</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"bad segment sequence"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]] = </span><a href="2-cg.html#SP6" class="function-link"><span class="function-syntax">CodeGen::new_segment</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]], </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segment_sequence</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generator_private_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>An optional "alternative" set can also be created.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::additional_segments</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">CodeGen::additional_segments</span></span>:<br/>Final C - <a href="5-fnc.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">codes</span><span class="plain-syntax">[]) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">additional_segment_sequence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] &gt;= </span><span class="identifier-syntax">NO_DEFINED_I7CGS_VALUES</span><span class="plain-syntax">) ||</span>
<span class="plain-syntax"> (</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] == </span><span class="constant-syntax">no_I7CGS</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"bad segment sequence"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]] = </span><a href="2-cg.html#SP6" class="function-link"><span class="function-syntax">CodeGen::new_segment</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ADD_TO_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">codes</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]], </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">additional_segment_sequence</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>At any given time, a generation has a "current" segment, to which output is
being written. The generator should use <a href="2-cg.html#SP10" class="internal">CodeGen::select</a> to switch to a given
segment, which must be one of those it has created, and then use <a href="2-cg.html#SP10" class="internal">CodeGen::deselect</a>
to go back to where it was. These calls must be made in properly nested pairs.
</p>
<p class="commentary">At some point we may want to make the cap on the number of layers flexible,
but for now about 10 layers is plenty.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::select</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">CodeGen::select</span></span>:<br/>Generating Inform 6 - <a href="4-fi6.html#SP4_1">&#167;4.1</a>, <a href="4-fi6.html#SP4_2">&#167;4.2</a>, <a href="4-fi6.html#SP5">&#167;5</a><br/>Inform 6 Constants - <a href="4-i6c.html#SP3_1">&#167;3.1</a>, <a href="4-i6c.html#SP3_2">&#167;3.2</a>, <a href="4-i6c.html#SP6">&#167;6</a><br/>Inform 6 Global Variables - <a href="4-i6gv.html#SP2_1">&#167;2.1</a>, <a href="4-i6gv.html#SP2_2">&#167;2.2</a>, <a href="4-i6gv.html#SP2_3">&#167;2.3</a>, <a href="4-i6gv.html#SP2_4">&#167;2.4</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP4_3">&#167;4.3</a>, <a href="4-i6o.html#SP4_4">&#167;4.4</a>, <a href="4-i6o.html#SP4_5">&#167;4.5</a>, <a href="4-i6o.html#SP4_6">&#167;4.6</a>, <a href="4-i6o.html#SP5_1">&#167;5.1</a>, <a href="4-i6o.html#SP9">&#167;9</a>, <a href="4-i6o.html#SP13_1">&#167;13.1</a>, <a href="4-i6o.html#SP13_2">&#167;13.2</a>, <a href="4-i6o.html#SP13_3">&#167;13.3</a><br/>Inform 6 Code - <a href="4-i6c2.html#SP2">&#167;2</a>, <a href="4-i6c2.html#SP9">&#167;9</a><br/>Final C - <a href="5-fnc.html#SP5_2">&#167;5.2</a>, <a href="5-fnc.html#SP5_3">&#167;5.3</a>, <a href="5-fnc.html#SP6_1">&#167;6.1</a><br/>C Global Variables - <a href="5-cgv.html#SP2">&#167;2</a>, <a href="5-cgv.html#SP3">&#167;3</a>, <a href="5-cgv.html#SP3_1">&#167;3.1</a>, <a href="5-cgv.html#SP3_2">&#167;3.2</a>, <a href="5-cgv.html#SP3_3">&#167;3.3</a>, <a href="5-cgv.html#SP3_4">&#167;3.4</a>, <a href="5-cgv.html#SP4">&#167;4</a><br/>C Memory Model - <a href="5-cmm.html#SP2">&#167;2</a>, <a href="5-cmm.html#SP3">&#167;3</a>, <a href="5-cmm.html#SP4_1">&#167;4.1</a>, <a href="5-cmm.html#SP4_2">&#167;4.2</a>, <a href="5-cmm.html#SP4_2_2">&#167;4.2.2</a>, <a href="5-cmm.html#SP5">&#167;5</a>, <a href="5-cmm.html#SP7">&#167;7</a><br/>C Assembly - <a href="5-cas.html#SP5_2">&#167;5.2</a><br/>C Literals - <a href="5-clt.html#SP7">&#167;7</a>, <a href="5-clt.html#SP8">&#167;8</a><br/>C Object Model - <a href="5-com.html#SP2">&#167;2</a>, <a href="5-com.html#SP4">&#167;4</a>, <a href="5-com.html#SP7">&#167;7</a>, <a href="5-com.html#SP10">&#167;10</a>, <a href="5-com.html#SP13">&#167;13</a>, <a href="5-com.html#SP16">&#167;16</a>, <a href="5-com.html#SP17">&#167;17</a>, <a href="5-com.html#SP20_1">&#167;20.1</a>, <a href="5-com.html#SP20_3">&#167;20.3</a>, <a href="5-com.html#SP24">&#167;24</a>, <a href="5-com.html#SP34">&#167;34</a><br/>C Function Model - <a href="5-cfm.html#SP2">&#167;2</a>, <a href="5-cfm.html#SP4">&#167;4</a>, <a href="5-cfm.html#SP6">&#167;6</a>, <a href="5-cfm.html#SP8">&#167;8</a>, <a href="5-cfm.html#SP12">&#167;12</a>, <a href="5-cfm.html#SP14_1">&#167;14.1</a>, <a href="5-cfm.html#SP14_2">&#167;14.2</a>, <a href="5-cfm.html#SP14_3">&#167;14.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-cg.html#SP10" class="function-link"><span class="function-syntax">CodeGen::select_layered</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::select_layered</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">CodeGen::select_layered</span></span>:<br/>Inform 6 Constants - <a href="4-i6c.html#SP2">&#167;2</a><br/>C Namespace - <a href="5-cnm.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">layer</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">previous_pos</span><span class="plain-syntax"> = </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"poorly timed selection"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">i</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">NO_DEFINED_I7CGS_VALUES</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"out of range"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"generator does not use this segment ID"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">layer</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]-&gt;</span><span class="element-syntax">layers</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"too many layers"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="element-syntax">current_segment</span><span class="plain-syntax"> = </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segments</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="element-syntax">current_layer</span><span class="plain-syntax"> = </span><span class="identifier-syntax">layer</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">previous_pos</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::deselect</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">CodeGen::deselect</span></span>:<br/>Generating Inform 6 - <a href="4-fi6.html#SP4_1">&#167;4.1</a>, <a href="4-fi6.html#SP4_2">&#167;4.2</a>, <a href="4-fi6.html#SP5">&#167;5</a><br/>Inform 6 Constants - <a href="4-i6c.html#SP2">&#167;2</a>, <a href="4-i6c.html#SP5">&#167;5</a>, <a href="4-i6c.html#SP6">&#167;6</a><br/>Inform 6 Global Variables - <a href="4-i6gv.html#SP2_1">&#167;2.1</a>, <a href="4-i6gv.html#SP2_2">&#167;2.2</a>, <a href="4-i6gv.html#SP2_3">&#167;2.3</a>, <a href="4-i6gv.html#SP2_4">&#167;2.4</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP4_3">&#167;4.3</a>, <a href="4-i6o.html#SP4_4">&#167;4.4</a>, <a href="4-i6o.html#SP4_5">&#167;4.5</a>, <a href="4-i6o.html#SP4_6">&#167;4.6</a>, <a href="4-i6o.html#SP6">&#167;6</a>, <a href="4-i6o.html#SP9">&#167;9</a>, <a href="4-i6o.html#SP13_1">&#167;13.1</a>, <a href="4-i6o.html#SP13_2">&#167;13.2</a>, <a href="4-i6o.html#SP13_3">&#167;13.3</a><br/>Inform 6 Code - <a href="4-i6c2.html#SP2">&#167;2</a>, <a href="4-i6c2.html#SP9">&#167;9</a><br/>Final C - <a href="5-fnc.html#SP5_2">&#167;5.2</a>, <a href="5-fnc.html#SP5_3">&#167;5.3</a>, <a href="5-fnc.html#SP6_1">&#167;6.1</a><br/>C Namespace - <a href="5-cnm.html#SP7">&#167;7</a><br/>C Global Variables - <a href="5-cgv.html#SP2">&#167;2</a>, <a href="5-cgv.html#SP3">&#167;3</a>, <a href="5-cgv.html#SP3_1">&#167;3.1</a>, <a href="5-cgv.html#SP3_2">&#167;3.2</a>, <a href="5-cgv.html#SP3_3">&#167;3.3</a>, <a href="5-cgv.html#SP3_4">&#167;3.4</a>, <a href="5-cgv.html#SP4">&#167;4</a><br/>C Memory Model - <a href="5-cmm.html#SP2">&#167;2</a>, <a href="5-cmm.html#SP3">&#167;3</a>, <a href="5-cmm.html#SP4_2_2">&#167;4.2.2</a>, <a href="5-cmm.html#SP5">&#167;5</a>, <a href="5-cmm.html#SP7">&#167;7</a><br/>C Assembly - <a href="5-cas.html#SP5_2">&#167;5.2</a><br/>C Literals - <a href="5-clt.html#SP7">&#167;7</a>, <a href="5-clt.html#SP8">&#167;8</a><br/>C Object Model - <a href="5-com.html#SP2">&#167;2</a>, <a href="5-com.html#SP4">&#167;4</a>, <a href="5-com.html#SP7">&#167;7</a>, <a href="5-com.html#SP10">&#167;10</a>, <a href="5-com.html#SP13">&#167;13</a>, <a href="5-com.html#SP16">&#167;16</a>, <a href="5-com.html#SP17">&#167;17</a>, <a href="5-com.html#SP20_1">&#167;20.1</a>, <a href="5-com.html#SP20_3">&#167;20.3</a>, <a href="5-com.html#SP24">&#167;24</a>, <a href="5-com.html#SP34">&#167;34</a><br/>C Function Model - <a href="5-cfm.html#SP2">&#167;2</a>, <a href="5-cfm.html#SP4">&#167;4</a>, <a href="5-cfm.html#SP6">&#167;6</a>, <a href="5-cfm.html#SP8">&#167;8</a>, <a href="5-cfm.html#SP12">&#167;12</a>, <a href="5-cfm.html#SP14_1">&#167;14.1</a>, <a href="5-cfm.html#SP14_2">&#167;14.2</a>, <a href="5-cfm.html#SP14_3">&#167;14.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="reserved-syntax">segmentation_pos</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"poorly timed deselection"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>However, we can also temporarily divert the whole system to send its text to
some temporary stream somewhere. For that, use the following pair:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::select_temporary</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">CodeGen::select_temporary</span></span>:<br/><a href="2-cg.html#SP4">&#167;4</a><br/>Vanilla Constants - <a href="2-vc.html#SP1_8">&#167;1.8</a><br/>Vanilla Objects - <a href="2-vo.html#SP2_2_1_2">&#167;2.2.1.2</a>, <a href="2-vo.html#SP4_1_1_1_1_1_1">&#167;4.1.1.1.1.1.1</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP11">&#167;11</a><br/>C Assembly - <a href="5-cas.html#SP6_3">&#167;6.3</a><br/>C Object Model - <a href="5-com.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"nested temporary segments"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted_to</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::deselect_temporary</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">CodeGen::deselect_temporary</span></span>:<br/><a href="2-cg.html#SP4">&#167;4</a><br/>Vanilla Constants - <a href="2-vc.html#SP1_8">&#167;1.8</a><br/>Vanilla Objects - <a href="2-vo.html#SP2_2_1_2">&#167;2.2.1.2</a>, <a href="2-vo.html#SP4_1_1_1_1_1_1">&#167;4.1.1.1.1.1.1</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP11">&#167;11</a><br/>C Assembly - <a href="5-cas.html#SP6_3">&#167;6.3</a><br/>C Object Model - <a href="5-com.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted_to</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>The following returns the text stream a generator should write to. Note that
if it has been "temporarily diverted" then the regiular selection is ignored.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">CodeGen::current</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">CodeGen::current</span></span>:<br/><a href="2-cg.html#SP16_1">&#167;16.1</a><br/>Vanilla - <a href="2-vnl.html#SP4">&#167;4</a><br/>Vanilla Constants - <a href="2-vc.html#SP2">&#167;2</a><br/>Vanilla Objects - <a href="2-vo.html#SP5">&#167;5</a><br/>Generating Inform 6 - <a href="4-fi6.html#SP4_1">&#167;4.1</a>, <a href="4-fi6.html#SP4_2">&#167;4.2</a>, <a href="4-fi6.html#SP5">&#167;5</a><br/>Inform 6 Constants - <a href="4-i6c.html#SP2">&#167;2</a>, <a href="4-i6c.html#SP3_1">&#167;3.1</a>, <a href="4-i6c.html#SP3_2">&#167;3.2</a>, <a href="4-i6c.html#SP4">&#167;4</a>, <a href="4-i6c.html#SP5">&#167;5</a>, <a href="4-i6c.html#SP6">&#167;6</a>, <a href="4-i6c.html#SP7">&#167;7</a>, <a href="4-i6c.html#SP8">&#167;8</a>, <a href="4-i6c.html#SP9">&#167;9</a>, <a href="4-i6c.html#SP10">&#167;10</a><br/>Inform 6 Global Variables - <a href="4-i6gv.html#SP2_1">&#167;2.1</a>, <a href="4-i6gv.html#SP2_2">&#167;2.2</a>, <a href="4-i6gv.html#SP2_3">&#167;2.3</a>, <a href="4-i6gv.html#SP2_4">&#167;2.4</a>, <a href="4-i6gv.html#SP3">&#167;3</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP4_3">&#167;4.3</a>, <a href="4-i6o.html#SP4_4">&#167;4.4</a>, <a href="4-i6o.html#SP4_5">&#167;4.5</a>, <a href="4-i6o.html#SP4_6">&#167;4.6</a>, <a href="4-i6o.html#SP5_1">&#167;5.1</a>, <a href="4-i6o.html#SP6">&#167;6</a>, <a href="4-i6o.html#SP9">&#167;9</a>, <a href="4-i6o.html#SP10">&#167;10</a>, <a href="4-i6o.html#SP11">&#167;11</a>, <a href="4-i6o.html#SP13_1">&#167;13.1</a>, <a href="4-i6o.html#SP13_2">&#167;13.2</a>, <a href="4-i6o.html#SP13_3">&#167;13.3</a><br/>Inform 6 Code - <a href="4-i6c2.html#SP2">&#167;2</a>, <a href="4-i6c2.html#SP3">&#167;3</a>, <a href="4-i6c2.html#SP4">&#167;4</a>, <a href="4-i6c2.html#SP5">&#167;5</a>, <a href="4-i6c2.html#SP6">&#167;6</a>, <a href="4-i6c2.html#SP6_4">&#167;6.4</a>, <a href="4-i6c2.html#SP9">&#167;9</a><br/>Final C - <a href="5-fnc.html#SP5_2">&#167;5.2</a>, <a href="5-fnc.html#SP5_3">&#167;5.3</a>, <a href="5-fnc.html#SP6_1">&#167;6.1</a><br/>C Namespace - <a href="5-cnm.html#SP7">&#167;7</a><br/>C References - <a href="5-crf.html#SP2">&#167;2</a><br/>C Global Variables - <a href="5-cgv.html#SP2">&#167;2</a>, <a href="5-cgv.html#SP3">&#167;3</a>, <a href="5-cgv.html#SP3_1">&#167;3.1</a>, <a href="5-cgv.html#SP3_2">&#167;3.2</a>, <a href="5-cgv.html#SP3_3">&#167;3.3</a>, <a href="5-cgv.html#SP3_4">&#167;3.4</a>, <a href="5-cgv.html#SP4">&#167;4</a>, <a href="5-cgv.html#SP5">&#167;5</a><br/>C Memory Model - <a href="5-cmm.html#SP2">&#167;2</a>, <a href="5-cmm.html#SP3">&#167;3</a>, <a href="5-cmm.html#SP4_2_2">&#167;4.2.2</a>, <a href="5-cmm.html#SP5">&#167;5</a>, <a href="5-cmm.html#SP7">&#167;7</a>, <a href="5-cmm.html#SP8">&#167;8</a><br/>C Assembly - <a href="5-cas.html#SP5_2">&#167;5.2</a>, <a href="5-cas.html#SP6">&#167;6</a><br/>C Arithmetic - <a href="5-car.html#SP1">&#167;1</a><br/>C Program Control - <a href="5-cpc.html#SP1">&#167;1</a>, <a href="5-cpc.html#SP2">&#167;2</a>, <a href="5-cpc.html#SP2_13">&#167;2.13</a><br/>C Conditions - <a href="5-ccn.html#SP1">&#167;1</a>, <a href="5-ccn.html#SP2">&#167;2</a><br/>C Literals - <a href="5-clt.html#SP2">&#167;2</a>, <a href="5-clt.html#SP3">&#167;3</a>, <a href="5-clt.html#SP4">&#167;4</a>, <a href="5-clt.html#SP5">&#167;5</a>, <a href="5-clt.html#SP7">&#167;7</a>, <a href="5-clt.html#SP8">&#167;8</a>, <a href="5-clt.html#SP10">&#167;10</a><br/>C Object Model - <a href="5-com.html#SP2">&#167;2</a>, <a href="5-com.html#SP4">&#167;4</a>, <a href="5-com.html#SP7">&#167;7</a>, <a href="5-com.html#SP10">&#167;10</a>, <a href="5-com.html#SP13">&#167;13</a>, <a href="5-com.html#SP16">&#167;16</a>, <a href="5-com.html#SP17">&#167;17</a>, <a href="5-com.html#SP20_1">&#167;20.1</a>, <a href="5-com.html#SP20_3">&#167;20.3</a>, <a href="5-com.html#SP24">&#167;24</a>, <a href="5-com.html#SP26">&#167;26</a>, <a href="5-com.html#SP34">&#167;34</a><br/>C Function Model - <a href="5-cfm.html#SP2">&#167;2</a>, <a href="5-cfm.html#SP4">&#167;4</a>, <a href="5-cfm.html#SP5">&#167;5</a>, <a href="5-cfm.html#SP6">&#167;6</a>, <a href="5-cfm.html#SP8">&#167;8</a>, <a href="5-cfm.html#SP10">&#167;10</a>, <a href="5-cfm.html#SP11">&#167;11</a>, <a href="5-cfm.html#SP12">&#167;12</a>, <a href="5-cfm.html#SP14_1">&#167;14.1</a>, <a href="5-cfm.html#SP14_2">&#167;14.2</a>, <a href="5-cfm.html#SP14_3">&#167;14.3</a>, <a href="5-cfm.html#SP15">&#167;15</a><br/>C Input-Output Model - <a href="5-cim.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">temporarily_diverted</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="identifier-syntax">temporarily_diverted_to</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="element-syntax">current_segment</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="identifier-syntax">current_segment</span><span class="plain-syntax">-&gt;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">generated_code</span><span class="plain-syntax">[</span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">pos</span><span class="plain-syntax">.</span><span class="element-syntax">current_layer</span><span class="plain-syntax">];</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>And then all we do is concatenate them in order:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::write_segments</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">CodeGen::write_segments</span></span>:<br/>Code Generators - <a href="2-cg2.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">seg</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">seg</span><span class="plain-syntax">, </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">segment_sequence</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP13" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">seg</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::write_additional_segments</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">seg</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">seg</span><span class="plain-syntax">, </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">segmentation</span><span class="plain-syntax">.</span><span class="element-syntax">additional_segment_sequence</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-cg.html#SP13" class="function-link"><span class="function-syntax">CodeGen::write_segment</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">seg</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::write_segment</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">CodeGen::write_segment</span></span>:<br/>Final C - <a href="5-fnc.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">generated_segment</span><span class="plain-syntax"> *</span><span class="identifier-syntax">seg</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;seg-&gt;</span><span class="element-syntax">layers</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">seg</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">generated_code</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Transients. </b>Transient flags on symbols are used temporarily during code generation, but do
not change the meaning of the tree: they're just a way to keep track of, say,
what we've worked on so far.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::clear_all_transients</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">CodeGen::clear_all_transients</span></span>:<br/>Code Generators - <a href="2-cg2.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">InterTree::traverse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><a href="2-cg.html#SP14" class="function-link"><span class="function-syntax">CodeGen::clear_transients</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">PACKAGE_IST</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::clear_transients</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Package::defined_by_frame</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Packages::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;T-&gt;</span><span class="identifier-syntax">size</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">])</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Inter::Symbols::clear_transient_flags</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>In particular the <span class="extract"><span class="extract-syntax">TRAVERSE_MARK_BIT</span></span> flag is sometimes convenient to use.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::marked</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">CodeGen::marked</span></span>:<br/>Vanilla Objects - <a href="2-vo.html#SP4_1_1_1">&#167;4.1.1.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Inter::Symbols::get_flag</span><span class="plain-syntax">(</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRAVERSE_MARK_BIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::mark</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">CodeGen::mark</span></span>:<br/>Vanilla Objects - <a href="2-vo.html#SP4_1_1_1">&#167;4.1.1.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Inter::Symbols::set_flag</span><span class="plain-syntax">(</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRAVERSE_MARK_BIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::unmark</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">CodeGen::unmark</span></span>:<br/>Vanilla Objects - <a href="2-vo.html#SP4_1">&#167;4.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Inter::Symbols::clear_flag</span><span class="plain-syntax">(</span><span class="identifier-syntax">symb_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRAVERSE_MARK_BIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Value pairs. </b>We will very often need to compile an expression from a pair <span class="extract"><span class="extract-syntax">val1</span></span>, <span class="extract"><span class="extract-syntax">val2</span></span>
extracted from some Inter instruction.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::pair_at_bookmark</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">CodeGen::pair_at_bookmark</span></span>:<br/><a href="2-cg.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">IBM</span><span class="plain-syntax">?(</span><span class="identifier-syntax">Inter::Bookmarks::scope</span><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">)):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-cg.html#SP16_1" class="named-paragraph-link"><span class="named-paragraph">Generate from a value pair</span><span class="named-paragraph-number">16.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CodeGen::pair</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">CodeGen::pair</span></span>:<br/>Vanilla Constants - <a href="2-vc.html#SP1_8">&#167;1.8</a>, <a href="2-vc.html#SP2">&#167;2</a><br/>Vanilla Objects - <a href="2-vo.html#SP4_1_1_1_1_1_1">&#167;4.1.1.1.1.1.1</a><br/>Vanilla Code - <a href="2-vc2.html#SP4">&#167;4</a><br/>Inform 6 Constants - <a href="4-i6c.html#SP3_1">&#167;3.1</a><br/>Inform 6 Global Variables - <a href="4-i6gv.html#SP2_2">&#167;2.2</a>, <a href="4-i6gv.html#SP2_4">&#167;2.4</a><br/>Inform 6 Objects - <a href="4-i6o.html#SP11">&#167;11</a><br/>C Global Variables - <a href="5-cgv.html#SP3_4">&#167;3.4</a><br/>C Object Model - <a href="5-com.html#SP21">&#167;21</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">code_generation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">val2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">?(</span><span class="identifier-syntax">Inter::Packages::scope_of</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">)):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-cg.html#SP16_1" class="named-paragraph-link"><span class="named-paragraph">Generate from a value pair</span><span class="named-paragraph-number">16.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16_1" class="paragraph-anchor"></a><b>&#167;16.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Generate from a value pair</span><span class="named-paragraph-number">16.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><span class="identifier-syntax">gen</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">from</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-cg.html#SP12" class="function-link"><span class="function-syntax">CodeGen::current</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">LITERAL_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_literal_number</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">val2</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Inter::Symbols::is_stored_in_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">val2</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InterSymbolsTables::symbol_from_data_pair_and_table</span><span class="plain-syntax">(</span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">val2</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">s</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"bad symbol in Inter pair"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_literal_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">s</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">DIVIDER_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">divider_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">" ! %S\n\t"</span><span class="plain-syntax">, </span><span class="identifier-syntax">divider_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">REAL_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">glob_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_literal_real</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">glob_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">DWORD_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">glob_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_dictionary_word</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">glob_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">PDWORD_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">glob_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_dictionary_word</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">glob_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">LITERAL_TEXT_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">glob_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-cg2.html#SP19" class="function-link"><span class="function-syntax">Generators::compile_literal_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">gen</span><span class="plain-syntax">, </span><span class="identifier-syntax">glob_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">GLOB_IVAL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">glob_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Inter::Warehouse::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">InterTree::warehouse</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">val2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">glob_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"unimplemented data pair"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-cg.html#SP16">&#167;16</a> (twice).</li></ul>
<nav role="progress"><div class="progresscontainer">
<ul class="progressbar"><li class="progressprev"><a href="1-fm.html">&#10094;</a></li><li class="progresschapter"><a href="1-fm.html">1</a></li><li class="progresscurrentchapter">2</li><li class="progresscurrent">cg</li><li class="progresssection"><a href="2-cg2.html">cg2</a></li><li class="progresssection"><a href="2-vnl.html">vnl</a></li><li class="progresssection"><a href="2-vc.html">vc</a></li><li class="progresssection"><a href="2-vf.html">vf</a></li><li class="progresssection"><a href="2-vo.html">vo</a></li><li class="progresssection"><a href="2-vc2.html">vc2</a></li><li class="progresssection"><a href="2-vi.html">vi</a></li><li class="progresschapter"><a href="3-fti.html">3</a></li><li class="progresschapter"><a href="4-fi6.html">4</a></li><li class="progresschapter"><a href="5-fnc.html">5</a></li><li class="progressnext"><a href="2-cg2.html">&#10095;</a></li></ul></div>
</nav><!--End of weave-->
</main>
</body>
</html>