1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00

Changed handling of memory Inter in pipeline language

This commit is contained in:
Graham Nelson 2019-07-20 18:42:20 +01:00
parent 0c0c148830
commit ab54c350d3
8 changed files with 56 additions and 14 deletions

View file

@ -30,6 +30,7 @@ have no meaningful contents when the step is not running.
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">the_PP</span><span class="plain">;</span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">the_PP</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">the_N</span><span class="plain">;</span> <span class="reserved">int</span><span class="plain"> </span><span class="identifier">the_N</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">to_debugging_log</span><span class="plain">;</span> <span class="reserved">int</span><span class="plain"> </span><span class="identifier">to_debugging_log</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">from_memory</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">repository_argument</span><span class="plain">;</span> <span class="reserved">int</span><span class="plain"> </span><span class="identifier">repository_argument</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">text_out_file</span><span class="plain">;</span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">text_out_file</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repository</span><span class="plain">;</span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repository</span><span class="plain">;</span>
@ -63,6 +64,7 @@ have no meaningful contents when the step is not running.
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;text_out_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;text_out_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;the_N</span><span class="plain"> = -1;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;the_N</span><span class="plain"> = -1;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;from_memory</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;the_PP</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;the_PP</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="plain">}</span> <span class="plain">}</span>
@ -156,6 +158,7 @@ logging:
<pre class="display"> <pre class="display">
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">struct</span><span class="plain"> </span><span class="reserved">codegen_pipeline</span><span class="plain"> {</span> <span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">struct</span><span class="plain"> </span><span class="reserved">codegen_pipeline</span><span class="plain"> {</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">variables</span><span class="plain">;</span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">variables</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">memory_repository</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repositories</span><span class="plain">[10];</span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repositories</span><span class="plain">[10];</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">linked_list</span><span class="plain"> *</span><span class="identifier">steps</span><span class="plain">; </span> <span class="comment">of <code class="display"><span class="extract">pipeline_step</span></code></span> <span class="reserved">struct</span><span class="plain"> </span><span class="identifier">linked_list</span><span class="plain"> *</span><span class="identifier">steps</span><span class="plain">; </span> <span class="comment">of <code class="display"><span class="extract">pipeline_step</span></code></span>
<span class="identifier">MEMORY_MANAGEMENT</span> <span class="identifier">MEMORY_MANAGEMENT</span>
@ -172,6 +175,7 @@ logging:
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="identifier">CREATE</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain">);</span> <span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="identifier">CREATE</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain">);</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;variables</span><span class="plain"> = </span><span class="identifier">D</span><span class="plain">;</span> <span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;variables</span><span class="plain"> = </span><span class="identifier">D</span><span class="plain">;</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain"> = </span><span class="identifier">NEW_LINKED_LIST</span><span class="plain">(</span><span class="reserved">pipeline_step</span><span class="plain">);</span> <span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain"> = </span><span class="identifier">NEW_LINKED_LIST</span><span class="plain">(</span><span class="reserved">pipeline_step</span><span class="plain">);</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;memory_repository</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0; </span><span class="identifier">i</span><span class="plain">&lt;10; </span><span class="identifier">i</span><span class="plain">++) </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">] = </span><span class="identifier">NULL</span><span class="plain">;</span> <span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0; </span><span class="identifier">i</span><span class="plain">&lt;10; </span><span class="identifier">i</span><span class="plain">++) </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">] = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">S</span><span class="plain">;</span> <span class="reserved">return</span><span class="plain"> </span><span class="identifier">S</span><span class="plain">;</span>
<span class="plain">}</span> <span class="plain">}</span>
@ -218,7 +222,7 @@ logging:
<span class="plain">}</span> <span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::set_repository</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain">) {</span> <span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::set_repository</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain">) {</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[0] = </span><span class="identifier">I</span><span class="plain">;</span> <span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;memory_repository</span><span class="plain"> = </span><span class="identifier">I</span><span class="plain">;</span>
<span class="plain">}</span> <span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain">, </span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">N</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">PP</span><span class="plain">) {</span> <span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain">, </span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">N</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">PP</span><span class="plain">) {</span>
@ -255,6 +259,8 @@ logging:
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">)) {</span> <span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*log"</span><span class="plain">)) {</span> <span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*log"</span><span class="plain">)) {</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*memory"</span><span class="plain">)) {</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;from_memory</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span> <span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">slashes</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span> <span class="reserved">int</span><span class="plain"> </span><span class="identifier">slashes</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
@ -285,7 +291,10 @@ logging:
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;text_out_file</span><span class="plain"> = </span><span class="identifier">T</span><span class="plain">;</span> <span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;text_out_file</span><span class="plain"> = </span><span class="identifier">T</span><span class="plain">;</span>
<span class="plain">}</span> <span class="plain">}</span>
<span class="identifier">active</span><span class="plain"> = (*(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;execute</span><span class="plain">))(</span><span class="identifier">step</span><span class="plain">);</span> <span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;from_memory</span><span class="plain">) &amp;&amp; (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain"> &gt;= 0))</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain">] = </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;memory_repository</span><span class="plain">;</span>
<span class="reserved">else</span>
<span class="identifier">active</span><span class="plain"> = (*(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;execute</span><span class="plain">))(</span><span class="identifier">step</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (((</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">TEXT_OUT_STAGE_ARG</span><span class="plain">) ||</span> <span class="reserved">if</span><span class="plain"> (((</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">TEXT_OUT_STAGE_ARG</span><span class="plain">) ||</span>
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">)) &amp;&amp;</span> <span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">)) &amp;&amp;</span>

View file

@ -574,6 +574,7 @@ list is not exhaustive.
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">existing_story_file</span><span class="plain"> == </span><span class="identifier">FALSE</span><span class="plain">) {</span> <span class="reserved">if</span><span class="plain"> (</span><span class="identifier">existing_story_file</span><span class="plain"> == </span><span class="identifier">FALSE</span><span class="plain">) {</span>
<span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::basic_dictionary</span><span class="plain">(</span> <span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::basic_dictionary</span><span class="plain">(</span>
<span class="identifier">Filenames::get_leafname</span><span class="plain">(</span><span class="identifier">filename_of_compiled_i6_code</span><span class="plain">));</span> <span class="identifier">Filenames::get_leafname</span><span class="plain">(</span><span class="identifier">filename_of_compiled_i6_code</span><span class="plain">));</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">Dictionaries::create_text</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*in"</span><span class="plain">), </span><span class="identifier">I</span><span class="string">"*memory"</span><span class="plain">);</span>
<span class="identifier">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span> <span class="identifier">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">inter_processing_file</span><span class="plain">)</span> <span class="reserved">if</span><span class="plain"> (</span><span class="identifier">inter_processing_file</span><span class="plain">)</span>
<span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">inter_processing_file</span><span class="plain">), </span><span class="identifier">D</span><span class="plain">);</span> <span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">inter_processing_file</span><span class="plain">), </span><span class="identifier">D</span><span class="plain">);</span>

View file

@ -127,11 +127,24 @@ no repositories, no variables.
</p> </p>
<p class="inwebparagraph">When a pipeline is being run by the main Inform 7 compiler, however, <p class="inwebparagraph">When a pipeline is being run by the main Inform 7 compiler, however,
repository <code class="display"><span class="extract">0</span></code> will be preloaded with the inter code Inform has generated two variables are created in advance. <code class="display"><span class="extract">*in</span></code> is set to the inter code
in memory. The variable <code class="display"><span class="extract">*out</span></code> is set to the filename to which final I6 code which Inform has generated on the current run, and <code class="display"><span class="extract">*out</span></code> is set to the
needs to be written, and the "domain" is the directory containing that. filename to which final I6 code needs to be written. The practical
The template search path is set to the one used in Inform, that is, the effect is that any useful pipeline for Inform will begin and end thus:
template file <code class="display"><span class="extract">Whatever.i6t</span></code> would be looked for first in the project's </p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">read: 0 &lt;- *in</span>
<span class="plain">...</span>
<span class="plain">generate: inform6 -&gt; *out</span>
</pre>
<p class="inwebparagraph">In addition, the "domain" is set to the directory containing the <code class="display"><span class="extract">*out</span></code>
file, and the template search path is set to the one used in Inform, that is,
the template file <code class="display"><span class="extract">Whatever.i6t</span></code> would be looked for first in the project's
<code class="display"><span class="extract">X.materials/I6T</span></code> directory, then in the user's <code class="display"><span class="extract">I6T</span></code> directory, and failing <code class="display"><span class="extract">X.materials/I6T</span></code> directory, then in the user's <code class="display"><span class="extract">I6T</span></code> directory, and failing
that in Inform's built-in one. that in Inform's built-in one.
</p> </p>

View file

@ -1,3 +1,4 @@
read: 0 <- *in
link: Output.i6t link: Output.i6t
parse-linked-matter parse-linked-matter
resolve-conditional-compilation resolve-conditional-compilation

View file

@ -1,3 +1,4 @@
read: 0 <- *in
link: Output.i6t link: Output.i6t
parse-linked-matter parse-linked-matter
resolve-conditional-compilation resolve-conditional-compilation

View file

@ -396,6 +396,7 @@ with "Output.i6t".
if (existing_story_file == FALSE) { if (existing_story_file == FALSE) {
dictionary *D = CodeGen::Pipeline::basic_dictionary( dictionary *D = CodeGen::Pipeline::basic_dictionary(
Filenames::get_leafname(filename_of_compiled_i6_code)); Filenames::get_leafname(filename_of_compiled_i6_code));
Str::copy(Dictionaries::create_text(D, I"*in"), I"*memory");
codegen_pipeline *SS = NULL; codegen_pipeline *SS = NULL;
if (inter_processing_file) if (inter_processing_file)
SS = CodeGen::Pipeline::parse_from_file(Filenames::from_text(inter_processing_file), D); SS = CodeGen::Pipeline::parse_from_file(Filenames::from_text(inter_processing_file), D);

View file

@ -71,11 +71,18 @@ As the above implies, Inter pipelines normally begin with a clean slate:
no repositories, no variables. no repositories, no variables.
When a pipeline is being run by the main Inform 7 compiler, however, When a pipeline is being run by the main Inform 7 compiler, however,
repository |0| will be preloaded with the inter code Inform has generated two variables are created in advance. |*in| is set to the inter code
in memory. The variable |*out| is set to the filename to which final I6 code which Inform has generated on the current run, and |*out| is set to the
needs to be written, and the "domain" is the directory containing that. filename to which final I6 code needs to be written. The practical
The template search path is set to the one used in Inform, that is, the effect is that any useful pipeline for Inform will begin and end thus:
template file |Whatever.i6t| would be looked for first in the project's
|read: 0 <- *in|
|...|
|generate: inform6 -> *out|
In addition, the "domain" is set to the directory containing the |*out|
file, and the template search path is set to the one used in Inform, that is,
the template file |Whatever.i6t| would be looked for first in the project's
|X.materials/I6T| directory, then in the user's |I6T| directory, and failing |X.materials/I6T| directory, then in the user's |I6T| directory, and failing
that in Inform's built-in one. that in Inform's built-in one.

View file

@ -18,6 +18,7 @@ typedef struct pipeline_step {
struct pathname **the_PP; struct pathname **the_PP;
int the_N; int the_N;
int to_debugging_log; int to_debugging_log;
int from_memory;
int repository_argument; int repository_argument;
struct text_stream *text_out_file; struct text_stream *text_out_file;
struct inter_repository *repository; struct inter_repository *repository;
@ -42,6 +43,7 @@ void CodeGen::Pipeline::clean_step(pipeline_step *step) {
step->text_out_file = NULL; step->text_out_file = NULL;
step->the_N = -1; step->the_N = -1;
step->to_debugging_log = FALSE; step->to_debugging_log = FALSE;
step->from_memory = FALSE;
step->the_PP = NULL; step->the_PP = NULL;
step->repository = NULL; step->repository = NULL;
} }
@ -118,6 +120,7 @@ And then a pipeline is just a linked list of steps.
= =
typedef struct codegen_pipeline { typedef struct codegen_pipeline {
struct dictionary *variables; struct dictionary *variables;
struct inter_repository *memory_repository;
struct inter_repository *repositories[10]; struct inter_repository *repositories[10];
struct linked_list *steps; /* of |pipeline_step| */ struct linked_list *steps; /* of |pipeline_step| */
MEMORY_MANAGEMENT MEMORY_MANAGEMENT
@ -134,6 +137,7 @@ codegen_pipeline *CodeGen::Pipeline::new(dictionary *D) {
codegen_pipeline *S = CREATE(codegen_pipeline); codegen_pipeline *S = CREATE(codegen_pipeline);
S->variables = D; S->variables = D;
S->steps = NEW_LINKED_LIST(pipeline_step); S->steps = NEW_LINKED_LIST(pipeline_step);
S->memory_repository = NULL;
for (int i=0; i<10; i++) S->repositories[i] = NULL; for (int i=0; i<10; i++) S->repositories[i] = NULL;
return S; return S;
} }
@ -180,7 +184,7 @@ void CodeGen::Pipeline::parse_into(codegen_pipeline *S, text_stream *instruction
} }
void CodeGen::Pipeline::set_repository(codegen_pipeline *S, inter_repository *I) { void CodeGen::Pipeline::set_repository(codegen_pipeline *S, inter_repository *I) {
S->repositories[0] = I; S->memory_repository = I;
} }
void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **PP) { void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **PP) {
@ -217,6 +221,8 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **
(step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG)) { (step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG)) {
if (Str::eq(step->step_argument, I"*log")) { if (Str::eq(step->step_argument, I"*log")) {
step->to_debugging_log = TRUE; step->to_debugging_log = TRUE;
} else if (Str::eq(step->step_argument, I"*memory")) {
step->from_memory = TRUE;
} else { } else {
step->parsed_filename = Filenames::from_text(step->step_argument); step->parsed_filename = Filenames::from_text(step->step_argument);
int slashes = FALSE; int slashes = FALSE;
@ -247,7 +253,10 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **
step->text_out_file = T; step->text_out_file = T;
} }
active = (*(step->step_stage->execute))(step); if ((step->from_memory) && (step->repository_argument >= 0))
S->repositories[step->repository_argument] = S->memory_repository;
else
active = (*(step->step_stage->execute))(step);
if (((step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) || if (((step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) ||
(step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG)) && (step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG)) &&