From 5c27d8894cb52dfe1e52d8887b69650be06bc217 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sat, 20 Jul 2019 23:29:50 +0100 Subject: [PATCH] Decluttered inter pipeline mini-language --- docs/codegen-module/1-ppl.html | 67 ++++++----- docs/codegen-module/1-stg.html | 28 +++-- docs/codegen-module/2-alm.html | 50 ++++---- docs/codegen-module/2-erl.html | 2 +- docs/codegen-module/2-erm.html | 2 +- docs/codegen-module/2-lnk.html | 88 +++++++------- docs/codegen-module/2-plm.html | 2 +- docs/codegen-module/2-rcc.html | 2 +- docs/codegen-module/2-res.html | 2 +- docs/codegen-module/2-rv.html | 2 +- docs/codegen-module/2-unq.html | 2 +- docs/codegen-module/3-ip.html | 4 +- docs/codegen-module/3-tv.html | 2 +- docs/codegen-module/4-cg.html | 2 +- docs/inter/P-pas.html | 111 +++++++++++++----- docs/inter/P-ui.html | 2 +- inform7/Internal/Inter/default.interpipeline | 6 +- inform7/Tests/test-pl.interpipeline | 6 +- inter/Preliminaries/Pipelines and Stages.w | 73 ++++++++---- inter/Preliminaries/Using Inter.w | 2 +- .../General/_Pipelines/Assim.interpipeline | 4 +- .../General/_Pipelines/Cons.interpipeline | 4 +- .../General/_Pipelines/EasyRCC.interpipeline | 4 +- .../_Pipelines/IftrueRCC.interpipeline | 4 +- .../General/_Pipelines/ObjKind.interpipeline | 4 +- .../General/_Pipelines/PLM.interpipeline | 4 +- .../_Pipelines/Predeclared.interpipeline | 4 +- .../_Pipelines/Primitives.interpipeline | 4 +- .../_Pipelines/Redundancies.interpipeline | 4 +- .../_Pipelines/SimpleKind.interpipeline | 4 +- .../_Pipelines/SimpleRoutines.interpipeline | 4 +- inter/codegen-module/Chapter 1/Pipelines.w | 69 ++++++----- inter/codegen-module/Chapter 1/Stages.w | 26 ++-- inter/codegen-module/Chapter 2/Assimilate.w | 50 ++++---- .../Chapter 2/Eliminate Redundant Labels.w | 2 +- .../Chapter 2/Eliminate Redundant Matter.w | 2 +- .../Chapter 2/{Linker.w => Merge Template.w} | 60 +++++----- .../Chapter 2/Parse Linked Matter.w | 2 +- .../Chapter 2/Reconcile Verbs.w | 2 +- .../Chapter 2/Resolve External Symbols.w | 2 +- .../Resolving Conditional Compilation.w | 2 +- inter/codegen-module/Chapter 2/Uniqueness.w | 2 +- .../Chapter 3/Inter Primitives.w | 4 +- inter/codegen-module/Chapter 3/The Veneer.w | 2 +- .../Chapter 4/Code Generation.w | 2 +- inter/codegen-module/Contents.w | 2 +- 46 files changed, 422 insertions(+), 306 deletions(-) rename inter/codegen-module/Chapter 2/{Linker.w => Merge Template.w} (76%) diff --git a/docs/codegen-module/1-ppl.html b/docs/codegen-module/1-ppl.html index 0271478ad..ea8fb9780 100644 --- a/docs/codegen-module/1-ppl.html +++ b/docs/codegen-module/1-ppl.html @@ -42,7 +42,7 @@ have no meaningful contents when the step is not running. step->step_stage = NULL; step->step_argument = NULL; step->package_argument = NULL; - step->repository_argument = -1; + step->repository_argument = 0; CodeGen::Pipeline::clean_step(step); return step; } @@ -83,11 +83,10 @@ logging: void CodeGen::Pipeline::write_step(OUTPUT_STREAM, pipeline_step *step) { WRITE("%S", step->step_stage->stage_name); if (step->step_stage->stage_arg != NO_STAGE_ARG) { - if (step->package_argument) WRITE(" %S", step->package_argument); - WRITE(":"); - if (step->repository_argument >= 0) WRITE(" %d <-", step->repository_argument); - if (step->target_argument) WRITE(" %S ->", step->target_argument->target_name); - WRITE(" %S", step->step_argument); + WRITE(" %d", step->repository_argument); + if (Str::len(step->package_argument) > 0) WRITE(":%S", step->package_argument); + if (step->step_stage->takes_repository >= 0) WRITE(" <- %S", step->step_argument); + if (step->target_argument) WRITE(" %S -> %S", step->target_argument->target_name, step->step_argument); } } @@ -96,11 +95,12 @@ logging: CodeGen::Targets::make_targets(); pipeline_step *ST = CodeGen::Pipeline::new_step(); match_results mr = Regexp::create_mr(); - if (Regexp::match(&mr, step, L"(%c+?) *: *(%d) *<- *(%c*)")) { - ST->repository_argument = Str::atoi(mr.exp[1], 0); - ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); + int left_arrow_used = FALSE; + if (Regexp::match(&mr, step, L"(%c+?) *<- *(%c*)")) { + ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); Str::copy(step, mr.exp[0]); - } else if (Regexp::match(&mr, step, L"(%c+?) *: *(%C*) *-> *(%c*)")) { + left_arrow_used = TRUE; + } else if (Regexp::match(&mr, step, L"(%c+?) *(%C*) *-> *(%c*)")) { code_generation_target *cgt; LOOP_OVER(cgt, code_generation_target) if (Str::eq(mr.exp[1], cgt->target_name)) @@ -111,11 +111,15 @@ logging: } ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); Str::copy(step, mr.exp[0]); - } else if (Regexp::match(&mr, step, L"(%c+?) *: *(%c*)")) { - ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); - Str::copy(step, mr.exp[0]); } - if (Regexp::match(&mr, step, L"(%C+?) (%c+)")) { + if (Regexp::match(&mr, step, L"(%C+?) (%d)")) { + ST->repository_argument = Str::atoi(mr.exp[1], 0); + Str::copy(step, mr.exp[0]); + } else if (Regexp::match(&mr, step, L"(%C+?) (%d):(%c*)")) { + ST->repository_argument = Str::atoi(mr.exp[1], 0); + ST->package_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); + Str::copy(step, mr.exp[0]); + } else if (Regexp::match(&mr, step, L"(%C+?) (%c+)")) { ST->package_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); Str::copy(step, mr.exp[0]); } @@ -128,6 +132,14 @@ logging: WRITE_TO(STDERR, "No such step as '%S'\n", step); internal_error("no such step code"); } + if (ST->step_stage->takes_repository) { + if (left_arrow_used == FALSE) + internal_error("should use a left arrow"); + } else { + if (left_arrow_used) + internal_error("should not use a left arrow"); + } + Regexp::dispose_of(&mr); return ST; } @@ -227,19 +239,21 @@ logging: void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **PP) { if (S == NULL) return; - if (S->repositories[0] == NULL) S->repositories[0] = Inter::create(1, 32); clock_t start = clock(); int step_count = 0, step_total = 0; pipeline_step *step; LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps) step_total++; - int active = TRUE, current_repo = 0; - CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]); + int active = TRUE; LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps) if (active) { - inter_repository *I = S->repositories[current_repo]; + if (S->repositories[step->repository_argument] == NULL) + S->repositories[step->repository_argument] = Inter::create(1, 32); + inter_repository *I = S->repositories[step->repository_argument]; + if (I == NULL) internal_error("no repository"); CodeGen::Pipeline::lint(I); + CodeGen::Pipeline::prepare_to_run(I); CodeGen::Pipeline::clean_step(step); step->the_N = N; @@ -253,6 +267,8 @@ logging: Log::new_stage(STAGE_NAME); DISCARD_TEXT(STAGE_NAME); + int skip_step = FALSE; + if ((step->step_stage->stage_arg == FILE_STAGE_ARG) || (step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) || (step->step_stage->stage_arg == EXT_FILE_STAGE_ARG) || @@ -260,9 +276,9 @@ logging: if (Str::eq(step->step_argument, I"*log")) { step->to_debugging_log = TRUE; } else if (Str::eq(step->step_argument, I"*memory")) { - step->from_memory = TRUE; + S->repositories[step->repository_argument] = S->memory_repository; + skip_step = TRUE; } else { - step->parsed_filename = Filenames::from_text(step->step_argument); int slashes = FALSE; LOOP_THROUGH_TEXT(pos, step->step_argument) if (Str::get(pos) == '/') @@ -291,9 +307,7 @@ logging: step->text_out_file = T; } - if ((step->from_memory) && (step->repository_argument >= 0)) - S->repositories[step->repository_argument] = S->memory_repository; - else + if (skip_step == FALSE) active = (*(step->step_stage->execute))(step); if (((step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) || @@ -301,11 +315,6 @@ logging: (step->to_debugging_log == FALSE)) { STREAM_CLOSE(T); } - - if (step->repository_argument >= 0) { - current_repo = step->repository_argument; - CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]); - } } } @@ -419,7 +428,7 @@ logging: internal_error("zap"); } - CodeGen::Link::guard(Inter::Defn::verify_children_inner(P)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_children_inner(P)); } diff --git a/docs/codegen-module/1-stg.html b/docs/codegen-module/1-stg.html index ac100b8a6..d57ab5ad1 100644 --- a/docs/codegen-module/1-stg.html +++ b/docs/codegen-module/1-stg.html @@ -21,6 +21,7 @@ write output to; others are not.
     enum NO_STAGE_ARG from 1
+    enum GENERAL_STAGE_ARG
     enum FILE_STAGE_ARG
     enum TEXT_OUT_STAGE_ARG
     enum EXT_FILE_STAGE_ARG
@@ -33,14 +34,16 @@ write output to; others are not.
         struct text_stream *stage_name;
         int (*execute)(void *);
         int stage_arg;     one of the *_ARG values above
+        int takes_repository;
         MEMORY_MANAGEMENT
     } pipeline_stage;
 
-    pipeline_stage *CodeGen::Stage::new(text_stream *name, int (*X)(struct pipeline_step *), int arg) {
+    pipeline_stage *CodeGen::Stage::new(text_stream *name, int (*X)(struct pipeline_step *), int arg, int tr) {
         pipeline_stage *stage = CREATE(pipeline_stage);
         stage->stage_name = Str::duplicate(name);
         stage->execute = (int (*)(void *)) X;
         stage->stage_arg = arg;
+        stage->takes_repository = tr;
         return stage;
     }
 
@@ -62,15 +65,17 @@ to the routine below. void CodeGen::Stage::make_stages(void) { if (stages_made == FALSE) { stages_made = TRUE; - CodeGen::Stage::new(I"stop", CodeGen::Stage::run_stop_stage, NO_STAGE_ARG); - CodeGen::Stage::new(I"read", CodeGen::Stage::run_read_stage, FILE_STAGE_ARG); + CodeGen::Stage::new(I"stop", CodeGen::Stage::run_stop_stage, NO_STAGE_ARG, FALSE); + + CodeGen::Stage::new(I"read", CodeGen::Stage::run_read_stage, FILE_STAGE_ARG, TRUE); + CodeGen::Stage::new(I"extract", CodeGen::Stage::run_extract_stage, GENERAL_STAGE_ARG, TRUE); CodeGen::create_pipeline_stage(); CodeGen::Assimilate::create_pipeline_stage(); CodeGen::Eliminate::create_pipeline_stage(); CodeGen::Externals::create_pipeline_stage(); CodeGen::Labels::create_pipeline_stage(); - CodeGen::Link::create_pipeline_stage(); + CodeGen::MergeTemplate::create_pipeline_stage(); CodeGen::PLM::create_pipeline_stage(); CodeGen::RCC::create_pipeline_stage(); CodeGen::ReconcileVerbs::create_pipeline_stage(); @@ -94,11 +99,14 @@ the pipeline: } int CodeGen::Stage::run_read_stage(pipeline_step *step) { - filename *F = Filenames::from_text(step->step_argument); - if (Inter::Binary::test_file(F)) - Inter::Binary::read(step->repository, F); - else - Inter::Textual::read(step->repository, F); + filename *F = step->parsed_filename; + if (Inter::Binary::test_file(F)) Inter::Binary::read(step->repository, F); + else Inter::Textual::read(step->repository, F); + return TRUE; + } + + int CodeGen::Stage::run_extract_stage(pipeline_step *step) { + LOG("Arg is %S.\n", step->step_argument); return TRUE; } @@ -109,6 +117,8 @@ the pipeline:

The function CodeGen::Stage::run_read_stage is used in §2.

+

The function CodeGen::Stage::run_extract_stage is used in §2.

+

diff --git a/docs/codegen-module/2-alm.html b/docs/codegen-module/2-alm.html index 2fc6668f7..da1596d26 100644 --- a/docs/codegen-module/2-alm.html +++ b/docs/codegen-module/2-alm.html @@ -18,7 +18,7 @@
     void CodeGen::Assimilate::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"assimilate", CodeGen::Assimilate::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"assimilate", CodeGen::Assimilate::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int no_assimilated_actions = 0;
@@ -32,7 +32,7 @@
         no_assimilated_actions = 0;
         no_assimilated_commands = 0;
         no_assimilated_arrays = 0;
-        CodeGen::Link::ensure_search_list(I);
+        CodeGen::MergeTemplate::ensure_search_list(I);
         Inter::traverse_tree(I, CodeGen::Assimilate::visitor1, NULL, NULL, SPLAT_IST);
         Inter::traverse_tree(I, CodeGen::Assimilate::visitor2, NULL, NULL, SPLAT_IST);
         CodeGen::Assimilate::function_bodies();
@@ -138,7 +138,7 @@
             <Parse text of splat for identifier and value 2.1.1>;
             if ((proceed) && (unchecked_kind_symbol)) {
                 if (plm == DEFAULT_PLM) {
-                    inter_symbol *symbol = CodeGen::Link::find_name(I, identifier, TRUE);
+                    inter_symbol *symbol = CodeGen::MergeTemplate::find_name(I, identifier, TRUE);
                     if (symbol == NULL) plm = CONSTANT_PLM;
                 }
                 if (plm != DEFAULT_PLM) <Act on parsed constant definition 2.1.2>;
@@ -255,7 +255,7 @@
                 case FAKEACTION_PLM:
                 case OBJECT_PLM: {
                     <Assimilate a value 2.1.2.2>;
-                    CodeGen::Link::guard(Inter::Constant::new_numerical(IBM,
+                    CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM,
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name),
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol), v1, v2,
                         (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
@@ -264,7 +264,7 @@
                 }
                 case GLOBAL_PLM:
                     <Assimilate a value 2.1.2.2>;
-                    CodeGen::Link::guard(Inter::Variable::new(IBM,
+                    CodeGen::MergeTemplate::guard(Inter::Variable::new(IBM,
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name),
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol), v1, v2,
                         (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
@@ -277,7 +277,7 @@
 
                     if ((attr_symbol == NULL) || (!Inter::Symbols::is_defined(attr_symbol))) {
                         if (attr_symbol == NULL) attr_symbol = con_name;
-                        CodeGen::Link::guard(Inter::Property::new(IBM,
+                        CodeGen::MergeTemplate::guard(Inter::Property::new(IBM,
                             Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), attr_symbol),
                             Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), truth_state_kind_symbol),
                             (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
@@ -303,7 +303,7 @@
                     break;
                 }
                 case PROPERTY_PLM: {
-                    CodeGen::Link::guard(Inter::Property::new(IBM,
+                    CodeGen::MergeTemplate::guard(Inter::Property::new(IBM,
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name),
                         Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol),
                         (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
@@ -382,7 +382,7 @@
                         array_in_progress.data[pos++] = v1_pile[i];
                         array_in_progress.data[pos++] = v2_pile[i];
                     }
-                    CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress));
+                    CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress));
                     Inter::Frame::insert(array_in_progress, IBM);
 
                     if (plm == ARRAY_PLM) {
@@ -529,12 +529,12 @@
                     if (Str::len(value) == 0) break;
                     inter_symbol *loc_name = Inter::SymbolsTables::create_with_unique_name(Inter::Package::local_symbols(block_name), value);
                     Inter::Symbols::local(loc_name);
-                    CodeGen::Link::guard(Inter::Local::new(IBM, block_name, loc_name, unchecked_kind_symbol, 0, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
+                    CodeGen::MergeTemplate::guard(Inter::Local::new(IBM, block_name, loc_name, unchecked_kind_symbol, 0, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
                     DISCARD_TEXT(value);
                 }
             }
 
-            CodeGen::Link::guard(Inter::Code::new(IBM, (int) (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
+            CodeGen::MergeTemplate::guard(Inter::Code::new(IBM, (int) (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
             if (Str::len(body) > 0) {
                 int L = Str::len(body) - 1;
                 while ((L>0) && (Str::get_at(body, L) != ']')) L--;
@@ -547,7 +547,7 @@
 
             inter_symbol *rsymb = CodeGen::Assimilate::maybe_extern(I, identifier, Inter::Bookmarks::scope(IBM));
             Inter::Symbols::annotate_i(I, rsymb, ASSIMILATED_IANN, 1);
-            CodeGen::Link::guard(Inter::Constant::new_function(IBM,
+            CodeGen::MergeTemplate::guard(Inter::Constant::new_function(IBM,
                 Inter::SymbolsTables::id_from_symbol(I, FP, rsymb),
                 Inter::SymbolsTables::id_from_symbol(I, FP, unchecked_function_symbol),
                 Inter::SymbolsTables::id_from_symbol(I, FP, block_name),
@@ -573,7 +573,7 @@
     
         inter_package *CodeGen::Assimilate::new_package(inter_bookmark *IBM, inter_symbol *pname, inter_symbol *ptype) {
             inter_package *P = NULL;
-            CodeGen::Link::guard(Inter::Package::new_package(IBM, pname,
+            CodeGen::MergeTemplate::guard(Inter::Package::new_package(IBM, pname,
                 ptype, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL, &P));
             return P;
         }
@@ -650,7 +650,7 @@
 
     
         void CodeGen::Assimilate::ensure_action(inter_repository *I, inter_frame P, text_stream *value) {
-            if (CodeGen::Link::find_name(I, value, TRUE) == NULL) {
+            if (CodeGen::MergeTemplate::find_name(I, value, TRUE) == NULL) {
                 inter_bookmark IBM_d = CodeGen::Assimilate::template_submodule(I, I"actions", P);
                 inter_bookmark *IBM = &IBM_d;
                 TEMPORARY_TEXT(an);
@@ -665,16 +665,16 @@
                 WRITE_TO(unsharped, "%SSub", value);
                 Str::delete_first_character(unsharped);
                 Str::delete_first_character(unsharped);
-                inter_symbol *txsymb = CodeGen::Link::find_name(I, unsharped, TRUE);
+                inter_symbol *txsymb = CodeGen::MergeTemplate::find_name(I, unsharped, TRUE);
                 inter_symbol *xsymb = Inter::SymbolsTables::create_with_unique_name(Inter::Bookmarks::scope(IBM), unsharped);
                 if (txsymb) Inter::SymbolsTables::equate(xsymb, txsymb);
                 DISCARD_TEXT(unsharped);
-                CodeGen::Link::guard(Inter::Constant::new_numerical(IBM,
+                CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM,
                     Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), asymb),
                     Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), action_kind_symbol),
                     LITERAL_IVAL, 10000, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL));
                 Inter::Symbols::annotate_i(I, asymb, ACTION_IANN, 1);
-                CodeGen::Link::build_r(Inter::Bookmarks::package(IBM));
+                CodeGen::MergeTemplate::build_r(Inter::Bookmarks::package(IBM));
             }
         }
     
@@ -778,7 +778,7 @@ } match_results mr = Regexp::create_mr(); if (Regexp::match(&mr, S, L"scope=(%i+)")) { - inter_symbol *symb = CodeGen::Link::find_name(I, mr.exp[0], TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, mr.exp[0], TRUE); while ((symb) && (symb->equated_to)) symb = symb->equated_to; if (symb) { if (Inter::Symbols::read_annotation(symb, SCOPE_FILTER_IANN) != 1) @@ -787,7 +787,7 @@ } } if (Regexp::match(&mr, S, L"noun=(%i+)")) { - inter_symbol *symb = CodeGen::Link::find_name(I, mr.exp[0], TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, mr.exp[0], TRUE); while ((symb) && (symb->equated_to)) symb = symb->equated_to; if (symb) { if (Inter::Symbols::read_annotation(symb, NOUN_FILTER_IANN) != 1) @@ -797,7 +797,7 @@ } } - inter_symbol *symb = CodeGen::Link::find_name(I, S, TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, S, TRUE); if (symb) { Inter::Symbols::to_data(I, pack, symb, val1, val2); return; } @@ -822,7 +822,7 @@ Str::copy(glob_storage, sch->converted_from); inter_symbol *mcc_name = CodeGen::Assimilate::computed_constant_symbol(pack); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, pack, mcc_name), Inter::SymbolsTables::id_from_symbol(I, pack, unchecked_kind_symbol), GLOB_IVAL, ID, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -865,7 +865,7 @@ inter_t v1 = UNDEF_IVAL, v2 = 0; switch (t->ist_type) { case IDENTIFIER_ISTT: { - inter_symbol *symb = CodeGen::Link::find_name(I, t->material, TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, t->material, TRUE); if (symb) return symb; LOG("Failed to identify %S\n", t->material); break; @@ -880,7 +880,7 @@ } if (v1 == UNDEF_IVAL) return NULL; inter_symbol *mcc_name = CodeGen::Assimilate::computed_constant_symbol(pack); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, pack, mcc_name), Inter::SymbolsTables::id_from_symbol(I, pack, unchecked_kind_symbol), v1, v2, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -898,7 +898,7 @@ internal_error("can't extend frame"); array_in_progress.data[pos] = LITERAL_IVAL; array_in_progress.data[pos+1] = 0; Inter::Symbols::to_data(I, pack, i1, &(array_in_progress.data[pos+2]), &(array_in_progress.data[pos+3])); - CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); Inter::Frame::insert(array_in_progress, IBM); return mcc_name; } @@ -912,7 +912,7 @@ internal_error("can't extend frame"); Inter::Symbols::to_data(I, pack, i1, &(array_in_progress.data[pos]), &(array_in_progress.data[pos+1])); Inter::Symbols::to_data(I, pack, i2, &(array_in_progress.data[pos+2]), &(array_in_progress.data[pos+3])); - CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); Inter::Frame::insert(array_in_progress, IBM); return mcc_name; } @@ -952,7 +952,7 @@ return TRUE; #endif #ifndef CORE_MODULE - CodeGen::Link::entire_splat(IBM, NULL, body, offset, block_name); + CodeGen::MergeTemplate::entire_splat(IBM, NULL, body, offset, block_name); LOG("Splat %d\n", rb_splat_count++); return FALSE; #endif diff --git a/docs/codegen-module/2-erl.html b/docs/codegen-module/2-erl.html index b31cfd34d..515bc2bf9 100644 --- a/docs/codegen-module/2-erl.html +++ b/docs/codegen-module/2-erl.html @@ -26,7 +26,7 @@ on the Inter functions in a repository.
     void CodeGen::Labels::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"eliminate-redundant-labels", CodeGen::Labels::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"eliminate-redundant-labels", CodeGen::Labels::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::Labels::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/2-erm.html b/docs/codegen-module/2-erm.html
index ee75c7f25..115857199 100644
--- a/docs/codegen-module/2-erm.html
+++ b/docs/codegen-module/2-erm.html
@@ -25,7 +25,7 @@ isn't used.
 
     void CodeGen::Eliminate::create_pipeline_stage(void) {
         CodeGen::Stage::new(I"eliminate-redundant-code",
-            CodeGen::Eliminate::run_pipeline_stage, NO_STAGE_ARG);
+            CodeGen::Eliminate::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::Eliminate::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/2-lnk.html b/docs/codegen-module/2-lnk.html
index 6b6989549..7acaf2da2 100644
--- a/docs/codegen-module/2-lnk.html
+++ b/docs/codegen-module/2-lnk.html
@@ -17,23 +17,23 @@
 
 
 
-    void CodeGen::Link::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"link", CodeGen::Link::run_pipeline_stage, TEMPLATE_FILE_STAGE_ARG);
+    void CodeGen::MergeTemplate::create_pipeline_stage(void) {
+        CodeGen::Stage::new(I"merge-template", CodeGen::MergeTemplate::run_pipeline_stage, TEMPLATE_FILE_STAGE_ARG, TRUE);
     }
 
-    int CodeGen::Link::run_pipeline_stage(pipeline_step *step) {
+    int CodeGen::MergeTemplate::run_pipeline_stage(pipeline_step *step) {
         inter_package *main_package = Inter::Packages::main(step->repository);
         inter_bookmark IBM;
         if (main_package) IBM = Inter::Bookmarks::at_end_of_this_package(main_package);
         else IBM = Inter::Bookmarks::at_start_of_this_repository(step->repository);
-        CodeGen::Link::link(&IBM, step->step_argument, step->the_N, step->the_PP, NULL);
+        CodeGen::MergeTemplate::link(&IBM, step->step_argument, step->the_N, step->the_PP, NULL);
         return TRUE;
     }
 
     inter_symbols_table *link_search_list[10];
     int link_search_list_len = 0;
 
-    void CodeGen::Link::ensure_search_list(inter_repository *I) {
+    void CodeGen::MergeTemplate::ensure_search_list(inter_repository *I) {
         if (link_search_list_len == 0) {
             if (template_package) {
                 link_search_list[1] = Inter::Packages::scope(Inter::Packages::main(I));
@@ -46,29 +46,29 @@
         }
     }
 
-    void CodeGen::Link::link(inter_bookmark *IBM, text_stream *template_file, int N, pathname **PP, inter_package *owner) {
+    void CodeGen::MergeTemplate::link(inter_bookmark *IBM, text_stream *template_file, int N, pathname **PP, inter_package *owner) {
         if (IBM == NULL) internal_error("no inter to link with");
         inter_repository *I = IBM->read_into;
-        Inter::traverse_tree(I, CodeGen::Link::visitor, NULL, NULL, 0);
+        Inter::traverse_tree(I, CodeGen::MergeTemplate::visitor, NULL, NULL, 0);
 
         if (template_package == NULL) internal_error("unable to find template");
 
-        CodeGen::Link::ensure_search_list(I);
+        CodeGen::MergeTemplate::ensure_search_list(I);
 
         inter_bookmark link_bookmark =
             Inter::Bookmarks::at_end_of_this_package(template_package);
 
-        I6T_kit kit = TemplateReader::kit_out(&link_bookmark, &(CodeGen::Link::receive_raw),  &(CodeGen::Link::receive_command), NULL);
+        I6T_kit kit = TemplateReader::kit_out(&link_bookmark, &(CodeGen::MergeTemplate::receive_raw),  &(CodeGen::MergeTemplate::receive_command), NULL);
         kit.no_i6t_file_areas = N;
         for (int i=0; i<N; i++) kit.i6t_files[i] = PP[i];
         TEMPORARY_TEXT(T);
         TemplateReader::I6T_file_intervene(T, EARLY_LINK_STAGE, NULL, NULL, &kit);
-        CodeGen::Link::receive_raw(T, &kit);
+        CodeGen::MergeTemplate::receive_raw(T, &kit);
         DISCARD_TEXT(T);
         TemplateReader::extract(template_file, &kit);
     }
 
-    void CodeGen::Link::visitor(inter_repository *I, inter_frame P, void *state) {
+    void CodeGen::MergeTemplate::visitor(inter_repository *I, inter_frame P, void *state) {
         if (P.data[ID_IFLD] == LINK_IST) {
             text_stream *S1 = Inter::get_text(P.repo_segment->owning_repo, P.data[SEGMENT_LINK_IFLD]);
             text_stream *S2 = Inter::get_text(P.repo_segment->owning_repo, P.data[PART_LINK_IFLD]);
@@ -82,7 +82,7 @@
     dictionary *linkable_namespace = NULL;
     int linkable_namespace_created = FALSE;
 
-    inter_symbol *CodeGen::Link::find_in_namespace(inter_repository *I, text_stream *name) {
+    inter_symbol *CodeGen::MergeTemplate::find_in_namespace(inter_repository *I, text_stream *name) {
         if (linkable_namespace_created == FALSE) {
             linkable_namespace_created = TRUE;
             linkable_namespace = Dictionaries::new(512, FALSE);
@@ -93,7 +93,7 @@
                     if (C.data[ID_IFLD] == PACKAGE_IST) {
                         inter_package *P = Inter::Package::defined_by_frame(C);
                         if (Str::ne(P->package_name->symbol_name, I"template"))
-                            CodeGen::Link::build_r(P);
+                            CodeGen::MergeTemplate::build_r(P);
                     }
                 }
 
@@ -104,18 +104,18 @@
         return NULL;
     }
 
-    void CodeGen::Link::build_r(inter_package *P) {
-        CodeGen::Link::build_only(P);
+    void CodeGen::MergeTemplate::build_r(inter_package *P) {
+        CodeGen::MergeTemplate::build_only(P);
         inter_frame D = Inter::Symbols::defining_frame(P->package_name);
         LOOP_THROUGH_INTER_CHILDREN(C, D) {
             if (C.data[ID_IFLD] == PACKAGE_IST) {
                 inter_package *Q = Inter::Package::defined_by_frame(C);
-                CodeGen::Link::build_r(Q);
+                CodeGen::MergeTemplate::build_r(Q);
             }
         }
     }
 
-    void CodeGen::Link::build_only(inter_package *P) {
+    void CodeGen::MergeTemplate::build_only(inter_package *P) {
         inter_symbols_table *T = Inter::Packages::scope(P);
         if (T) {
             for (int i=0; i<T->size; i++) {
@@ -131,19 +131,19 @@
         }
     }
 
-    inter_symbol *CodeGen::Link::find_name(inter_repository *I, text_stream *S, int deeply) {
+    inter_symbol *CodeGen::MergeTemplate::find_name(inter_repository *I, text_stream *S, int deeply) {
         for (int i=0; i<link_search_list_len; i++) {
             inter_symbol *symb = Inter::SymbolsTables::symbol_from_name_not_equating(link_search_list[i], S);
             if (symb) return symb;
         }
         if (deeply) {
-            inter_symbol *symb = CodeGen::Link::find_in_namespace(I, S);
+            inter_symbol *symb = CodeGen::MergeTemplate::find_in_namespace(I, S);
             if (symb) return symb;
         }
         return NULL;
     }
 
-    void CodeGen::Link::log_search_path(void) {
+    void CodeGen::MergeTemplate::log_search_path(void) {
         for (int i=0; i<link_search_list_len; i++) {
             LOG("Search %d: $4\n", i, link_search_list[i]);
         }
@@ -151,43 +151,43 @@
 
     int link_pie_count = 0;
 
-    void CodeGen::Link::guard(inter_error_message *ERR) {
+    void CodeGen::MergeTemplate::guard(inter_error_message *ERR) {
         if (ERR) { Inter::Errors::issue(ERR); internal_error("inter error"); }
     }
 
-    void CodeGen::Link::entire_splat(inter_bookmark *IBM, text_stream *origin, text_stream *content, inter_t level, inter_symbol *code_block) {
+    void CodeGen::MergeTemplate::entire_splat(inter_bookmark *IBM, text_stream *origin, text_stream *content, inter_t level, inter_symbol *code_block) {
         inter_t SID = Inter::create_text(IBM->read_into);
         text_stream *glob_storage = Inter::get_text(IBM->read_into, SID);
         Str::copy(glob_storage, content);
-        CodeGen::Link::guard(Inter::Splat::new(IBM, code_block, SID, 0, level, 0, NULL));
+        CodeGen::MergeTemplate::guard(Inter::Splat::new(IBM, code_block, SID, 0, level, 0, NULL));
     }
 

-

The function CodeGen::Link::create_pipeline_stage is used in 1/stg (§2).

+

The function CodeGen::MergeTemplate::create_pipeline_stage is used in 1/stg (§2).

-

The function CodeGen::Link::run_pipeline_stage appears nowhere else.

+

The function CodeGen::MergeTemplate::run_pipeline_stage appears nowhere else.

-

The function CodeGen::Link::ensure_search_list is used in 2/alm (§1).

+

The function CodeGen::MergeTemplate::ensure_search_list is used in 2/alm (§1).

-

The function CodeGen::Link::link appears nowhere else.

+

The function CodeGen::MergeTemplate::link appears nowhere else.

-

The function CodeGen::Link::visitor appears nowhere else.

+

The function CodeGen::MergeTemplate::visitor appears nowhere else.

-

The function CodeGen::Link::find_in_namespace appears nowhere else.

+

The function CodeGen::MergeTemplate::find_in_namespace appears nowhere else.

-

The function CodeGen::Link::build_r is used in 2/alm (§5).

+

The function CodeGen::MergeTemplate::build_r is used in 2/alm (§5).

-

The function CodeGen::Link::build_only appears nowhere else.

+

The function CodeGen::MergeTemplate::build_only appears nowhere else.

-

The function CodeGen::Link::find_name is used in 2/alm (§2.1, §5, §6).

+

The function CodeGen::MergeTemplate::find_name is used in 2/alm (§2.1, §5, §6).

-

The function CodeGen::Link::log_search_path appears nowhere else.

+

The function CodeGen::MergeTemplate::log_search_path appears nowhere else.

-

The function CodeGen::Link::guard is used in 1/ppl (§5), 2/alm (§2.1.2, §2.2.2, §3, §5, §6), 3/ip (§2), 3/tv (§1).

+

The function CodeGen::MergeTemplate::guard is used in 1/ppl (§5), 2/alm (§2.1.2, §2.2.2, §3, §5, §6), 3/ip (§2), 3/tv (§1).

-

The function CodeGen::Link::entire_splat is used in §2, 2/alm (§6).

+

The function CodeGen::MergeTemplate::entire_splat is used in §2, 2/alm (§6).

§2.

@@ -203,7 +203,7 @@
-    void CodeGen::Link::receive_raw(text_stream *S, I6T_kit *kit) {
+    void CodeGen::MergeTemplate::receive_raw(text_stream *S, I6T_kit *kit) {
         text_stream *R = Str::new();
         int mode = IGNORE_WS_FILTER_BIT;
         LOOP_THROUGH_TEXT(pos, S) {
@@ -245,22 +245,22 @@
             }
             PUT_TO(R, c);
             if ((c == ';') && (!(mode & SUBORDINATE_FILTER_BITS))) {
-                CodeGen::Link::chunked_raw(R, kit);
+                CodeGen::MergeTemplate::chunked_raw(R, kit);
                 mode = IGNORE_WS_FILTER_BIT;
             }
         }
-        CodeGen::Link::chunked_raw(R, kit);
+        CodeGen::MergeTemplate::chunked_raw(R, kit);
         Str::clear(S);
     }
 
-    void CodeGen::Link::chunked_raw(text_stream *S, I6T_kit *kit) {
+    void CodeGen::MergeTemplate::chunked_raw(text_stream *S, I6T_kit *kit) {
         if (Str::len(S) == 0) return;
         PUT_TO(S, '\n');
-        CodeGen::Link::entire_splat(kit->IBM, I"template", S, (inter_t) (Inter::Bookmarks::baseline(kit->IBM) + 1), Inter::Bookmarks::package(kit->IBM)->package_name);
+        CodeGen::MergeTemplate::entire_splat(kit->IBM, I"template", S, (inter_t) (Inter::Bookmarks::baseline(kit->IBM) + 1), Inter::Bookmarks::package(kit->IBM)->package_name);
         Str::clear(S);
     }
 
-    void CodeGen::Link::receive_command(OUTPUT_STREAM, text_stream *command, text_stream *argument, I6T_kit *kit) {
+    void CodeGen::MergeTemplate::receive_command(OUTPUT_STREAM, text_stream *command, text_stream *argument, I6T_kit *kit) {
         if ((Str::eq_wide_string(command, L"plugin")) ||
             (Str::eq_wide_string(command, L"type")) ||
             (Str::eq_wide_string(command, L"open-file")) ||
@@ -295,11 +295,11 @@
 
 

-

The function CodeGen::Link::receive_raw is used in §1.

+

The function CodeGen::MergeTemplate::receive_raw is used in §1.

-

The function CodeGen::Link::chunked_raw appears nowhere else.

+

The function CodeGen::MergeTemplate::chunked_raw appears nowhere else.

-

The function CodeGen::Link::receive_command is used in §1.

+

The function CodeGen::MergeTemplate::receive_command is used in §1.



diff --git a/docs/codegen-module/2-plm.html b/docs/codegen-module/2-plm.html index c90ea6031..9fd504d61 100644 --- a/docs/codegen-module/2-plm.html +++ b/docs/codegen-module/2-plm.html @@ -18,7 +18,7 @@
     void CodeGen::PLM::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"parse-linked-matter", CodeGen::PLM::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"parse-linked-matter", CodeGen::PLM::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::PLM::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/2-rcc.html b/docs/codegen-module/2-rcc.html
index b0ea808f9..f42ed989c 100644
--- a/docs/codegen-module/2-rcc.html
+++ b/docs/codegen-module/2-rcc.html
@@ -18,7 +18,7 @@
 
 
     void CodeGen::RCC::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"resolve-conditional-compilation", CodeGen::RCC::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"resolve-conditional-compilation", CodeGen::RCC::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::RCC::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/2-res.html b/docs/codegen-module/2-res.html
index 137c0631f..69ad4c295 100644
--- a/docs/codegen-module/2-res.html
+++ b/docs/codegen-module/2-res.html
@@ -18,7 +18,7 @@
 
 
     void CodeGen::Externals::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"resolve-external-symbols", CodeGen::Externals::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"resolve-external-symbols", CodeGen::Externals::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int resolution_failed = FALSE;
diff --git a/docs/codegen-module/2-rv.html b/docs/codegen-module/2-rv.html
index dba28238b..303887778 100644
--- a/docs/codegen-module/2-rv.html
+++ b/docs/codegen-module/2-rv.html
@@ -18,7 +18,7 @@
 
 
     void CodeGen::ReconcileVerbs::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"reconcile-verbs", CodeGen::ReconcileVerbs::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"reconcile-verbs", CodeGen::ReconcileVerbs::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::ReconcileVerbs::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/2-unq.html b/docs/codegen-module/2-unq.html
index 912a408f3..68285783b 100644
--- a/docs/codegen-module/2-unq.html
+++ b/docs/codegen-module/2-unq.html
@@ -18,7 +18,7 @@
 
 
     void CodeGen::Uniqueness::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"make-identifiers-unique", CodeGen::Uniqueness::run_pipeline_stage, NO_STAGE_ARG);
+        CodeGen::Stage::new(I"make-identifiers-unique", CodeGen::Uniqueness::run_pipeline_stage, NO_STAGE_ARG, FALSE);
     }
 
     int CodeGen::Uniqueness::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/codegen-module/3-ip.html b/docs/codegen-module/3-ip.html
index 8062bd666..6269c7592 100644
--- a/docs/codegen-module/3-ip.html
+++ b/docs/codegen-module/3-ip.html
@@ -246,10 +246,10 @@
         if (to == NULL) internal_error("no symbol");
         TEMPORARY_TEXT(prim_command);
         WRITE_TO(prim_command, "primitive %S %S", prim, category);
-        CodeGen::Link::guard(Inter::Defn::read_construct_text(prim_command, NULL, IBM));
+        CodeGen::MergeTemplate::guard(Inter::Defn::read_construct_text(prim_command, NULL, IBM));
         inter_error_message *E = NULL;
         *to = Inter::Textual::find_symbol(I, NULL, Inter::get_global_symbols(I), prim, PRIMITIVE_IST, &E);
-        CodeGen::Link::guard(E);
+        CodeGen::MergeTemplate::guard(E);
         DISCARD_TEXT(prim_command);
     }
 
diff --git a/docs/codegen-module/3-tv.html b/docs/codegen-module/3-tv.html
index 8bc622bd7..1f5b782f0 100644
--- a/docs/codegen-module/3-tv.html
+++ b/docs/codegen-module/3-tv.html
@@ -172,7 +172,7 @@
             *slot = Inter::SymbolsTables::symbol_from_name_creating(tab, S);
             if (Str::len(T) > 0) Inter::Symbols::set_translate(*slot, T);
             Inter::Symbols::annotate_i(IBM->read_into, *slot, VENEER_IANN, 1);
-            CodeGen::Link::guard(Inter::Constant::new_numerical(IBM,
+            CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM,
                 Inter::SymbolsTables::id_from_symbol(IBM->read_into, veneer_package, *slot),
                 Inter::SymbolsTables::id_from_symbol(IBM->read_into, veneer_package, unchecked_kind_symbol),
                 LITERAL_IVAL, 0,
diff --git a/docs/codegen-module/4-cg.html b/docs/codegen-module/4-cg.html
index b22b14c44..425d4d4bd 100644
--- a/docs/codegen-module/4-cg.html
+++ b/docs/codegen-module/4-cg.html
@@ -18,7 +18,7 @@
 
 
     void CodeGen::create_pipeline_stage(void) {
-        CodeGen::Stage::new(I"generate", CodeGen::run_pipeline_stage, TEXT_OUT_STAGE_ARG);
+        CodeGen::Stage::new(I"generate", CodeGen::run_pipeline_stage, TEXT_OUT_STAGE_ARG, FALSE);
     }
 
     int CodeGen::run_pipeline_stage(pipeline_step *step) {
diff --git a/docs/inter/P-pas.html b/docs/inter/P-pas.html
index e14a555fe..27f8a74bb 100644
--- a/docs/inter/P-pas.html
+++ b/docs/inter/P-pas.html
@@ -11,7 +11,7 @@
 
 

Sequences of named code-generation stages are called pipelines.

-
+

§1. Stages and descriptions. A processing stage is a step in code generation which acts on a repository of inter in memory. Some stages change, add to or edit down that code, while @@ -54,11 +54,7 @@ each line, and the comma is not needed:

-

§2. A pipeline can work on up to 10 different repositories, called 0 to 9, -which are initially empty (but see below). -

- -

A pipeline description can make use of "variables". These hold only text, +

§2. A pipeline description can make use of "variables". These hold only text, and generally represent filenames. Variable names begin with a star *. The pipeline cannot create variables: instead, the user of the pipeline has to make them before use. For example, @@ -79,7 +75,7 @@ the given pipeline. Inside the pipeline, a line such as:

-        generate: inform6 -> *X
+        generate inform6 -> *X
 

would then be read as: @@ -89,7 +85,7 @@ the given pipeline. Inside the pipeline, a line such as:

-        generate: inform6 -> ex/why
+        generate inform6 -> ex/why
 

After variable substitution like this, filenames inside the pipeline @@ -114,7 +110,7 @@ For example,

-        generate: inventory -> *log
+        generate inventory -> *log
 

Template filenames are a little different: those are searched for inside @@ -137,9 +133,9 @@ effect is that any useful pipeline for Inform will begin and end thus:

-        read: 0 <- *in
+        read <- *in
         ...
-        generate: inform6 -> *out
+        generate inform6 -> *out
 

In addition, the "domain" is set to the directory containing the *out @@ -211,7 +207,53 @@ project's Materials folder. But there are also two other ways.

-

§4. Reading and generating. The read stage reads Inter from a file into a repository in memory. +

§4. Stage descriptions. There are three sorts of stage description: those involving material coming +in, denoted by a left arrow, those involving some external file being written +out, denoted by a right arrow, and those which just process what we have. +These take the following forms: +

+ +

+ + +
+        STAGENAME [LOCATION] <- SOURCE
+        STAGENAME [LOCATION] FORMAT -> DESTINATION
+        STAGENAME [LOCATION]
+
+ +

In each case the LOCATION is optional. For example: +

+ +

+ + +
+        read 2 <- *in
+        generate binary -> *out
+        eliminate-redundant-labels /main/template
+
+ +

In the first line the location is 2. Pipeline descriptios allow us to manage +up to 10 different repositories, and these are called 0 to 9. These are +all initially empty. Any stage which doesn't specify a repository is considered +to apply to 0; plenty of pipelines never mention the digits 0 to 9 at +all because they do everything inside 0. +

+ +

In the second line, there's no location given, so the location is presumed +to be 0. +

+ +

The third line demonstrates that a location can be more specific than just +a repository: it can be a specific package in a repository. Here, it's +/main/template in repository 0, but we could also write 7:/main/template +to mean /main/template in 7, for example. Not all stages allow the +location to be narrowed down to a single package (which by definition +includes all its subpackages): see below. +

+ +

§5. Reading and generating. The read stage reads Inter from a file into a repository in memory. (Its previous contents, if any, are discarded.) This then becomes the repository to which subsequent stages apply. The format is:

@@ -223,8 +265,12 @@ repository to which subsequent stages apply. The format is: read REPOSITORY <- FILE
-

where REPOSITORY is 0 to 9. Conventionally, we use 0 most of the time. -The FILE can contain either binary or textual Inter, and this is +

where REPOSITORY is 0 to 9, and is 0 if not supplied. Note that +this fills an entire repository: it's not meaningful to specify a +named package as the location. +

+ +

The FILE can contain either binary or textual Inter, and this is automatically detected.

@@ -232,13 +278,14 @@ automatically detected.
-        generate: FORMAT -> FILE
+        generate FORMAT -> FILE
 
-

writes the contents of the current repository out into the given FILE. -There are several possible formats: binary and text mean a binary or -textual Inter file, inventory means a textual summary of the contents, -and inform6 means an Inform 6 program. +

writes the repository out into the given FILE. There are several possible +formats: binary and text mean a binary or textual Inter file, inventory +means a textual summary of the contents, and inform6 means an Inform 6 +program. At present, only inventory can be generated on specific +packages in a repository.

The generate stage leaves the repository unchanged, so it's possible @@ -246,7 +293,7 @@ to generate multiple representations of the same repository into different files.

-

§5. The code-generation stages. The following are all experimental, and have probably not yet reached their +

§6. The code-generation stages. The following are all experimental, and have probably not yet reached their final form or names.

@@ -260,13 +307,13 @@ therefore, are converted out of Inform 6 and then back into it again. This sounds inefficient but is surprisingly fast, and enables many optimisations.)

-

§6. link:T reads in the I6T template file T, converts it to inter in a very -basic way (creating many splats), and merges it with the repository. Splats -are the unhappiest of inter statements, simply including verbatim snippets -of Inform 6 code. +

§7. merge-template <- T reads in the I6T template file T, converts it to +inter in a very basic way (creating many splats), and merges it with the +repository. Splats are the unhappiest of inter statements, simply including +verbatim snippets of Inform 6 code.

-

§7. parse-linked-matter examines the splats produced by linking and annotates +

§8. parse-linked-matter examines the splats produced by merging and annotates them by what they seem to want to do. For example,

@@ -289,7 +336,7 @@ them by what they seem to want to do. For example,

-

§8. resolve-conditional-compilation looks for splats arising from Inform 6 +

§9. resolve-conditional-compilation looks for splats arising from Inform 6 conditional compilation directives such as #ifdef, #ifndef, #endif; it then detects whether the relevant symbols are defined, or looks at their values, and deletes sections of code not to be compiled. At the end of this @@ -322,7 +369,7 @@ For example:

-

§9. assimilate aims to convert all remaining splats in the repository into +

§10. assimilate aims to convert all remaining splats in the repository into higher-level inter statements. For example,

@@ -349,7 +396,7 @@ higher-level inter statements. For example, and the linking process is complete.

-

§10. make-identifiers-unique looks for symbols marked with the MAKE_NAME_UNIQUE +

§11. make-identifiers-unique looks for symbols marked with the MAKE_NAME_UNIQUE flag (represented in textual form by an asterisk after its name), This flag means that Inform wants the symbol name to be globally unique in the repository. For example, if Inform generates the symbol name fruit*, it's really telling @@ -371,7 +418,7 @@ same name in any I6 program, for example.

At the end of this stage, no symbol still has the MAKE_NAME_UNIQUE flag.

-

§11. reconcile-verbs is a short stage looking for clashes between any verbs (in +

§12. reconcile-verbs is a short stage looking for clashes between any verbs (in the parser interactive fiction sense) which have been assimilated from the template, and verbs which have been defined in the main source text. For example, suppose the source creates the command verb "abstract": this would @@ -385,12 +432,12 @@ up with two command verbs: abstract<

At the end of this stage, all parser verbs have distinct textual forms.

-

§12. eliminate-redundant-code deletes all packages which Inter can prove +

§13. eliminate-redundant-code deletes all packages which Inter can prove will not be used in the final code generated from the repository. For example, functions never called, or arrays never referred to, are deleted.

-

§13. eliminate-redundant-labels performs peephole optimisation on all of +

§14. eliminate-redundant-labels performs peephole optimisation on all of the functions in the repository to remove all labels which are declared but can never be jumped to.

@@ -399,7 +446,7 @@ but can never be jumped to. branch, either by inv !jump or in assembly language.

-

§14. The special stage stop halts processing of the pipeline midway. At present +

§15. The special stage stop halts processing of the pipeline midway. At present this is only useful for making experimental edits to pipeline descriptions to see what just the first half does, without deleting the second half of the description. diff --git a/docs/inter/P-ui.html b/docs/inter/P-ui.html index da7e506e3..ef646425e 100644 --- a/docs/inter/P-ui.html +++ b/docs/inter/P-ui.html @@ -88,7 +88,7 @@ one stage, can be quite elaborate (see later), but for example:

-        read: 0 <- myfile.inter, resolve-conditional-compilation, generate: inform6 -> myfile.i6
+        read <- myfile.inter, resolve-conditional-compilation, generate inform6 -> myfile.i6
 

is a valid three-stage pipeline. The command to do this is then: diff --git a/inform7/Internal/Inter/default.interpipeline b/inform7/Internal/Inter/default.interpipeline index 01a826e4e..abff59a1a 100644 --- a/inform7/Internal/Inter/default.interpipeline +++ b/inform7/Internal/Inter/default.interpipeline @@ -1,9 +1,9 @@ -read: 0 <- *in -link: Output.i6t +read <- *in +merge-template <- Output.i6t parse-linked-matter resolve-conditional-compilation assimilate make-identifiers-unique resolve-external-symbols reconcile-verbs -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inform7/Tests/test-pl.interpipeline b/inform7/Tests/test-pl.interpipeline index 01a826e4e..abff59a1a 100644 --- a/inform7/Tests/test-pl.interpipeline +++ b/inform7/Tests/test-pl.interpipeline @@ -1,9 +1,9 @@ -read: 0 <- *in -link: Output.i6t +read <- *in +merge-template <- Output.i6t parse-linked-matter resolve-conditional-compilation assimilate make-identifiers-unique resolve-external-symbols reconcile-verbs -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Preliminaries/Pipelines and Stages.w b/inter/Preliminaries/Pipelines and Stages.w index ab8a6aae1..bf6f53f41 100644 --- a/inter/Preliminaries/Pipelines and Stages.w +++ b/inter/Preliminaries/Pipelines and Stages.w @@ -27,10 +27,7 @@ each line, and the comma is not needed: |xyzzy| |plover| -@ A pipeline can work on up to 10 different repositories, called |0| to |9|, -which are initially empty (but see below). - -A pipeline description can make use of "variables". These hold only text, +@ A pipeline description can make use of "variables". These hold only text, and generally represent filenames. Variable names begin with a star |*|. The pipeline cannot create variables: instead, the user of the pipeline has to make them before use. For example, @@ -40,11 +37,11 @@ to make them before use. For example, creates the variable |*X| with the textual contents |ex/why| before running the given pipeline. Inside the pipeline, a line such as: - |generate: inform6 -> *X| + |generate inform6 -> *X| would then be read as: - |generate: inform6 -> ex/why| + |generate inform6 -> ex/why| After variable substitution like this, filenames inside the pipeline description are interpreted as follows: @@ -60,7 +57,7 @@ A command to write a text file to |*log| is interpreted instead to mean "spool the output you would otherwise write to the debugging log instead". For example, - |generate: inventory -> *log| + |generate inventory -> *log| Template filenames are a little different: those are searched for inside a path of possible directories. By default there's no such path, but using @@ -76,9 +73,9 @@ which Inform has generated on the current run, and |*out| is set to the filename to which final I6 code needs to be written. The practical effect is that any useful pipeline for Inform will begin and end thus: - |read: 0 <- *in| + |read <- *in| |...| - |generate: inform6 -> *out| + |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, @@ -116,6 +113,38 @@ Exactly as with Inter, Inform 7 also responds to |-pipeline-file|: |$ inform7/Tangled/inform7 ... -pipeline-file FILE| +@h Stage descriptions. +There are three sorts of stage description: those involving material coming +in, denoted by a left arrow, those involving some external file being written +out, denoted by a right arrow, and those which just process what we have. +These take the following forms: + + |STAGENAME [LOCATION] <- SOURCE| + |STAGENAME [LOCATION] FORMAT -> DESTINATION| + |STAGENAME [LOCATION]| + +In each case the |LOCATION| is optional. For example: + + |read 2 <- *in| + |generate binary -> *out| + |eliminate-redundant-labels /main/template| + +In the first line the location is |2|. Pipeline descriptios allow us to manage +up to 10 different repositories, and these are called |0| to |9|. These are +all initially empty. Any stage which doesn't specify a repository is considered +to apply to |0|; plenty of pipelines never mention the digits |0| to |9| at +all because they do everything inside |0|. + +In the second line, there's no location given, so the location is presumed +to be |0|. + +The third line demonstrates that a location can be more specific than just +a repository: it can be a specific package in a repository. Here, it's +|/main/template| in repository |0|, but we could also write |7:/main/template| +to mean |/main/template| in |7|, for example. Not all stages allow the +location to be narrowed down to a single package (which by definition +includes all its subpackages): see below. + @h Reading and generating. The |read| stage reads Inter from a file into a repository in memory. (Its previous contents, if any, are discarded.) This then becomes the @@ -123,16 +152,20 @@ repository to which subsequent stages apply. The format is: |read REPOSITORY <- FILE| -where |REPOSITORY| is |0| to |9|. Conventionally, we use |0| most of the time. +where |REPOSITORY| is |0| to |9|, and is |0| if not supplied. Note that +this fills an entire repository: it's not meaningful to specify a +named package as the location. + The |FILE| can contain either binary or textual Inter, and this is automatically detected. - |generate: FORMAT -> FILE| + |generate FORMAT -> FILE| -writes the contents of the current repository out into the given |FILE|. -There are several possible formats: |binary| and |text| mean a binary or -textual Inter file, |inventory| means a textual summary of the contents, -and |inform6| means an Inform 6 program. +writes the repository out into the given |FILE|. There are several possible +formats: |binary| and |text| mean a binary or textual Inter file, |inventory| +means a textual summary of the contents, and |inform6| means an Inform 6 +program. At present, only |inventory| can be generated on specific +packages in a repository. The |generate| stage leaves the repository unchanged, so it's possible to generate multiple representations of the same repository into different @@ -151,12 +184,12 @@ turn this merged repository into Inform 6 code. (Routines in the template, therefore, are converted out of Inform 6 and then back into it again. This sounds inefficient but is surprisingly fast, and enables many optimisations.) -@ |link:T| reads in the I6T template file T, converts it to inter in a very -basic way (creating many splats), and merges it with the repository. Splats -are the unhappiest of inter statements, simply including verbatim snippets -of Inform 6 code. +@ |merge-template <- T| reads in the I6T template file |T|, converts it to +inter in a very basic way (creating many splats), and merges it with the +repository. Splats are the unhappiest of inter statements, simply including +verbatim snippets of Inform 6 code. -@ |parse-linked-matter| examines the splats produced by linking and annotates +@ |parse-linked-matter| examines the splats produced by merging and annotates them by what they seem to want to do. For example, |splat &"Global nitwit = 2;\n"| diff --git a/inter/Preliminaries/Using Inter.w b/inter/Preliminaries/Using Inter.w index 79550bf97..8139d0a3a 100644 --- a/inter/Preliminaries/Using Inter.w +++ b/inter/Preliminaries/Using Inter.w @@ -49,7 +49,7 @@ converts |my.intert| (a textual inter file) to its binary equivalent a pipeline of processing stages. The pipeline, which must contain at least one stage, can be quite elaborate (see later), but for example: - |read: 0 <- myfile.inter, resolve-conditional-compilation, generate: inform6 -> myfile.i6| + |read <- myfile.inter, resolve-conditional-compilation, generate inform6 -> myfile.i6| is a valid three-stage pipeline. The command to do this is then: diff --git a/inter/Tests/General/_Pipelines/Assim.interpipeline b/inter/Tests/General/_Pipelines/Assim.interpipeline index 93be701ea..73629d677 100644 --- a/inter/Tests/General/_Pipelines/Assim.interpipeline +++ b/inter/Tests/General/_Pipelines/Assim.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter assimilate resolve-external-symbols -generate: text -> *out +generate text -> *out diff --git a/inter/Tests/General/_Pipelines/Cons.interpipeline b/inter/Tests/General/_Pipelines/Cons.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/Cons.interpipeline +++ b/inter/Tests/General/_Pipelines/Cons.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Tests/General/_Pipelines/EasyRCC.interpipeline b/inter/Tests/General/_Pipelines/EasyRCC.interpipeline index bb7bf9b2e..7e80215d3 100644 --- a/inter/Tests/General/_Pipelines/EasyRCC.interpipeline +++ b/inter/Tests/General/_Pipelines/EasyRCC.interpipeline @@ -1,4 +1,4 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation -generate: text -> *out +generate text -> *out diff --git a/inter/Tests/General/_Pipelines/IftrueRCC.interpipeline b/inter/Tests/General/_Pipelines/IftrueRCC.interpipeline index bb7bf9b2e..7e80215d3 100644 --- a/inter/Tests/General/_Pipelines/IftrueRCC.interpipeline +++ b/inter/Tests/General/_Pipelines/IftrueRCC.interpipeline @@ -1,4 +1,4 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation -generate: text -> *out +generate text -> *out diff --git a/inter/Tests/General/_Pipelines/ObjKind.interpipeline b/inter/Tests/General/_Pipelines/ObjKind.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/ObjKind.interpipeline +++ b/inter/Tests/General/_Pipelines/ObjKind.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Tests/General/_Pipelines/PLM.interpipeline b/inter/Tests/General/_Pipelines/PLM.interpipeline index a3f007dd9..3d3dbffa2 100644 --- a/inter/Tests/General/_Pipelines/PLM.interpipeline +++ b/inter/Tests/General/_Pipelines/PLM.interpipeline @@ -1,3 +1,3 @@ -read: 0 <- *in +read <- *in parse-linked-matter -generate: text -> *out +generate text -> *out diff --git a/inter/Tests/General/_Pipelines/Predeclared.interpipeline b/inter/Tests/General/_Pipelines/Predeclared.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/Predeclared.interpipeline +++ b/inter/Tests/General/_Pipelines/Predeclared.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Tests/General/_Pipelines/Primitives.interpipeline b/inter/Tests/General/_Pipelines/Primitives.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/Primitives.interpipeline +++ b/inter/Tests/General/_Pipelines/Primitives.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Tests/General/_Pipelines/Redundancies.interpipeline b/inter/Tests/General/_Pipelines/Redundancies.interpipeline index 04d724ce0..61d95b39f 100644 --- a/inter/Tests/General/_Pipelines/Redundancies.interpipeline +++ b/inter/Tests/General/_Pipelines/Redundancies.interpipeline @@ -1,3 +1,3 @@ -read: 0 <- *in +read <- *in eliminate-redundant-labels -generate: text -> *out +generate text -> *out diff --git a/inter/Tests/General/_Pipelines/SimpleKind.interpipeline b/inter/Tests/General/_Pipelines/SimpleKind.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/SimpleKind.interpipeline +++ b/inter/Tests/General/_Pipelines/SimpleKind.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/Tests/General/_Pipelines/SimpleRoutines.interpipeline b/inter/Tests/General/_Pipelines/SimpleRoutines.interpipeline index 34bc26d17..a7d7e158d 100644 --- a/inter/Tests/General/_Pipelines/SimpleRoutines.interpipeline +++ b/inter/Tests/General/_Pipelines/SimpleRoutines.interpipeline @@ -1,5 +1,5 @@ -read: 0 <- *in +read <- *in parse-linked-matter resolve-conditional-compilation assimilate -generate: inform6 -> *out +generate inform6 -> *out diff --git a/inter/codegen-module/Chapter 1/Pipelines.w b/inter/codegen-module/Chapter 1/Pipelines.w index 970699d55..c2beb6dbe 100644 --- a/inter/codegen-module/Chapter 1/Pipelines.w +++ b/inter/codegen-module/Chapter 1/Pipelines.w @@ -30,7 +30,7 @@ pipeline_step *CodeGen::Pipeline::new_step(void) { step->step_stage = NULL; step->step_argument = NULL; step->package_argument = NULL; - step->repository_argument = -1; + step->repository_argument = 0; CodeGen::Pipeline::clean_step(step); return step; } @@ -55,11 +55,10 @@ logging: void CodeGen::Pipeline::write_step(OUTPUT_STREAM, pipeline_step *step) { WRITE("%S", step->step_stage->stage_name); if (step->step_stage->stage_arg != NO_STAGE_ARG) { - if (step->package_argument) WRITE(" %S", step->package_argument); - WRITE(":"); - if (step->repository_argument >= 0) WRITE(" %d <-", step->repository_argument); - if (step->target_argument) WRITE(" %S ->", step->target_argument->target_name); - WRITE(" %S", step->step_argument); + WRITE(" %d", step->repository_argument); + if (Str::len(step->package_argument) > 0) WRITE(":%S", step->package_argument); + if (step->step_stage->takes_repository >= 0) WRITE(" <- %S", step->step_argument); + if (step->target_argument) WRITE(" %S -> %S", step->target_argument->target_name, step->step_argument); } } @@ -68,11 +67,12 @@ pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, dictionary *D) { CodeGen::Targets::make_targets(); pipeline_step *ST = CodeGen::Pipeline::new_step(); match_results mr = Regexp::create_mr(); - if (Regexp::match(&mr, step, L"(%c+?) *: *(%d) *<- *(%c*)")) { - ST->repository_argument = Str::atoi(mr.exp[1], 0); - ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); + int left_arrow_used = FALSE; + if (Regexp::match(&mr, step, L"(%c+?) *<- *(%c*)")) { + ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); Str::copy(step, mr.exp[0]); - } else if (Regexp::match(&mr, step, L"(%c+?) *: *(%C*) *-> *(%c*)")) { + left_arrow_used = TRUE; + } else if (Regexp::match(&mr, step, L"(%c+?) *(%C*) *-> *(%c*)")) { code_generation_target *cgt; LOOP_OVER(cgt, code_generation_target) if (Str::eq(mr.exp[1], cgt->target_name)) @@ -83,11 +83,15 @@ pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, dictionary *D) { } ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); Str::copy(step, mr.exp[0]); - } else if (Regexp::match(&mr, step, L"(%c+?) *: *(%c*)")) { - ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); - Str::copy(step, mr.exp[0]); } - if (Regexp::match(&mr, step, L"(%C+?) (%c+)")) { + if (Regexp::match(&mr, step, L"(%C+?) (%d)")) { + ST->repository_argument = Str::atoi(mr.exp[1], 0); + Str::copy(step, mr.exp[0]); + } else if (Regexp::match(&mr, step, L"(%C+?) (%d):(%c*)")) { + ST->repository_argument = Str::atoi(mr.exp[1], 0); + ST->package_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D); + Str::copy(step, mr.exp[0]); + } else if (Regexp::match(&mr, step, L"(%C+?) (%c+)")) { ST->package_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D); Str::copy(step, mr.exp[0]); } @@ -100,6 +104,14 @@ pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, dictionary *D) { WRITE_TO(STDERR, "No such step as '%S'\n", step); internal_error("no such step code"); } + if (ST->step_stage->takes_repository) { + if (left_arrow_used == FALSE) + internal_error("should use a left arrow"); + } else { + if (left_arrow_used) + internal_error("should not use a left arrow"); + } + Regexp::dispose_of(&mr); return ST; } @@ -189,20 +201,22 @@ void CodeGen::Pipeline::set_repository(codegen_pipeline *S, inter_repository *I) void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **PP) { if (S == NULL) return; - if (S->repositories[0] == NULL) S->repositories[0] = Inter::create(1, 32); clock_t start = clock(); int step_count = 0, step_total = 0; pipeline_step *step; LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps) step_total++; - int active = TRUE, current_repo = 0; - CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]); + int active = TRUE; LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps) if (active) { - inter_repository *I = S->repositories[current_repo]; + if (S->repositories[step->repository_argument] == NULL) + S->repositories[step->repository_argument] = Inter::create(1, 32); + inter_repository *I = S->repositories[step->repository_argument]; + if (I == NULL) internal_error("no repository"); CodeGen::Pipeline::lint(I); - + CodeGen::Pipeline::prepare_to_run(I); + CodeGen::Pipeline::clean_step(step); step->the_N = N; step->the_PP = PP; @@ -215,6 +229,8 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname ** Log::new_stage(STAGE_NAME); DISCARD_TEXT(STAGE_NAME); + int skip_step = FALSE; + if ((step->step_stage->stage_arg == FILE_STAGE_ARG) || (step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) || (step->step_stage->stage_arg == EXT_FILE_STAGE_ARG) || @@ -222,9 +238,9 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname ** if (Str::eq(step->step_argument, I"*log")) { step->to_debugging_log = TRUE; } else if (Str::eq(step->step_argument, I"*memory")) { - step->from_memory = TRUE; + S->repositories[step->repository_argument] = S->memory_repository; + skip_step = TRUE; } else { - step->parsed_filename = Filenames::from_text(step->step_argument); int slashes = FALSE; LOOP_THROUGH_TEXT(pos, step->step_argument) if (Str::get(pos) == '/') @@ -253,9 +269,7 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname ** step->text_out_file = T; } - if ((step->from_memory) && (step->repository_argument >= 0)) - S->repositories[step->repository_argument] = S->memory_repository; - else + if (skip_step == FALSE) active = (*(step->step_stage->execute))(step); if (((step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) || @@ -263,11 +277,6 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname ** (step->to_debugging_log == FALSE)) { STREAM_CLOSE(T); } - - if (step->repository_argument >= 0) { - current_repo = step->repository_argument; - CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]); - } } } @@ -359,5 +368,5 @@ void CodeGen::Pipeline::visitor(inter_repository *I, inter_frame P, void *state) internal_error("zap"); } - CodeGen::Link::guard(Inter::Defn::verify_children_inner(P)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_children_inner(P)); } diff --git a/inter/codegen-module/Chapter 1/Stages.w b/inter/codegen-module/Chapter 1/Stages.w index 092f759c0..bd461b3c4 100644 --- a/inter/codegen-module/Chapter 1/Stages.w +++ b/inter/codegen-module/Chapter 1/Stages.w @@ -8,6 +8,7 @@ following. Some stages are invoked with an argument, often the filename to write output to; others are not. @e NO_STAGE_ARG from 1 +@e GENERAL_STAGE_ARG @e FILE_STAGE_ARG @e TEXT_OUT_STAGE_ARG @e EXT_FILE_STAGE_ARG @@ -19,14 +20,16 @@ typedef struct pipeline_stage { struct text_stream *stage_name; int (*execute)(void *); int stage_arg; /* one of the |*_ARG| values above */ + int takes_repository; MEMORY_MANAGEMENT } pipeline_stage; -pipeline_stage *CodeGen::Stage::new(text_stream *name, int (*X)(struct pipeline_step *), int arg) { +pipeline_stage *CodeGen::Stage::new(text_stream *name, int (*X)(struct pipeline_step *), int arg, int tr) { pipeline_stage *stage = CREATE(pipeline_stage); stage->stage_name = Str::duplicate(name); stage->execute = (int (*)(void *)) X; stage->stage_arg = arg; + stage->takes_repository = tr; return stage; } @@ -40,15 +43,17 @@ int stages_made = FALSE; void CodeGen::Stage::make_stages(void) { if (stages_made == FALSE) { stages_made = TRUE; - CodeGen::Stage::new(I"stop", CodeGen::Stage::run_stop_stage, NO_STAGE_ARG); - CodeGen::Stage::new(I"read", CodeGen::Stage::run_read_stage, FILE_STAGE_ARG); + CodeGen::Stage::new(I"stop", CodeGen::Stage::run_stop_stage, NO_STAGE_ARG, FALSE); + + CodeGen::Stage::new(I"read", CodeGen::Stage::run_read_stage, FILE_STAGE_ARG, TRUE); + CodeGen::Stage::new(I"extract", CodeGen::Stage::run_extract_stage, GENERAL_STAGE_ARG, TRUE); CodeGen::create_pipeline_stage(); CodeGen::Assimilate::create_pipeline_stage(); CodeGen::Eliminate::create_pipeline_stage(); CodeGen::Externals::create_pipeline_stage(); CodeGen::Labels::create_pipeline_stage(); - CodeGen::Link::create_pipeline_stage(); + CodeGen::MergeTemplate::create_pipeline_stage(); CodeGen::PLM::create_pipeline_stage(); CodeGen::RCC::create_pipeline_stage(); CodeGen::ReconcileVerbs::create_pipeline_stage(); @@ -65,10 +70,13 @@ int CodeGen::Stage::run_stop_stage(pipeline_step *step) { } int CodeGen::Stage::run_read_stage(pipeline_step *step) { - filename *F = Filenames::from_text(step->step_argument); - if (Inter::Binary::test_file(F)) - Inter::Binary::read(step->repository, F); - else - Inter::Textual::read(step->repository, F); + filename *F = step->parsed_filename; + if (Inter::Binary::test_file(F)) Inter::Binary::read(step->repository, F); + else Inter::Textual::read(step->repository, F); + return TRUE; +} + +int CodeGen::Stage::run_extract_stage(pipeline_step *step) { + LOG("Arg is %S.\n", step->step_argument); return TRUE; } diff --git a/inter/codegen-module/Chapter 2/Assimilate.w b/inter/codegen-module/Chapter 2/Assimilate.w index bd0201b34..e66db6b39 100644 --- a/inter/codegen-module/Chapter 2/Assimilate.w +++ b/inter/codegen-module/Chapter 2/Assimilate.w @@ -6,7 +6,7 @@ To assimilate the material in parsed non-code splats. = void CodeGen::Assimilate::create_pipeline_stage(void) { - CodeGen::Stage::new(I"assimilate", CodeGen::Assimilate::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"assimilate", CodeGen::Assimilate::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int no_assimilated_actions = 0; @@ -20,7 +20,7 @@ int CodeGen::Assimilate::run_pipeline_stage(pipeline_step *step) { no_assimilated_actions = 0; no_assimilated_commands = 0; no_assimilated_arrays = 0; - CodeGen::Link::ensure_search_list(I); + CodeGen::MergeTemplate::ensure_search_list(I); Inter::traverse_tree(I, CodeGen::Assimilate::visitor1, NULL, NULL, SPLAT_IST); Inter::traverse_tree(I, CodeGen::Assimilate::visitor2, NULL, NULL, SPLAT_IST); CodeGen::Assimilate::function_bodies(); @@ -100,7 +100,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta @; if ((proceed) && (unchecked_kind_symbol)) { if (plm == DEFAULT_PLM) { - inter_symbol *symbol = CodeGen::Link::find_name(I, identifier, TRUE); + inter_symbol *symbol = CodeGen::MergeTemplate::find_name(I, identifier, TRUE); if (symbol == NULL) plm = CONSTANT_PLM; } if (plm != DEFAULT_PLM) @; @@ -197,7 +197,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta case FAKEACTION_PLM: case OBJECT_PLM: { @; - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name), Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol), v1, v2, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -206,7 +206,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta } case GLOBAL_PLM: @; - CodeGen::Link::guard(Inter::Variable::new(IBM, + CodeGen::MergeTemplate::guard(Inter::Variable::new(IBM, Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name), Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol), v1, v2, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -219,7 +219,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta if ((attr_symbol == NULL) || (!Inter::Symbols::is_defined(attr_symbol))) { if (attr_symbol == NULL) attr_symbol = con_name; - CodeGen::Link::guard(Inter::Property::new(IBM, + CodeGen::MergeTemplate::guard(Inter::Property::new(IBM, Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), attr_symbol), Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), truth_state_kind_symbol), (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -245,7 +245,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta break; } case PROPERTY_PLM: { - CodeGen::Link::guard(Inter::Property::new(IBM, + CodeGen::MergeTemplate::guard(Inter::Property::new(IBM, Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), con_name), Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), unchecked_kind_symbol), (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -324,7 +324,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta array_in_progress.data[pos++] = v1_pile[i]; array_in_progress.data[pos++] = v2_pile[i]; } - CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); Inter::Frame::insert(array_in_progress, IBM); if (plm == ARRAY_PLM) { @@ -421,12 +421,12 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta if (Str::len(value) == 0) break; inter_symbol *loc_name = Inter::SymbolsTables::create_with_unique_name(Inter::Package::local_symbols(block_name), value); Inter::Symbols::local(loc_name); - CodeGen::Link::guard(Inter::Local::new(IBM, block_name, loc_name, unchecked_kind_symbol, 0, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); + CodeGen::MergeTemplate::guard(Inter::Local::new(IBM, block_name, loc_name, unchecked_kind_symbol, 0, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); DISCARD_TEXT(value); } } - CodeGen::Link::guard(Inter::Code::new(IBM, (int) (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); + CodeGen::MergeTemplate::guard(Inter::Code::new(IBM, (int) (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); if (Str::len(body) > 0) { int L = Str::len(body) - 1; while ((L>0) && (Str::get_at(body, L) != ']')) L--; @@ -439,7 +439,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta inter_symbol *rsymb = CodeGen::Assimilate::maybe_extern(I, identifier, Inter::Bookmarks::scope(IBM)); Inter::Symbols::annotate_i(I, rsymb, ASSIMILATED_IANN, 1); - CodeGen::Link::guard(Inter::Constant::new_function(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_function(IBM, Inter::SymbolsTables::id_from_symbol(I, FP, rsymb), Inter::SymbolsTables::id_from_symbol(I, FP, unchecked_function_symbol), Inter::SymbolsTables::id_from_symbol(I, FP, block_name), @@ -457,7 +457,7 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta @ = inter_package *CodeGen::Assimilate::new_package(inter_bookmark *IBM, inter_symbol *pname, inter_symbol *ptype) { inter_package *P = NULL; - CodeGen::Link::guard(Inter::Package::new_package(IBM, pname, + CodeGen::MergeTemplate::guard(Inter::Package::new_package(IBM, pname, ptype, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL, &P)); return P; } @@ -516,7 +516,7 @@ inter_symbol *CodeGen::Assimilate::maybe_extern(inter_repository *I, text_stream @ = void CodeGen::Assimilate::ensure_action(inter_repository *I, inter_frame P, text_stream *value) { - if (CodeGen::Link::find_name(I, value, TRUE) == NULL) { + if (CodeGen::MergeTemplate::find_name(I, value, TRUE) == NULL) { inter_bookmark IBM_d = CodeGen::Assimilate::template_submodule(I, I"actions", P); inter_bookmark *IBM = &IBM_d; TEMPORARY_TEXT(an); @@ -531,16 +531,16 @@ void CodeGen::Assimilate::ensure_action(inter_repository *I, inter_frame P, text WRITE_TO(unsharped, "%SSub", value); Str::delete_first_character(unsharped); Str::delete_first_character(unsharped); - inter_symbol *txsymb = CodeGen::Link::find_name(I, unsharped, TRUE); + inter_symbol *txsymb = CodeGen::MergeTemplate::find_name(I, unsharped, TRUE); inter_symbol *xsymb = Inter::SymbolsTables::create_with_unique_name(Inter::Bookmarks::scope(IBM), unsharped); if (txsymb) Inter::SymbolsTables::equate(xsymb, txsymb); DISCARD_TEXT(unsharped); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), asymb), Inter::SymbolsTables::id_from_symbol(I, Inter::Bookmarks::package(IBM), action_kind_symbol), LITERAL_IVAL, 10000, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); Inter::Symbols::annotate_i(I, asymb, ACTION_IANN, 1); - CodeGen::Link::build_r(Inter::Bookmarks::package(IBM)); + CodeGen::MergeTemplate::build_r(Inter::Bookmarks::package(IBM)); } } @@ -636,7 +636,7 @@ void CodeGen::Assimilate::value(inter_repository *I, inter_package *pack, inter_ } match_results mr = Regexp::create_mr(); if (Regexp::match(&mr, S, L"scope=(%i+)")) { - inter_symbol *symb = CodeGen::Link::find_name(I, mr.exp[0], TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, mr.exp[0], TRUE); while ((symb) && (symb->equated_to)) symb = symb->equated_to; if (symb) { if (Inter::Symbols::read_annotation(symb, SCOPE_FILTER_IANN) != 1) @@ -645,7 +645,7 @@ void CodeGen::Assimilate::value(inter_repository *I, inter_package *pack, inter_ } } if (Regexp::match(&mr, S, L"noun=(%i+)")) { - inter_symbol *symb = CodeGen::Link::find_name(I, mr.exp[0], TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, mr.exp[0], TRUE); while ((symb) && (symb->equated_to)) symb = symb->equated_to; if (symb) { if (Inter::Symbols::read_annotation(symb, NOUN_FILTER_IANN) != 1) @@ -655,7 +655,7 @@ void CodeGen::Assimilate::value(inter_repository *I, inter_package *pack, inter_ } } - inter_symbol *symb = CodeGen::Link::find_name(I, S, TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, S, TRUE); if (symb) { Inter::Symbols::to_data(I, pack, symb, val1, val2); return; } @@ -680,7 +680,7 @@ inter_symbol *CodeGen::Assimilate::compute_constant(inter_repository *I, inter_p Str::copy(glob_storage, sch->converted_from); inter_symbol *mcc_name = CodeGen::Assimilate::computed_constant_symbol(pack); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, pack, mcc_name), Inter::SymbolsTables::id_from_symbol(I, pack, unchecked_kind_symbol), GLOB_IVAL, ID, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -723,7 +723,7 @@ inter_symbol *CodeGen::Assimilate::compute_constant_eval(inter_repository *I, in inter_t v1 = UNDEF_IVAL, v2 = 0; switch (t->ist_type) { case IDENTIFIER_ISTT: { - inter_symbol *symb = CodeGen::Link::find_name(I, t->material, TRUE); + inter_symbol *symb = CodeGen::MergeTemplate::find_name(I, t->material, TRUE); if (symb) return symb; LOG("Failed to identify %S\n", t->material); break; @@ -738,7 +738,7 @@ inter_symbol *CodeGen::Assimilate::compute_constant_eval(inter_repository *I, in } if (v1 == UNDEF_IVAL) return NULL; inter_symbol *mcc_name = CodeGen::Assimilate::computed_constant_symbol(pack); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(I, pack, mcc_name), Inter::SymbolsTables::id_from_symbol(I, pack, unchecked_kind_symbol), v1, v2, (inter_t) Inter::Bookmarks::baseline(IBM) + 1, NULL)); @@ -756,7 +756,7 @@ inter_symbol *CodeGen::Assimilate::compute_constant_unary_operation(inter_reposi internal_error("can't extend frame"); array_in_progress.data[pos] = LITERAL_IVAL; array_in_progress.data[pos+1] = 0; Inter::Symbols::to_data(I, pack, i1, &(array_in_progress.data[pos+2]), &(array_in_progress.data[pos+3])); - CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); Inter::Frame::insert(array_in_progress, IBM); return mcc_name; } @@ -770,7 +770,7 @@ inter_symbol *CodeGen::Assimilate::compute_constant_binary_operation(inter_t op, internal_error("can't extend frame"); Inter::Symbols::to_data(I, pack, i1, &(array_in_progress.data[pos]), &(array_in_progress.data[pos+1])); Inter::Symbols::to_data(I, pack, i2, &(array_in_progress.data[pos+2]), &(array_in_progress.data[pos+3])); - CodeGen::Link::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); + CodeGen::MergeTemplate::guard(Inter::Defn::verify_construct(Inter::Bookmarks::package(IBM), array_in_progress)); Inter::Frame::insert(array_in_progress, IBM); return mcc_name; } @@ -810,7 +810,7 @@ int CodeGen::Assimilate::routine_body(inter_bookmark *IBM, inter_symbol *block_n return TRUE; #endif #ifndef CORE_MODULE - CodeGen::Link::entire_splat(IBM, NULL, body, offset, block_name); + CodeGen::MergeTemplate::entire_splat(IBM, NULL, body, offset, block_name); LOG("Splat %d\n", rb_splat_count++); return FALSE; #endif diff --git a/inter/codegen-module/Chapter 2/Eliminate Redundant Labels.w b/inter/codegen-module/Chapter 2/Eliminate Redundant Labels.w index ae4d52563..aebf5ec06 100644 --- a/inter/codegen-module/Chapter 2/Eliminate Redundant Labels.w +++ b/inter/codegen-module/Chapter 2/Eliminate Redundant Labels.w @@ -13,7 +13,7 @@ on the Inter functions in a repository. = void CodeGen::Labels::create_pipeline_stage(void) { - CodeGen::Stage::new(I"eliminate-redundant-labels", CodeGen::Labels::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"eliminate-redundant-labels", CodeGen::Labels::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::Labels::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 2/Eliminate Redundant Matter.w b/inter/codegen-module/Chapter 2/Eliminate Redundant Matter.w index 51cd998e4..2bfd9a141 100644 --- a/inter/codegen-module/Chapter 2/Eliminate Redundant Matter.w +++ b/inter/codegen-module/Chapter 2/Eliminate Redundant Matter.w @@ -14,7 +14,7 @@ isn't used. = void CodeGen::Eliminate::create_pipeline_stage(void) { CodeGen::Stage::new(I"eliminate-redundant-code", - CodeGen::Eliminate::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Eliminate::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::Eliminate::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 2/Linker.w b/inter/codegen-module/Chapter 2/Merge Template.w similarity index 76% rename from inter/codegen-module/Chapter 2/Linker.w rename to inter/codegen-module/Chapter 2/Merge Template.w index a8b458b3e..fa8cea4ae 100644 --- a/inter/codegen-module/Chapter 2/Linker.w +++ b/inter/codegen-module/Chapter 2/Merge Template.w @@ -1,27 +1,27 @@ -[CodeGen::Link::] Linker. +[CodeGen::MergeTemplate::] Linker. To link inter from I7 with template code. @h Link. = -void CodeGen::Link::create_pipeline_stage(void) { - CodeGen::Stage::new(I"link", CodeGen::Link::run_pipeline_stage, TEMPLATE_FILE_STAGE_ARG); +void CodeGen::MergeTemplate::create_pipeline_stage(void) { + CodeGen::Stage::new(I"merge-template", CodeGen::MergeTemplate::run_pipeline_stage, TEMPLATE_FILE_STAGE_ARG, TRUE); } -int CodeGen::Link::run_pipeline_stage(pipeline_step *step) { +int CodeGen::MergeTemplate::run_pipeline_stage(pipeline_step *step) { inter_package *main_package = Inter::Packages::main(step->repository); inter_bookmark IBM; if (main_package) IBM = Inter::Bookmarks::at_end_of_this_package(main_package); else IBM = Inter::Bookmarks::at_start_of_this_repository(step->repository); - CodeGen::Link::link(&IBM, step->step_argument, step->the_N, step->the_PP, NULL); + CodeGen::MergeTemplate::link(&IBM, step->step_argument, step->the_N, step->the_PP, NULL); return TRUE; } inter_symbols_table *link_search_list[10]; int link_search_list_len = 0; -void CodeGen::Link::ensure_search_list(inter_repository *I) { +void CodeGen::MergeTemplate::ensure_search_list(inter_repository *I) { if (link_search_list_len == 0) { if (template_package) { link_search_list[1] = Inter::Packages::scope(Inter::Packages::main(I)); @@ -34,29 +34,29 @@ void CodeGen::Link::ensure_search_list(inter_repository *I) { } } -void CodeGen::Link::link(inter_bookmark *IBM, text_stream *template_file, int N, pathname **PP, inter_package *owner) { +void CodeGen::MergeTemplate::link(inter_bookmark *IBM, text_stream *template_file, int N, pathname **PP, inter_package *owner) { if (IBM == NULL) internal_error("no inter to link with"); inter_repository *I = IBM->read_into; - Inter::traverse_tree(I, CodeGen::Link::visitor, NULL, NULL, 0); + Inter::traverse_tree(I, CodeGen::MergeTemplate::visitor, NULL, NULL, 0); if (template_package == NULL) internal_error("unable to find template"); - CodeGen::Link::ensure_search_list(I); + CodeGen::MergeTemplate::ensure_search_list(I); inter_bookmark link_bookmark = Inter::Bookmarks::at_end_of_this_package(template_package); - I6T_kit kit = TemplateReader::kit_out(&link_bookmark, &(CodeGen::Link::receive_raw), &(CodeGen::Link::receive_command), NULL); + I6T_kit kit = TemplateReader::kit_out(&link_bookmark, &(CodeGen::MergeTemplate::receive_raw), &(CodeGen::MergeTemplate::receive_command), NULL); kit.no_i6t_file_areas = N; for (int i=0; iowning_repo, P.data[SEGMENT_LINK_IFLD]); text_stream *S2 = Inter::get_text(P.repo_segment->owning_repo, P.data[PART_LINK_IFLD]); @@ -70,7 +70,7 @@ void CodeGen::Link::visitor(inter_repository *I, inter_frame P, void *state) { dictionary *linkable_namespace = NULL; int linkable_namespace_created = FALSE; -inter_symbol *CodeGen::Link::find_in_namespace(inter_repository *I, text_stream *name) { +inter_symbol *CodeGen::MergeTemplate::find_in_namespace(inter_repository *I, text_stream *name) { if (linkable_namespace_created == FALSE) { linkable_namespace_created = TRUE; linkable_namespace = Dictionaries::new(512, FALSE); @@ -81,7 +81,7 @@ inter_symbol *CodeGen::Link::find_in_namespace(inter_repository *I, text_stream if (C.data[ID_IFLD] == PACKAGE_IST) { inter_package *P = Inter::Package::defined_by_frame(C); if (Str::ne(P->package_name->symbol_name, I"template")) - CodeGen::Link::build_r(P); + CodeGen::MergeTemplate::build_r(P); } } @@ -92,18 +92,18 @@ inter_symbol *CodeGen::Link::find_in_namespace(inter_repository *I, text_stream return NULL; } -void CodeGen::Link::build_r(inter_package *P) { - CodeGen::Link::build_only(P); +void CodeGen::MergeTemplate::build_r(inter_package *P) { + CodeGen::MergeTemplate::build_only(P); inter_frame D = Inter::Symbols::defining_frame(P->package_name); LOOP_THROUGH_INTER_CHILDREN(C, D) { if (C.data[ID_IFLD] == PACKAGE_IST) { inter_package *Q = Inter::Package::defined_by_frame(C); - CodeGen::Link::build_r(Q); + CodeGen::MergeTemplate::build_r(Q); } } } -void CodeGen::Link::build_only(inter_package *P) { +void CodeGen::MergeTemplate::build_only(inter_package *P) { inter_symbols_table *T = Inter::Packages::scope(P); if (T) { for (int i=0; isize; i++) { @@ -119,19 +119,19 @@ void CodeGen::Link::build_only(inter_package *P) { } } -inter_symbol *CodeGen::Link::find_name(inter_repository *I, text_stream *S, int deeply) { +inter_symbol *CodeGen::MergeTemplate::find_name(inter_repository *I, text_stream *S, int deeply) { for (int i=0; iread_into); text_stream *glob_storage = Inter::get_text(IBM->read_into, SID); Str::copy(glob_storage, content); - CodeGen::Link::guard(Inter::Splat::new(IBM, code_block, SID, 0, level, 0, NULL)); + CodeGen::MergeTemplate::guard(Inter::Splat::new(IBM, code_block, SID, 0, level, 0, NULL)); } @ @@ -162,7 +162,7 @@ void CodeGen::Link::entire_splat(inter_bookmark *IBM, text_stream *origin, text_ @d SUBORDINATE_FILTER_BITS (COMMENTED_FILTER_BIT + SQUOTED_FILTER_BIT + DQUOTED_FILTER_BIT + ROUTINED_FILTER_BIT) = -void CodeGen::Link::receive_raw(text_stream *S, I6T_kit *kit) { +void CodeGen::MergeTemplate::receive_raw(text_stream *S, I6T_kit *kit) { text_stream *R = Str::new(); int mode = IGNORE_WS_FILTER_BIT; LOOP_THROUGH_TEXT(pos, S) { @@ -204,22 +204,22 @@ void CodeGen::Link::receive_raw(text_stream *S, I6T_kit *kit) { } PUT_TO(R, c); if ((c == ';') && (!(mode & SUBORDINATE_FILTER_BITS))) { - CodeGen::Link::chunked_raw(R, kit); + CodeGen::MergeTemplate::chunked_raw(R, kit); mode = IGNORE_WS_FILTER_BIT; } } - CodeGen::Link::chunked_raw(R, kit); + CodeGen::MergeTemplate::chunked_raw(R, kit); Str::clear(S); } -void CodeGen::Link::chunked_raw(text_stream *S, I6T_kit *kit) { +void CodeGen::MergeTemplate::chunked_raw(text_stream *S, I6T_kit *kit) { if (Str::len(S) == 0) return; PUT_TO(S, '\n'); - CodeGen::Link::entire_splat(kit->IBM, I"template", S, (inter_t) (Inter::Bookmarks::baseline(kit->IBM) + 1), Inter::Bookmarks::package(kit->IBM)->package_name); + CodeGen::MergeTemplate::entire_splat(kit->IBM, I"template", S, (inter_t) (Inter::Bookmarks::baseline(kit->IBM) + 1), Inter::Bookmarks::package(kit->IBM)->package_name); Str::clear(S); } -void CodeGen::Link::receive_command(OUTPUT_STREAM, text_stream *command, text_stream *argument, I6T_kit *kit) { +void CodeGen::MergeTemplate::receive_command(OUTPUT_STREAM, text_stream *command, text_stream *argument, I6T_kit *kit) { if ((Str::eq_wide_string(command, L"plugin")) || (Str::eq_wide_string(command, L"type")) || (Str::eq_wide_string(command, L"open-file")) || diff --git a/inter/codegen-module/Chapter 2/Parse Linked Matter.w b/inter/codegen-module/Chapter 2/Parse Linked Matter.w index bdc7b74e2..0df457e9a 100644 --- a/inter/codegen-module/Chapter 2/Parse Linked Matter.w +++ b/inter/codegen-module/Chapter 2/Parse Linked Matter.w @@ -6,7 +6,7 @@ To generate the initial state of storage for variables. = void CodeGen::PLM::create_pipeline_stage(void) { - CodeGen::Stage::new(I"parse-linked-matter", CodeGen::PLM::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"parse-linked-matter", CodeGen::PLM::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::PLM::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 2/Reconcile Verbs.w b/inter/codegen-module/Chapter 2/Reconcile Verbs.w index 2ef522157..d045e5570 100644 --- a/inter/codegen-module/Chapter 2/Reconcile Verbs.w +++ b/inter/codegen-module/Chapter 2/Reconcile Verbs.w @@ -6,7 +6,7 @@ To reconcile clashes between assimilated and originally generated verbs. = void CodeGen::ReconcileVerbs::create_pipeline_stage(void) { - CodeGen::Stage::new(I"reconcile-verbs", CodeGen::ReconcileVerbs::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"reconcile-verbs", CodeGen::ReconcileVerbs::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::ReconcileVerbs::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 2/Resolve External Symbols.w b/inter/codegen-module/Chapter 2/Resolve External Symbols.w index 9c2749df1..4cceb32e3 100644 --- a/inter/codegen-module/Chapter 2/Resolve External Symbols.w +++ b/inter/codegen-module/Chapter 2/Resolve External Symbols.w @@ -6,7 +6,7 @@ To make sure certain symbol names translate into globally unique target symbols. = void CodeGen::Externals::create_pipeline_stage(void) { - CodeGen::Stage::new(I"resolve-external-symbols", CodeGen::Externals::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"resolve-external-symbols", CodeGen::Externals::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int resolution_failed = FALSE; diff --git a/inter/codegen-module/Chapter 2/Resolving Conditional Compilation.w b/inter/codegen-module/Chapter 2/Resolving Conditional Compilation.w index 3bd0ab8db..c506d15e1 100644 --- a/inter/codegen-module/Chapter 2/Resolving Conditional Compilation.w +++ b/inter/codegen-module/Chapter 2/Resolving Conditional Compilation.w @@ -6,7 +6,7 @@ To generate the initial state of storage for variables. = void CodeGen::RCC::create_pipeline_stage(void) { - CodeGen::Stage::new(I"resolve-conditional-compilation", CodeGen::RCC::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"resolve-conditional-compilation", CodeGen::RCC::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::RCC::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 2/Uniqueness.w b/inter/codegen-module/Chapter 2/Uniqueness.w index e0102ada6..d2fd2464e 100644 --- a/inter/codegen-module/Chapter 2/Uniqueness.w +++ b/inter/codegen-module/Chapter 2/Uniqueness.w @@ -6,7 +6,7 @@ To make sure certain symbol names translate into globally unique target symbols. = void CodeGen::Uniqueness::create_pipeline_stage(void) { - CodeGen::Stage::new(I"make-identifiers-unique", CodeGen::Uniqueness::run_pipeline_stage, NO_STAGE_ARG); + CodeGen::Stage::new(I"make-identifiers-unique", CodeGen::Uniqueness::run_pipeline_stage, NO_STAGE_ARG, FALSE); } int CodeGen::Uniqueness::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Chapter 3/Inter Primitives.w b/inter/codegen-module/Chapter 3/Inter Primitives.w index c8a17efa3..56268671a 100644 --- a/inter/codegen-module/Chapter 3/Inter Primitives.w +++ b/inter/codegen-module/Chapter 3/Inter Primitives.w @@ -230,10 +230,10 @@ void Primitives::emit_one(inter_repository *I, inter_bookmark *IBM, text_stream if (to == NULL) internal_error("no symbol"); TEMPORARY_TEXT(prim_command); WRITE_TO(prim_command, "primitive %S %S", prim, category); - CodeGen::Link::guard(Inter::Defn::read_construct_text(prim_command, NULL, IBM)); + CodeGen::MergeTemplate::guard(Inter::Defn::read_construct_text(prim_command, NULL, IBM)); inter_error_message *E = NULL; *to = Inter::Textual::find_symbol(I, NULL, Inter::get_global_symbols(I), prim, PRIMITIVE_IST, &E); - CodeGen::Link::guard(E); + CodeGen::MergeTemplate::guard(E); DISCARD_TEXT(prim_command); } diff --git a/inter/codegen-module/Chapter 3/The Veneer.w b/inter/codegen-module/Chapter 3/The Veneer.w index 11789e090..b201a5670 100644 --- a/inter/codegen-module/Chapter 3/The Veneer.w +++ b/inter/codegen-module/Chapter 3/The Veneer.w @@ -168,7 +168,7 @@ inter_symbol *Veneer::make(inter_package *veneer_package, inter_bookmark *IBM, i *slot = Inter::SymbolsTables::symbol_from_name_creating(tab, S); if (Str::len(T) > 0) Inter::Symbols::set_translate(*slot, T); Inter::Symbols::annotate_i(IBM->read_into, *slot, VENEER_IANN, 1); - CodeGen::Link::guard(Inter::Constant::new_numerical(IBM, + CodeGen::MergeTemplate::guard(Inter::Constant::new_numerical(IBM, Inter::SymbolsTables::id_from_symbol(IBM->read_into, veneer_package, *slot), Inter::SymbolsTables::id_from_symbol(IBM->read_into, veneer_package, unchecked_kind_symbol), LITERAL_IVAL, 0, diff --git a/inter/codegen-module/Chapter 4/Code Generation.w b/inter/codegen-module/Chapter 4/Code Generation.w index d0c1c6512..efff32d09 100644 --- a/inter/codegen-module/Chapter 4/Code Generation.w +++ b/inter/codegen-module/Chapter 4/Code Generation.w @@ -6,7 +6,7 @@ To generate final code from intermediate code. = void CodeGen::create_pipeline_stage(void) { - CodeGen::Stage::new(I"generate", CodeGen::run_pipeline_stage, TEXT_OUT_STAGE_ARG); + CodeGen::Stage::new(I"generate", CodeGen::run_pipeline_stage, TEXT_OUT_STAGE_ARG, FALSE); } int CodeGen::run_pipeline_stage(pipeline_step *step) { diff --git a/inter/codegen-module/Contents.w b/inter/codegen-module/Contents.w index ad97c368c..66cf49b33 100644 --- a/inter/codegen-module/Contents.w +++ b/inter/codegen-module/Contents.w @@ -11,7 +11,7 @@ Chapter 1: Setting Up Pipelines Chapter 2: Miscellaneous Pipeline Stages - Linker + Merge Template Template Reader Parse Linked Matter Resolving Conditional Compilation