From 741209e2253df9450ad9d99daf73ced8f33a6387 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sat, 1 May 2021 18:18:59 +0100 Subject: [PATCH] Scene status and changing made synoptic --- docs/codegen-module/3-act.html | 2 +- docs/codegen-module/3-act2.html | 2 +- docs/codegen-module/3-chr.html | 2 +- docs/codegen-module/3-ext.html | 2 +- docs/codegen-module/3-ins.html | 101 +++++++++ docs/codegen-module/3-lt.html | 2 +- docs/codegen-module/3-prp.html | 2 +- docs/codegen-module/3-rls.html | 2 +- docs/codegen-module/3-rlt.html | 2 +- docs/codegen-module/3-rsp.html | 2 +- docs/codegen-module/3-scn.html | 213 ++++++++++++++++++ docs/codegen-module/3-su.html | 25 +- docs/codegen-module/3-tbl.html | 2 +- docs/codegen-module/4-cg.html | 2 +- docs/codegen-module/index.html | 10 + docs/core-module/1-htc.html | 1 + docs/if-module/3-scn.html | 7 +- docs/runtime-module/2-ec.html | 32 +-- docs/runtime-module/2-emt.html | 2 +- docs/runtime-module/2-hrr.html | 86 ++++--- docs/runtime-module/5-ins.html | 23 +- docs/runtime-module/5-rsfk.html | 2 +- docs/runtime-module/6-scn.html | 161 ++++++------- inform7/Figures/memory-diagnostics.txt | 64 +++--- inform7/Figures/timings-diagnostics.txt | 37 +-- .../core-module/Chapter 1/How To Compile.w | 1 + inform7/if-module/Chapter 3/Scenes.w | 7 +- inform7/runtime-module/Chapter 2/Hierarchy.w | 46 +++- inform7/runtime-module/Chapter 5/Instances.w | 21 +- inform7/runtime-module/Chapter 6/Scenes.w | 144 +++++------- inter/codegen-module/Chapter 3/Instances.w | 20 ++ inter/codegen-module/Chapter 3/Scenes.w | 123 ++++++++++ .../Chapter 3/Synoptic Utilities.w | 13 ++ inter/codegen-module/Contents.w | 2 + 34 files changed, 858 insertions(+), 305 deletions(-) create mode 100644 docs/codegen-module/3-ins.html create mode 100644 docs/codegen-module/3-scn.html create mode 100644 inter/codegen-module/Chapter 3/Instances.w create mode 100644 inter/codegen-module/Chapter 3/Scenes.w diff --git a/docs/codegen-module/3-act.html b/docs/codegen-module/3-act.html index b3345a2f8..b8f78a643 100644 --- a/docs/codegen-module/3-act.html +++ b/docs/codegen-module/3-act.html @@ -201,7 +201,7 @@ of packages of type _activity
  • This code is used in §2.
diff --git a/docs/codegen-module/3-act2.html b/docs/codegen-module/3-act2.html index 11b1f5b8c..28bebdb14 100644 --- a/docs/codegen-module/3-act2.html +++ b/docs/codegen-module/3-act2.html @@ -274,7 +274,7 @@ of packages of type _action
  • This code is used in §3.
diff --git a/docs/codegen-module/3-chr.html b/docs/codegen-module/3-chr.html index e35160763..fe59435b3 100644 --- a/docs/codegen-module/3-chr.html +++ b/docs/codegen-module/3-chr.html @@ -623,7 +623,7 @@ of packages of type _relation
  • This code is used in §2.6.
diff --git a/docs/codegen-module/3-ext.html b/docs/codegen-module/3-ext.html index 35d1deb13..6d97403cb 100644 --- a/docs/codegen-module/3-ext.html +++ b/docs/codegen-module/3-ext.html @@ -215,7 +215,7 @@ is its allocation ID plus 1. (In effect, this means extensions are numbered from
  • This code is used in §2.
diff --git a/docs/codegen-module/3-ins.html b/docs/codegen-module/3-ins.html new file mode 100644 index 000000000..786fa6af1 --- /dev/null +++ b/docs/codegen-module/3-ins.html @@ -0,0 +1,101 @@ + + + + Instances + + + + + + + + + + + + + + + + + + +
+ + +

To renumber the instances and construct suitable functions and arrays.

+ +

§1. Before this runs, instance packages are scattered all over the Inter tree. +

+ +

As this is called, Synoptic Utilities has already formed a list instance_nodes +of packages of type _instance. +

+ +
+void SynopticInstances::renumber(inter_tree *I, inter_tree_location_list *instance_nodes) {
+    if (TreeLists::len(instance_nodes) > 0) {
+        TreeLists::sort(instance_nodes, Synoptic::module_order);
+		for (int i=0; i<TreeLists::len(instance_nodes); i++) {
+			inter_package *pack = Inter::Package::defined_by_frame(instance_nodes->list[i].node);
+			inter_tree_node *D = Synoptic::get_definition(pack, I"scene_id");
+			D->W.data[DATA_CONST_IFLD+1] = (inter_ti) i;
+		}
+    }
+}
+
+ + +
+ + + diff --git a/docs/codegen-module/3-lt.html b/docs/codegen-module/3-lt.html index e9d45a864..b0d8f8f95 100644 --- a/docs/codegen-module/3-lt.html +++ b/docs/codegen-module/3-lt.html @@ -200,7 +200,7 @@ and use that to define a sorting function on nodes: } diff --git a/docs/codegen-module/3-prp.html b/docs/codegen-module/3-prp.html index 72027836a..06f351582 100644 --- a/docs/codegen-module/3-prp.html +++ b/docs/codegen-module/3-prp.html @@ -119,7 +119,7 @@ of packages of type _activity
  • This code is used in §2.
diff --git a/docs/codegen-module/3-rls.html b/docs/codegen-module/3-rls.html index 8a07546a3..a422080a8 100644 --- a/docs/codegen-module/3-rls.html +++ b/docs/codegen-module/3-rls.html @@ -367,7 +367,7 @@ of packages of type _rulebook
  • This code is used in §2.7.
diff --git a/docs/codegen-module/3-rlt.html b/docs/codegen-module/3-rlt.html index 1f4d5925a..4d0e74330 100644 --- a/docs/codegen-module/3-rlt.html +++ b/docs/codegen-module/3-rlt.html @@ -199,7 +199,7 @@ of packages of type _relation
  • This code is used in §2.
diff --git a/docs/codegen-module/3-rsp.html b/docs/codegen-module/3-rsp.html index 4d8fe3075..8011e942a 100644 --- a/docs/codegen-module/3-rsp.html +++ b/docs/codegen-module/3-rsp.html @@ -269,7 +269,7 @@ code is less limited.
  • This code is used in §2.
diff --git a/docs/codegen-module/3-scn.html b/docs/codegen-module/3-scn.html new file mode 100644 index 000000000..a28f6396d --- /dev/null +++ b/docs/codegen-module/3-scn.html @@ -0,0 +1,213 @@ + + + + Scenes + + + + + + + + + + + + + + + + + + +
+ + +

To renumber the scenes and construct suitable functions and arrays.

+ +

§1. Before this runs, property packages are scattered all over the Inter tree. +We must allocate each one a unique ID. +

+ +

As this is called, Synoptic Utilities has already formed a list property_nodes +of packages of type _activity. +

+ +
+void SynopticScenes::renumber(inter_tree *I, inter_tree_location_list *scene_nodes) {
+    if (TreeLists::len(scene_nodes) > 0) {
+        TreeLists::sort(scene_nodes, Synoptic::module_order);
+        for (int i=0; i<TreeLists::len(scene_nodes); i++) {
+            inter_package *pack = Inter::Package::defined_by_frame(scene_nodes->list[i].node);
+            text_stream *name = Metadata::read_optional_textual(pack, I"^name");
+            LOG("scene %d: %S\n", i, name);
+        }
+    }
+}
+
+

§2. There are also resources to create in the synoptic module: +

+ +
enum SHOWSCENESTATUS_SYNID
+enum DETECTSCENECHANGE_SYNID
+
+
+int SynopticScenes::redefine(inter_tree *I, inter_tree_node *P, inter_symbol *con_s, int synid) {
+    inter_package *pack = Inter::Packages::container(P);
+    inter_bookmark IBM = Inter::Bookmarks::at_end_of_this_package(pack);
+    switch (synid) {
+        case SHOWSCENESTATUS_SYNID: {
+            packaging_state save = Synoptic::begin_redefining_function(&IBM, I, P);
+            Add a body of code to the SHOWSCENESTATUS function2.1;
+            Synoptic::end_redefining_function(I, save);
+            break;
+        }
+        case DETECTSCENECHANGE_SYNID: {
+            packaging_state save = Synoptic::begin_redefining_function(&IBM, I, P);
+            Add a body of code to the DETECTSCENECHANGE function2.2;
+            Synoptic::end_redefining_function(I, save);
+            break;
+        }
+        default: return FALSE;
+    }
+    return TRUE;
+}
+
+

§2.1. Add a body of code to the SHOWSCENESTATUS function2.1 = +

+ +
+    for (int i=0; i<TreeLists::len(scene_nodes); i++) {
+        inter_package *pack = Inter::Package::defined_by_frame(scene_nodes->list[i].node);
+        inter_symbol *ssf_s = Metadata::read_symbol(pack, I"^scene_status_fn");
+        Produce::inv_call(I, ssf_s);
+    }
+
+
  • This code is used in §2.
+

§2.2. There is one argument, chs: the number of iterations so far. Iterations +occur because each set of scene changes could change the circumstances in such +a way that other scene changes are now required (through external conditions, +not through anchors); we don't want this to lock up, so we will cap recursion. +Within the routine, a second local variable, ch, is a flag indicating +whether any change in status has or has not occurred. +

+ +
define MAX_SCENE_CHANGE_ITERATION 20
+
+

Add a body of code to the DETECTSCENECHANGE function2.2 = +

+ +
+    inter_symbol *chs_s = Synoptic::get_local(I, I"chs");
+    inter_symbol *myself_s = Synoptic::get_local(I, I"myself");
+    inter_symbol *Again_l = Produce::reserve_label(I, I".Again");
+    inter_symbol *CScene_l = Produce::reserve_label(I, I".CScene");
+    Produce::place_label(I, Again_l);
+    for (int i=0; i<TreeLists::len(scene_nodes); i++) {
+        inter_package *pack = Inter::Package::defined_by_frame(scene_nodes->list[i].node);
+        inter_symbol *scf_s = Metadata::read_symbol(pack, I"^scene_change_fn");
+        Produce::inv_primitive(I, IF_BIP);
+        Produce::down(I);
+            Produce::inv_call(I, scf_s);
+            Produce::code(I);
+            Produce::down(I);
+                Produce::inv_primitive(I, JUMP_BIP);
+                Produce::down(I);
+                    Produce::lab(I, CScene_l);
+                Produce::up(I);
+            Produce::up(I);
+        Produce::up(I);
+    }
+    Produce::rfalse(I);
+
+    Produce::place_label(I, CScene_l);
+
+    Produce::inv_primitive(I, IF_BIP);
+    Produce::down(I);
+        Produce::inv_primitive(I, GT_BIP);
+        Produce::down(I);
+            Produce::val_symbol(I, K_value, chs_s);
+            Produce::val(I, K_value, LITERAL_IVAL, (inter_ti) MAX_SCENE_CHANGE_ITERATION);
+        Produce::up(I);
+        Produce::code(I);
+        Produce::down(I);
+            Produce::inv_primitive(I, PRINT_BIP);
+            Produce::down(I);
+                Produce::val_text(I, I">--> The scene change machinery is stuck.\n");
+            Produce::up(I);
+            Produce::rtrue(I);
+        Produce::up(I);
+    Produce::up(I);
+    Produce::inv_primitive(I, PREINCREMENT_BIP);
+    Produce::down(I);
+        Produce::ref_symbol(I, K_value, chs_s);
+    Produce::up(I);
+	Produce::inv_call(I, myself_s);
+	Produce::down(I);
+		Produce::inv_primitive(I, PREINCREMENT_BIP);
+		Produce::down(I);
+			Produce::ref_symbol(I, K_value, chs_s);
+		Produce::up(I);
+	Produce::up(I);
+	Produce::rtrue(I);
+    Produce::inv_primitive(I, JUMP_BIP);
+    Produce::down(I);
+        Produce::lab(I, Again_l);
+    Produce::up(I);
+
+
  • This code is used in §2.
+ + +
+ + + diff --git a/docs/codegen-module/3-su.html b/docs/codegen-module/3-su.html index 8e94be7c5..d6361d4a3 100644 --- a/docs/codegen-module/3-su.html +++ b/docs/codegen-module/3-su.html @@ -97,6 +97,8 @@ function togglePopup(material_id) { inter_tree_location_list *table_column_usage_nodes = NULL; inter_tree_location_list *past_tense_action_nodes = NULL; inter_tree_location_list *past_tense_condition_nodes = NULL; +inter_tree_location_list *instance_nodes = NULL; +inter_tree_location_list *scene_nodes = NULL; int Synoptic::go(pipeline_step *step) { text_nodes = TreeLists::new(); @@ -113,6 +115,8 @@ function togglePopup(material_id) { table_column_usage_nodes = TreeLists::new(); past_tense_action_nodes = TreeLists::new(); past_tense_condition_nodes = TreeLists::new(); + instance_nodes = TreeLists::new(); + scene_nodes = TreeLists::new(); InterTree::traverse(step->repository, Synoptic::visitor, NULL, NULL, 0); SynopticText::alphabetise(step->repository, text_nodes); @@ -126,6 +130,8 @@ function togglePopup(material_id) { SynopticRelations::renumber(step->repository, relation_nodes); SynopticTables::renumber(step->repository, table_nodes); SynopticChronology::renumber(step->repository, past_tense_action_nodes); + SynopticInstances::renumber(step->repository, instance_nodes); + SynopticScenes::renumber(step->repository, scene_nodes); return TRUE; } @@ -167,6 +173,12 @@ function togglePopup(material_id) { TreeLists::add(past_tense_action_nodes, P); if (ptype == PackageTypes::get(I, I"_past_condition")) TreeLists::add(past_tense_condition_nodes, P); + if (ptype == PackageTypes::get(I, I"_instance")) { + TreeLists::add(instance_nodes, P); + inter_package *pack = Inter::Package::defined_by_frame(P); + if (Metadata::exists(pack, I"^is_scene")) + TreeLists::add(scene_nodes, P); + } } } @@ -191,13 +203,14 @@ function togglePopup(material_id) { if (SynopticRelations::redefine(I, P, con_s, synid)) return; if (SynopticTables::redefine(I, P, con_s, synid)) return; if (SynopticChronology::redefine(I, P, con_s, synid)) return; + if (SynopticScenes::redefine(I, P, con_s, synid)) return; LOG("Couldn't consolidate $3\n", con_s); internal_error("symbol cannot be consolidated"); } } } -int Synoptic::module_order(const void *ent1, const void *ent2) { +int Synoptic::module_order(const void *ent1, const void *ent2) { itl_entry *E1 = (itl_entry *) ent1; itl_entry *E2 = (itl_entry *) ent2; if (E1 == E2) return 0; @@ -234,14 +247,14 @@ function togglePopup(material_id) { return InterSymbolsTables::create_with_unique_name(Inter::Packages::scope(pack), name); } -inter_symbol *Synoptic::get_local(inter_tree *I, text_stream *name) { +inter_symbol *Synoptic::get_local(inter_tree *I, text_stream *name) { inter_package *pack = Inter::Bookmarks::package(Produce::at(I)); inter_symbol *loc_s = InterSymbolsTables::symbol_from_name(Inter::Packages::scope(pack), name); if (loc_s == NULL) Metadata::err("local not found", pack, name); return loc_s; } -packaging_state Synoptic::begin_redefining_function(inter_bookmark *IBM, inter_tree *I, inter_tree_node *P) { +packaging_state Synoptic::begin_redefining_function(inter_bookmark *IBM, inter_tree *I, inter_tree_node *P) { if (P->W.data[FORMAT_CONST_IFLD] != CONSTANT_ROUTINE) { LOG("%d\n", P->W.data[FORMAT_CONST_IFLD]); internal_error("not a function"); @@ -260,7 +273,7 @@ function togglePopup(material_id) { return save; } -void Synoptic::end_redefining_function(inter_tree *I, packaging_state save) { +void Synoptic::end_redefining_function(inter_tree *I, packaging_state save) { Packaging::set_state(I, save.saved_IRS, save.saved_enclosure); Produce::pop_code_position(I); Site::set_cir(I, NULL); @@ -346,7 +359,7 @@ function togglePopup(material_id) { Q->W.data[Q->W.extent-1] = val2; } -inter_tree_node *Synoptic::get_definition(inter_package *pack, text_stream *name) { +inter_tree_node *Synoptic::get_definition(inter_package *pack, text_stream *name) { inter_symbol *def_s = InterSymbolsTables::symbol_from_name(Inter::Packages::scope(pack), name); if (def_s == NULL) { LOG("Unable to find symbol %S in $6\n", name, pack); @@ -380,7 +393,7 @@ function togglePopup(material_id) { } diff --git a/docs/codegen-module/3-tbl.html b/docs/codegen-module/3-tbl.html index 7e48bbd23..8eb9aefe2 100644 --- a/docs/codegen-module/3-tbl.html +++ b/docs/codegen-module/3-tbl.html @@ -288,7 +288,7 @@ of packages of type _table
  • This code is used in §2.
diff --git a/docs/codegen-module/4-cg.html b/docs/codegen-module/4-cg.html index 601bdef17..676f64e01 100644 --- a/docs/codegen-module/4-cg.html +++ b/docs/codegen-module/4-cg.html @@ -305,7 +305,7 @@ we also have to direct it to a given text. } diff --git a/docs/codegen-module/index.html b/docs/codegen-module/index.html index 1aa2b3e61..2c1c2be7b 100644 --- a/docs/codegen-module/index.html +++ b/docs/codegen-module/index.html @@ -198,6 +198,11 @@ Actions
- To renumber the actions and construct suitable functions and arrays.

+
  • +

    + Instances - + To renumber the instances and construct suitable functions and arrays.

    +
  • Properties - @@ -218,6 +223,11 @@ Chronology - To construct suitable functions and arrays to manage past-tense references in code.

  • +
  • +

    + Scenes - + To renumber the scenes and construct suitable functions and arrays.

    +
  • diff --git a/docs/core-module/1-htc.html b/docs/core-module/1-htc.html index 148606cb3..fbfe777bf 100644 --- a/docs/core-module/1-htc.html +++ b/docs/core-module/1-htc.html @@ -326,6 +326,7 @@ so on. Those absolute basics are made here. BENCH(RTRules::rulebook_var_creators) BENCH(RTRules::compile_rulebooks) BENCH(RTRules::compile_metadata) + BENCH(RTInstances::compile_metadata) BENCH(RTProperties::compile_metadata) BENCH(RTActivities::activity_var_creators) BENCH(RTVerbs::ConjugateVerb) diff --git a/docs/if-module/3-scn.html b/docs/if-module/3-scn.html index f4f744a1d..f657b4893 100644 --- a/docs/if-module/3-scn.html +++ b/docs/if-module/3-scn.html @@ -97,8 +97,11 @@ to non-trivial functions as well as tables of data. int Scenes::production_line(int stage, int debugging, stopwatch_timer *sequence_timer) { if (stage == INTER1_CSEQ) { - BENCH(RTScenes::DetectSceneChange_routine); - BENCH(RTScenes::ShowSceneStatus_routine); + BENCH(RTScenes::compile_change_functions); + BENCH(RTScenes::compile_show_status_functions); + } + if (stage == INTER3_CSEQ) { + BENCH(RTScenes::compile_synoptic_resources); } return FALSE; } diff --git a/docs/runtime-module/2-ec.html b/docs/runtime-module/2-ec.html index df154b935..3bf0d93ae 100644 --- a/docs/runtime-module/2-ec.html +++ b/docs/runtime-module/2-ec.html @@ -108,10 +108,10 @@ instruction last emitted, not after it.
  • EmitCode::up then returns us back to where we were.
  • -void EmitCode::up(void) {
    +void EmitCode::up(void) {
         Produce::up(Emit::tree());
     }
    -void EmitCode::down(void) {
    +void EmitCode::down(void) {
         Produce::down(Emit::tree());
     }
     
    @@ -127,7 +127,7 @@ have made, net:

    §5. Structural.

    -void EmitCode::code(void) {
    +void EmitCode::code(void) {
         Produce::code(Emit::tree());
     }
     
    @@ -140,7 +140,7 @@ start of a function.
     

    -void EmitCode::comment(text_stream *text) {
    +void EmitCode::comment(text_stream *text) {
         if (Functions::a_function_is_being_compiled() == FALSE)
             internal_error("code comment emitted outside function");
         inter_ti ID = Inter::Warehouse::create_text(Emit::warehouse(), Emit::package());
    @@ -153,7 +153,7 @@ start of a function.
     

    -void EmitCode::val_number(inter_ti N) {
    +void EmitCode::val_number(inter_ti N) {
         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, N);
     }
     
    @@ -165,11 +165,11 @@ start of a function.
         Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
     }
     
    -void EmitCode::val_iname(kind *K, inter_name *iname) {
    +void EmitCode::val_iname(kind *K, inter_name *iname) {
         Produce::val_iname(Emit::tree(), K, iname);
     }
     
    -void EmitCode::val_text(text_stream *text) {
    +void EmitCode::val_text(text_stream *text) {
         Produce::val_text(Emit::tree(), text);
     }
     
    @@ -185,7 +185,7 @@ start of a function.
         Produce::val_nothing(Emit::tree());
     }
     
    -void EmitCode::val_symbol(kind *K, inter_symbol *S) {
    +void EmitCode::val_symbol(kind *K, inter_symbol *S) {
         Produce::val_symbol(Emit::tree(), K, S);
     }
     
    @@ -205,7 +205,7 @@ start of a function. Produce::ref_iname(Emit::tree(), K, iname); } -void EmitCode::ref_symbol(kind *K, inter_symbol *S) { +void EmitCode::ref_symbol(kind *K, inter_symbol *S) { Produce::ref_symbol(Emit::tree(), K, S); }
    @@ -213,11 +213,11 @@ start of a function.

    -void EmitCode::inv(inter_ti bip) {
    +void EmitCode::inv(inter_ti bip) {
         Produce::inv_primitive(Emit::tree(), bip);
     }
     
    -void EmitCode::call(inter_name *fn_iname) {
    +void EmitCode::call(inter_name *fn_iname) {
         Produce::inv_call_iname(Emit::tree(), fn_iname);
     }
     
    @@ -231,11 +231,11 @@ current function:
     

    -void EmitCode::rtrue(void) {
    +void EmitCode::rtrue(void) {
         Produce::rtrue(Emit::tree());
     }
     
    -void EmitCode::rfalse(void) {
    +void EmitCode::rfalse(void) {
         Produce::rfalse(Emit::tree());
     }
     
    @@ -256,15 +256,15 @@ advance:

    -inter_symbol *EmitCode::reserve_label(text_stream *identifier) {
    +inter_symbol *EmitCode::reserve_label(text_stream *identifier) {
         return Produce::reserve_label(Emit::tree(), identifier);
     }
     
    -void EmitCode::place_label(inter_symbol *lab_s) {
    +void EmitCode::place_label(inter_symbol *lab_s) {
         Produce::place_label(Emit::tree(), lab_s);
     }
     
    -void EmitCode::lab(inter_symbol *L) {
    +void EmitCode::lab(inter_symbol *L) {
         Produce::lab(Emit::tree(), L);
     }
     
    diff --git a/docs/runtime-module/2-emt.html b/docs/runtime-module/2-emt.html index 466745ea8..be02c43f8 100644 --- a/docs/runtime-module/2-emt.html +++ b/docs/runtime-module/2-emt.html @@ -381,7 +381,7 @@ it represents an actual number at run-time, the second if not:

    -inter_name *Emit::iname_constant(inter_name *con_iname, kind *K, inter_name *val_iname) {
    +inter_name *Emit::iname_constant(inter_name *con_iname, kind *K, inter_name *val_iname) {
         packaging_state save = Packaging::enter_home_of(con_iname);
         inter_symbol *con_s = Produce::define_symbol(con_iname);
         inter_symbol *kind_s = Produce::kind_to_symbol(K);
    diff --git a/docs/runtime-module/2-hrr.html b/docs/runtime-module/2-hrr.html
    index aa7e102a8..05807cd52 100644
    --- a/docs/runtime-module/2-hrr.html
    +++ b/docs/runtime-module/2-hrr.html
    @@ -72,7 +72,7 @@ function togglePopup(material_id) {
         
     

    To provide an enforced structure and set of naming conventions for packages and names in the Inter code we generate.

    -
    +

    §1. Introduction. See What This Module Does for an overview of how Inter hierarchies work.

    @@ -286,10 +286,11 @@ that the compiler can refer to it. Establish relations8.1.36; Establish rulebooks8.1.38; Establish rules8.1.40; - Establish tables8.1.42; - Establish variables8.1.44; - Establish enclosed matter8.1.46; - The rest8.1.48; + Establish scenes8.1.42; + Establish tables8.1.44; + Establish variables8.1.46; + Establish enclosed matter8.1.48; + The rest8.1.50;
    • This code is used in §8.

    §8.2. Establish locations for material expected to be added by linking8.2 = @@ -346,11 +347,11 @@ that the compiler can refer to it. H_C_T(KIT_CONFIGURATION_BITMAP_HL, I"KIT_CONFIGURATION_BITMAP") H_C_T(KIT_CONFIGURATION_LOOKMODE_HL, I"KIT_CONFIGURATION_LOOKMODE") H_C_T(LOCALPARKING_HL, I"LocalParking") + H_C_T(RNG_SEED_AT_START_OF_PLAY_HL, I"RNG_SEED_AT_START_OF_PLAY") H_END H_BEGIN(HierarchyLocations::synoptic_submodule(I, basics)) H_C_T(MAX_FRAME_SIZE_NEEDED_HL, I"MAX_FRAME_SIZE_NEEDED") - H_C_T(RNG_SEED_AT_START_OF_PLAY_HL, I"RNG_SEED_AT_START_OF_PLAY") H_END submodule_identity *basic_extras = Packaging::register_submodule(I"BasicInformExtrasKit"); @@ -845,7 +846,14 @@ that the compiler can refer to it.

    enum INSTANCES_HAP
     enum INSTANCE_NAME_METADATA_HL
    +enum INSTANCE_VALUE_METADATA_HL
    +enum INSTANCE_KIND_METADATA_HL
    +enum INSTANCE_IS_SCENE_METADATA_HL
    +enum INSTANCE_SSF_METADATA_HL
    +enum INSTANCE_SCF_METADATA_HL
     enum INSTANCE_HL
    +enum SCENE_STATUS_FN_HL
    +enum SCENE_CHANGE_FN_HL
     enum BACKDROP_FOUND_IN_FN_HL
     enum REGION_FOUND_IN_FN_HL
     enum SHORT_NAME_FN_HL
    @@ -864,7 +872,14 @@ that the compiler can refer to it.
         H_BEGIN(HierarchyLocations::local_submodule(instances))
             H_BEGIN_AP(INSTANCES_HAP,             I"instance", I"_instance")
                 H_C_U(INSTANCE_NAME_METADATA_HL,  I"^name")
    +            H_C_U(INSTANCE_VALUE_METADATA_HL, I"^value")
    +            H_C_U(INSTANCE_KIND_METADATA_HL,  I"^kind")
    +            H_C_U(INSTANCE_IS_SCENE_METADATA_HL, I"^is_scene")
    +            H_C_U(INSTANCE_SSF_METADATA_HL,   I"^scene_status_fn")
    +            H_C_U(INSTANCE_SCF_METADATA_HL,   I"^scene_change_fn")
                 H_C_U(INSTANCE_HL,                I"I")
    +            H_F_U(SCENE_STATUS_FN_HL,         I"scene_status_fn")
    +            H_F_U(SCENE_CHANGE_FN_HL,         I"scene_change_fn")
                 H_F_U(BACKDROP_FOUND_IN_FN_HL,    I"backdrop_found_in_fn")
                 H_F_G(SHORT_NAME_FN_HL,           I"short_name_fn", I"SN_R")
                 H_F_G(SHORT_NAME_PROPERTY_FN_HL,  I"short_name_property_fn", I"SN_R_A")
    @@ -882,8 +897,6 @@ that the compiler can refer to it.
     
     
    enum INITIAL_MAX_SCORE_HL
     enum NO_DIRECTIONS_HL
    -enum SHOWSCENESTATUS_HL
    -enum DETECTSCENECHANGE_HL
     enum MAP_STORAGE_HL
     enum INITIALSITUATION_HL
     enum PLAYER_OBJECT_INIS_HL
    @@ -900,18 +913,19 @@ that the compiler can refer to it.
     
         submodule_identity *interactive_fiction = Packaging::register_submodule(I"interactive_fiction");
     
    -    H_BEGIN(HierarchyLocations::synoptic_submodule(I, interactive_fiction))
    -        H_C_T(INITIAL_MAX_SCORE_HL,           I"INITIAL_MAX_SCORE")
    -        H_C_T(NO_DIRECTIONS_HL,               I"No_Directions")
    -        H_F_T(SHOWSCENESTATUS_HL,             I"show_scene_status_fn", I"ShowSceneStatus")
    -        H_F_T(DETECTSCENECHANGE_HL,           I"detect_scene_change_fn", I"DetectSceneChange")
    -        H_C_T(MAP_STORAGE_HL,                 I"Map_Storage")
    -        H_C_T(INITIALSITUATION_HL,            I"InitialSituation")
    +    H_BEGIN(HierarchyLocations::generic_submodule(I, interactive_fiction))
             H_C_T(PLAYER_OBJECT_INIS_HL,          I"PLAYER_OBJECT_INIS")
             H_C_T(START_OBJECT_INIS_HL,           I"START_OBJECT_INIS")
             H_C_T(START_ROOM_INIS_HL,             I"START_ROOM_INIS")
             H_C_T(START_TIME_INIS_HL,             I"START_TIME_INIS")
             H_C_T(DONE_INIS_HL,                   I"DONE_INIS")
    +    H_END
    +
    +    H_BEGIN(HierarchyLocations::synoptic_submodule(I, interactive_fiction))
    +        H_C_T(INITIAL_MAX_SCORE_HL,           I"INITIAL_MAX_SCORE")
    +        H_C_T(NO_DIRECTIONS_HL,               I"No_Directions")
    +        H_C_T(MAP_STORAGE_HL,                 I"Map_Storage")
    +        H_C_T(INITIALSITUATION_HL,            I"InitialSituation")
             H_BEGIN_AP(DIRECTIONS_HAP,            I"direction", I"_direction")
                 H_C_G(DIRECTION_HL,               I"DirectionObject")
             H_END
    @@ -1322,7 +1336,23 @@ that the compiler can refer to it.
         H_END
     
    • This code is used in §8.1.
    -

    §8.1.41. Tables.

    +

    §8.1.41. Scenes.

    + +
    enum SHOWSCENESTATUS_HL
    +enum DETECTSCENECHANGE_HL
    +
    +

    §8.1.42. Establish scenes8.1.42 = +

    + +
    +    submodule_identity *scenes = Packaging::register_submodule(I"scenes");
    +    H_BEGIN(HierarchyLocations::synoptic_submodule(I, scenes))
    +        H_F_T(SHOWSCENESTATUS_HL,             I"show_scene_status_fn", I"ShowSceneStatus")
    +        H_F_T(DETECTSCENECHANGE_HL,           I"detect_scene_change_fn", I"DetectSceneChange")
    +    H_END
    +
    +
    • This code is used in §8.1.
    +

    §8.1.43. Tables.

    enum TABLES_HAP
     enum TABLE_NAME_METADATA_HL
    @@ -1342,7 +1372,7 @@ that the compiler can refer to it.
     enum TC_KOV_HL
     enum TB_BLANKS_HL
     
    -

    §8.1.42. Establish tables8.1.42 = +

    §8.1.44. Establish tables8.1.44 =

    @@ -1382,13 +1412,13 @@ that the compiler can refer to it.
         H_END
     
    • This code is used in §8.1.
    -

    §8.1.43. Variables.

    +

    §8.1.45. Variables.

    enum VARIABLES_HAP
     enum VARIABLE_NAME_METADATA_HL
     enum VARIABLE_HL
     
    -

    §8.1.44. Establish variables8.1.44 = +

    §8.1.46. Establish variables8.1.46 =

    @@ -1402,7 +1432,7 @@ that the compiler can refer to it.
         H_END
     
    • This code is used in §8.1.
    -

    §8.1.45. Enclosed matter.

    +

    §8.1.47. Enclosed matter.

    enum LITERALS_HAP
     enum TEXT_LITERAL_HL
    @@ -1420,7 +1450,7 @@ that the compiler can refer to it.
     enum GROUPS_TOGETHER_HAP
     enum GROUP_TOGETHER_FN_HL
     
    -

    §8.1.46. Establish enclosed matter8.1.46 = +

    §8.1.48. Establish enclosed matter8.1.48 =

    @@ -1448,7 +1478,7 @@ that the compiler can refer to it.
         H_END
     
    • This code is used in §8.1.
    -

    §8.1.47.

    +

    §8.1.49.

    enum K_OBJECT_XPACKAGE from 0
     enum K_NUMBER_XPACKAGE
    @@ -1486,7 +1516,7 @@ that the compiler can refer to it.
     enum TABLEOFEXTERNALFILES_HL
     enum PRINT_SCENE_HL
     
    -

    §8.1.48. The rest8.1.48 = +

    §8.1.50. The rest8.1.50 =

    @@ -2157,7 +2187,7 @@ at which this array should be placed, by calling, e.g., 
     
     
    -inter_name *Hierarchy::find(int id) {
    +inter_name *Hierarchy::find(int id) {
         return HierarchyLocations::find(Emit::tree(), id);
     }
     
    @@ -2180,7 +2210,7 @@ package holding it. (P

    -inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
    +inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
         return HierarchyLocations::find_in_package(Emit::tree(), id, P, EMPTY_WORDING,
             NULL, -1, NULL);
     }
    @@ -2242,7 +2272,7 @@ available", using the following, which creates a socket. Again, see
     

    -void Hierarchy::make_available(inter_name *iname) {
    +void Hierarchy::make_available(inter_name *iname) {
         text_stream *ma_as = Produce::get_translation(iname);
         if (Str::len(ma_as) == 0) ma_as = InterNames::to_text(iname);
         PackageTypes::get(Emit::tree(), I"_linkage");
    @@ -2341,12 +2371,12 @@ point system, and for those:
         Emit::text_constant(iname, value);
     }
     
    -void Hierarchy::apply_metadata_from_number(package_request *P, int id, inter_ti N) {
    +void Hierarchy::apply_metadata_from_number(package_request *P, int id, inter_ti N) {
         inter_name *iname = Hierarchy::make_iname_in(id, P);
         Emit::numeric_constant(iname, N);
     }
     
    -void Hierarchy::apply_metadata_from_iname(package_request *P, int id, inter_name *val) {
    +void Hierarchy::apply_metadata_from_iname(package_request *P, int id, inter_name *val) {
         inter_name *iname = Hierarchy::make_iname_in(id, P);
         Emit::iname_constant(iname, K_value, val);
     }
    diff --git a/docs/runtime-module/5-ins.html b/docs/runtime-module/5-ins.html
    index 29de6ecc8..3992b6ac6 100644
    --- a/docs/runtime-module/5-ins.html
    +++ b/docs/runtime-module/5-ins.html
    @@ -86,11 +86,28 @@ function togglePopup(material_id) {
         NounIdentifiers::noun_compose_identifier(I->icd.instance_package,
             I->as_noun, I->allocation_id);
         I->icd.instance_iname = NounIdentifiers::iname(I->as_noun);
    -    Hierarchy::apply_metadata_from_wording(I->icd.instance_package, INSTANCE_NAME_METADATA_HL,
    -        Nouns::nominative(I->as_noun, FALSE));
         I->icd.instance_emitted = FALSE;
     }
     
    +void RTInstances::compile_metadata(void) {
    +    instance *I;
    +    LOOP_OVER(I, instance) {
    +        Hierarchy::apply_metadata_from_wording(I->icd.instance_package,
    +            INSTANCE_NAME_METADATA_HL,
    +            Nouns::nominative(I->as_noun, FALSE));
    +        Hierarchy::apply_metadata_from_iname(I->icd.instance_package,
    +            INSTANCE_VALUE_METADATA_HL,
    +            I->icd.instance_iname);
    +        inter_name *kn_iname = Hierarchy::make_iname_in(INSTANCE_KIND_METADATA_HL,
    +            I->icd.instance_package);
    +        kind *K = Instances::to_kind(I);
    +        RTKinds::constant_from_strong_id(kn_iname, K);
    +        if ((K_scene) && (Kinds::eq(K, K_scene)))
    +            Hierarchy::apply_metadata_from_number(I->icd.instance_package,
    +                INSTANCE_IS_SCENE_METADATA_HL, 1);
    +    }
    +}
    +
     inter_name *RTInstances::iname(instance *I) {
         if (I == NULL) return NULL;
         return I->icd.instance_iname;
    @@ -152,7 +169,7 @@ declarations) and finally return     return iname;
     }
     
    -package_request *RTInstances::package(instance *I) {
    +package_request *RTInstances::package(instance *I) {
         RTInstances::iname(I);  Thus forcing this to exist...
         return I->icd.instance_package;
     }
    diff --git a/docs/runtime-module/5-rsfk.html b/docs/runtime-module/5-rsfk.html
    index 0d1dc7807..93ecc8a73 100644
    --- a/docs/runtime-module/5-rsfk.html
    +++ b/docs/runtime-module/5-rsfk.html
    @@ -618,7 +618,7 @@ turns up. This means remembering everything we've seen, using a new structure:
         }
     }
     
    -void RTKinds::constant_from_strong_id(inter_name *iname, kind *K) {
    +void RTKinds::constant_from_strong_id(inter_name *iname, kind *K) {
         runtime_kind_structure *rks = RTKinds::get_rks(K);
         if (rks) {
             Emit::iname_constant(iname, K_value, rks->rks_iname);
    diff --git a/docs/runtime-module/6-scn.html b/docs/runtime-module/6-scn.html
    index b6a4902c7..4a685bfd6 100644
    --- a/docs/runtime-module/6-scn.html
    +++ b/docs/runtime-module/6-scn.html
    @@ -113,89 +113,33 @@ occurs, and (b) act upon it. This is all handled by the following Inter
     function.
     

    -

    There is one argument, chs: the number of iterations so far. Iterations -occur because each set of scene changes could change the circumstances in such -a way that other scene changes are now required (through external conditions, -not through anchors); we don't want this to lock up, so we will cap recursion. -Within the routine, a second local variable, ch, is a flag indicating -whether any change in status has or has not occurred. -

    -

    There is no significance to the return value.

    -
    define MAX_SCENE_CHANGE_ITERATION 20
    -
    -void RTScenes::DetectSceneChange_routine(void) {
    -    inter_name *iname = Hierarchy::find(DETECTSCENECHANGE_HL);
    -    packaging_state save = Functions::begin(iname);
    -    inter_symbol *chs_s =
    -        LocalVariables::new_internal_commented_as_symbol(I"chs", I"count of changes made");
    -    inter_symbol *ch_s =
    -        LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made");
    -    inter_symbol *CScene_l = EmitCode::reserve_label(I".CScene");
    -
    +void RTScenes::compile_change_functions(void) {
         scene *sc;
    -    LOOP_OVER(sc, scene) Compile code detecting the ends of a specific scene2.2;
    -
    -    EmitCode::place_label(CScene_l);
    -    Add the scene-change tail2.1;
    -
    -    Functions::end(save);
    -    Hierarchy::make_available(iname);
    +    LOOP_OVER(sc, scene) {
    +        inter_name *iname =
    +            Hierarchy::make_iname_in(SCENE_CHANGE_FN_HL, RTInstances::package(sc->as_instance));
    +        packaging_state save = Functions::begin(iname);
    +        inter_symbol *ch_s =
    +            LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made");
    +        Compile code detecting the ends of a specific scene2.1;
    +        EmitCode::rfalse();
    +        Functions::end(save);
    +        inter_name *md_iname = Hierarchy::make_iname_in(INSTANCE_SCF_METADATA_HL, RTInstances::package(sc->as_instance));
    +        Emit::iname_constant(md_iname, K_value, iname);
    +    }
     }
     
    -

    §2.1. Add the scene-change tail2.1 = -

    - -
    -    EmitCode::inv(IF_BIP);
    -    EmitCode::down();
    -        EmitCode::inv(GT_BIP);
    -        EmitCode::down();
    -            EmitCode::val_symbol(K_value, chs_s);
    -            EmitCode::val_number((inter_ti) MAX_SCENE_CHANGE_ITERATION);
    -        EmitCode::up();
    -        EmitCode::code();
    -        EmitCode::down();
    -            EmitCode::inv(PRINT_BIP);
    -            EmitCode::down();
    -                EmitCode::val_text(I">--> The scene change machinery is stuck.\n");
    -            EmitCode::up();
    -            EmitCode::rtrue();
    -        EmitCode::up();
    -    EmitCode::up();
    -
    -    EmitCode::inv(IF_BIP);
    -    EmitCode::down();
    -        EmitCode::inv(GT_BIP);
    -        EmitCode::down();
    -            EmitCode::val_symbol(K_value, ch_s);
    -            EmitCode::val_number(0);
    -        EmitCode::up();
    -        EmitCode::code();
    -        EmitCode::down();
    -            EmitCode::call(iname);
    -            EmitCode::down();
    -                EmitCode::inv(PREINCREMENT_BIP);
    -                EmitCode::down();
    -                    EmitCode::ref_symbol(K_value, chs_s);
    -                EmitCode::up();
    -            EmitCode::up();
    -        EmitCode::up();
    -    EmitCode::up();
    -
    -    EmitCode::rfalse();
    -
    -
    • This code is used in §2.
    -

    §2.2. Recall that ends numbered 1, 2, 3, ... are all ways for the scene to end, +

    §2.1. Recall that ends numbered 1, 2, 3, ... are all ways for the scene to end, so they are only checked if its status is currently running; end 0 is the beginning, checked only if it isn't. We give priority to the higher end numbers so that more abstruse ways to end take precedence over less.

    -

    Compile code detecting the ends of a specific scene2.2 = +

    Compile code detecting the ends of a specific scene2.1 =

    @@ -213,7 +157,7 @@ numbers so that more abstruse ways to end take precedence over less.
             EmitCode::code();
             EmitCode::down();
                 for (int end=sc->no_ends-1; end>=1; end--)
    -                RTScenes::test_scene_end(sc, end, ch_s, CScene_l);
    +                RTScenes::test_scene_end(sc, end, ch_s);
             EmitCode::up();
         EmitCode::up();
     
    @@ -230,7 +174,7 @@ numbers so that more abstruse ways to end take precedence over less.
             EmitCode::up();
             EmitCode::code();
             EmitCode::down();
    -            RTScenes::test_scene_end(sc, 0, ch_s, CScene_l);
    +            RTScenes::test_scene_end(sc, 0, ch_s);
             EmitCode::up();
         EmitCode::up();
     
    @@ -243,7 +187,7 @@ below.

    -void RTScenes::test_scene_end(scene *sc, int end, inter_symbol *ch_s, inter_symbol *CScene_l) {
    +void RTScenes::test_scene_end(scene *sc, int end, inter_symbol *ch_s) {
         if ((end == 0) && (sc->start_of_play)) {
             EmitCode::inv(IF_BIP);
             EmitCode::down();
    @@ -316,10 +260,7 @@ instruction because we're not compiling a loop.)
                     EmitCode::val_number(1);
                 EmitCode::up();
                 RTScenes::compile_scene_end(sc, end);
    -            EmitCode::inv(JUMP_BIP);
    -            EmitCode::down();
    -                EmitCode::lab(CScene_l);
    -            EmitCode::up();
    +            EmitCode::rtrue();
             EmitCode::up();
         EmitCode::up();
     
    @@ -589,15 +530,16 @@ what handles this.

    -void RTScenes::ShowSceneStatus_routine(void) {
    -    inter_name *iname = Hierarchy::find(SHOWSCENESTATUS_HL);
    -    packaging_state save = Functions::begin(iname);
    -    EmitCode::inv(IFDEBUG_BIP);
    -    EmitCode::down();
    -        EmitCode::code();
    +void RTScenes::compile_show_status_functions(void) {
    +    scene *sc;
    +    LOOP_OVER(sc, scene) {
    +        inter_name *iname =
    +            Hierarchy::make_iname_in(SCENE_STATUS_FN_HL, RTInstances::package(sc->as_instance));
    +        packaging_state save = Functions::begin(iname);
    +        EmitCode::inv(IFDEBUG_BIP);
             EmitCode::down();
    -            scene *sc;
    -            LOOP_OVER(sc, scene) {
    +            EmitCode::code();
    +            EmitCode::down();
                     wording NW = Instances::get_name(sc->as_instance, FALSE);
     
                     EmitCode::inv(IFELSE_BIP);
    @@ -620,11 +562,12 @@ what handles this.
                             Show status of this non-running scene6.2;
                         EmitCode::up();
                     EmitCode::up();
    -            }
    +            EmitCode::up();
             EmitCode::up();
    -    EmitCode::up();
    -    Functions::end(save);
    -    Hierarchy::make_available(iname);
    +        Functions::end(save);
    +        inter_name *md_iname = Hierarchy::make_iname_in(INSTANCE_SSF_METADATA_HL, RTInstances::package(sc->as_instance));
    +        Emit::iname_constant(md_iname, K_value, iname);
    +    }
     }
     

    §6.1. Show status of this running scene6.1 = @@ -780,6 +723,44 @@ actually running: } }

    +

    §8.

    + +
    +void RTScenes::compile_synoptic_resources(void) {
    +    Provide placeholder for the SHOWSCENESTATUS function8.1;
    +    Provide placeholder for the DETECTSCENECHANGE function8.2;
    +}
    +
    +

    §8.1. Provide placeholder for the SHOWSCENESTATUS function8.1 = +

    + +
    +    inter_name *iname = Hierarchy::find(SHOWSCENESTATUS_HL);
    +    Produce::annotate_i(iname, SYNOPTIC_IANN, SHOWSCENESTATUS_SYNID);
    +    packaging_state save = Functions::begin(iname);
    +    EmitCode::comment(I"This function is consolidated");
    +    Functions::end(save);
    +    Hierarchy::make_available(iname);
    +
    +
    • This code is used in §8.
    +

    §8.2. Provide placeholder for the DETECTSCENECHANGE function8.2 = +

    + +
    +    inter_name *iname = Hierarchy::find(DETECTSCENECHANGE_HL);
    +    Produce::annotate_i(iname, SYNOPTIC_IANN, DETECTSCENECHANGE_SYNID);
    +    packaging_state save = Functions::begin(iname);
    +    LocalVariables::new_internal_commented_as_symbol(I"chs", I"count of changes made");
    +    inter_symbol *ch_s =
    +        LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made");
    +    inter_symbol *myself_s = InterSymbolsTables::create_with_unique_name(ch_s->owning_table, I"myself");
    +    InterSymbolsTables::equate(myself_s, InterNames::to_symbol(iname));
    +
    +    EmitCode::comment(I"This function is consolidated");
    +    Functions::end(save);
    +    Hierarchy::make_available(iname);
    +
    +
    • This code is used in §8.
    diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index aa4be76b2..766cfd4ed 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,12 +1,12 @@ -Total memory consumption was 296195K = 289 MB +Total memory consumption was 298905K = 292 MB -63.7% was used for 1463905 objects, in 316039 frames in 236 x 800K = 188800K = 184 MB: +63.9% was used for 1469154 objects, in 316296 frames in 239 x 800K = 191200K = 186 MB: - 9.5% inter_tree_node_array 40 x 8192 = 327680 objects, 28837120 bytes - 5.9% text_stream_array 3229 x 100 = 322900 objects, 18185728 bytes - 5.3% linked_list 29077 objects, 16283120 bytes - 3.4% parse_node 129367 objects, 10349360 bytes - 2.7% inter_symbol_array 84 x 1024 = 86016 objects, 8260224 bytes + 9.4% inter_tree_node_array 40 x 8192 = 327680 objects, 28837120 bytes + 5.9% text_stream_array 3258 x 100 = 325800 objects, 18349056 bytes + 5.3% linked_list 29092 objects, 16291520 bytes + 3.3% parse_node 129367 objects, 10349360 bytes + 2.7% inter_symbol_array 85 x 1024 = 87040 objects, 8358560 bytes 2.4% verb_conjugation 160 objects, 7425280 bytes 1.8% parse_node_annotation_array 345 x 500 = 172500 objects, 5531040 bytes 1.0% pcalc_prop_array 24 x 1000 = 24000 objects, 3264768 bytes @@ -14,22 +14,22 @@ Total memory consumption was 296195K = 289 MB 0.8% kind_array 66 x 1000 = 66000 objects, 2642112 bytes 0.6% inter_schema_token 13459 objects, 1938096 bytes 0.5% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes - 0.4% inter_name_array 29 x 1000 = 29000 objects, 1392928 bytes + 0.4% inter_name_array 30 x 1000 = 30000 objects, 1440960 bytes 0.4% match_trie_array 10 x 1000 = 10000 objects, 1360320 bytes 0.4% i6_schema_array 21 x 100 = 2100 objects, 1260672 bytes 0.3% id_body 940 objects, 1075360 bytes - 0.3% inter_package 14893 objects, 1072296 bytes + 0.3% inter_package 14899 objects, 1072728 bytes 0.3% adjective_meaning 202 objects, 1000304 bytes 0.3% excerpt_meaning 3098 objects, 966576 bytes 0.3% inter_name_generator_array 24 x 1000 = 24000 objects, 960768 bytes - 0.3% inter_symbols_table 14893 objects, 953152 bytes - 0.3% dictionary 19366 objects, 929568 bytes + 0.3% inter_symbols_table 14899 objects, 953536 bytes + 0.3% dictionary 19542 objects, 938016 bytes 0.2% production 3885 objects, 901320 bytes - 0.2% dict_entry_array 272 x 100 = 27200 objects, 879104 bytes + 0.2% dict_entry_array 273 x 100 = 27300 objects, 882336 bytes 0.2% ptoken 8390 objects, 872560 bytes 0.2% grammatical_usage 3610 objects, 866400 bytes 0.2% individual_form 2560 objects, 860160 bytes - 0.2% package_request 9536 objects, 839168 bytes + 0.2% package_request 9540 objects, 839520 bytes 0.2% inter_schema_node 8663 objects, 831648 bytes 0.2% unary_predicate_array 16 x 1000 = 16000 objects, 640512 bytes 0.1% local_variable_array 46 x 100 = 4600 objects, 443072 bytes @@ -47,14 +47,14 @@ Total memory consumption was 296195K = 289 MB ---- nonterminal 759 objects, 139656 bytes ---- compilation_subtask 1664 objects, 133120 bytes ---- nascent_array 1969 objects, 126016 bytes - ---- hierarchy_location 805 objects, 115920 bytes + ---- hierarchy_location 812 objects, 116928 bytes ---- documentation_ref 1274 objects, 112112 bytes ---- inference 1703 objects, 108992 bytes ---- imperative_defn 1376 objects, 99072 bytes ---- anl_entry_array 2 x 1000 = 2000 objects, 96064 bytes ---- noun_usage 2401 objects, 96040 bytes ---- preposition 273 objects, 87360 bytes - ---- inter_tree 6 objects, 82128 bytes + ---- inter_tree 6 objects, 82464 bytes ---- lexical_cluster 2516 objects, 80512 bytes ---- pcalc_term_array 2 x 1000 = 2000 objects, 80064 bytes ---- kind_variable_declaration 1652 objects, 79296 bytes @@ -110,11 +110,11 @@ Total memory consumption was 296195K = 289 MB ---- booking_list 407 objects, 13024 bytes ---- adjective_iname_holder 320 objects, 12800 bytes ---- pathname 292 objects, 11680 bytes - ---- stopwatch_timer 138 objects, 11040 bytes + ---- stopwatch_timer 140 objects, 11200 bytes ---- filename 208 objects, 8320 bytes ---- equation_node 68 objects, 7616 bytes + ---- uniqueness_count 306 objects, 7344 bytes ---- understanding_item_array 3 x 100 = 300 objects, 7296 bytes - ---- uniqueness_count 302 objects, 7248 bytes ---- shared_variable_array 1 x 100 objects, 7232 bytes ---- determiner 22 objects, 7216 bytes ---- verb 108 objects, 6048 bytes @@ -141,7 +141,7 @@ Total memory consumption was 296195K = 289 MB ---- inform_extension 19 objects, 3040 bytes ---- either_or_property_data 62 objects, 2976 bytes ---- property_of_value_storage 93 objects, 2976 bytes - ---- submodule_request 71 objects, 2840 bytes + ---- submodule_request 73 objects, 2920 bytes ---- part_of_inference_data 79 objects, 2528 bytes ---- parentage_inference_data 79 objects, 2528 bytes ---- kind_constructor_casting_rule_array 1 x 100 objects, 2432 bytes @@ -176,24 +176,24 @@ Total memory consumption was 296195K = 289 MB ---- target_vm 6 objects, 816 bytes ---- generated_segment 25 objects, 800 bytes ---- inter_data_type 14 objects, 784 bytes - ---- submodule_identity 23 objects, 736 bytes + ---- submodule_identity 24 objects, 768 bytes ---- inform_language 6 objects, 672 bytes - ---- relation_guard 5 objects, 640 bytes ---- inter_warehouse_room 10 objects, 640 bytes + ---- relation_guard 5 objects, 640 bytes + ---- inter_tree_location_list 16 objects, 640 bytes ---- I6T_intervention 8 objects, 640 bytes ---- named_rulebook_outcome 15 objects, 600 bytes ---- inbuild_search_result 15 objects, 600 bytes - ---- inter_tree_location_list 14 objects, 560 bytes ---- rulebook_outcome 17 objects, 544 bytes ---- small_word_set 11 objects, 528 bytes - ---- inform_kit 5 objects, 520 bytes ---- implication 13 objects, 520 bytes + ---- inform_kit 5 objects, 520 bytes ---- inference_family 11 objects, 440 bytes - ---- i6_memory_setting 13 objects, 416 bytes ---- equation 4 objects, 416 bytes + ---- i6_memory_setting 13 objects, 416 bytes ---- dval_written 10 objects, 400 bytes - ---- bp_family 12 objects, 384 bytes ---- article_usage 8 objects, 384 bytes + ---- bp_family 12 objects, 384 bytes ---- source_file 5 objects, 360 bytes ---- module_package 9 objects, 360 bytes ---- inbuild_genre 7 objects, 336 bytes @@ -237,24 +237,24 @@ Total memory consumption was 296195K = 289 MB ---- kind_template_definition 1 object, 40 bytes ---- parse_name_notice 1 object, 40 bytes -36.2% was used for memory not allocated for objects: +36.0% was used for memory not allocated for objects: - 16.7% text stream storage 50819960 bytes in 333795 claims - 3.5% dictionary storage 10831872 bytes in 19366 claims - ---- sorting 952 bytes in 3 claims + 16.6% text stream storage 51038332 bytes in 336609 claims + 3.5% dictionary storage 10921984 bytes in 19542 claims + ---- sorting 968 bytes in 3 claims 2.3% source text 7200000 bytes in 3 claims 3.5% source text details 10800000 bytes in 2 claims ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims - 0.8% inter symbols storage 2567488 bytes in 15716 claims - 5.5% inter bytecode storage 16802776 bytes in 14 claims + 0.8% inter symbols storage 2568752 bytes in 15723 claims + 5.4% inter bytecode storage 16802776 bytes in 14 claims 2.8% inter links storage 8750208 bytes in 246 claims - ---- inter tree location list storage 113920 bytes in 16 claims + ---- inter tree location list storage 122112 bytes in 18 claims 0.5% instance-of-kind counting 1695204 bytes in 1 claim ---- compilation workspace for objects 21856 bytes in 25 claims ---- lists for type-checking invocations 16000 bytes in 1 claim ---- emitter array storage 155664 bytes in 2042 claims ---- code generation workspace for objects 9192 bytes in 9 claims -20.1% was overhead - 61158504 bytes = 59725K = 58 MB +20.6% was overhead - 63283368 bytes = 61800K = 60 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index e280a0cf2..b107135fa 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,37 +1,38 @@ 100.0% in inform7 run 53.3% in compilation to Inter - 31.9% in //Sequence::undertake_queued_tasks// - 5.3% in //InferenceSubjects::emit_all// - 3.4% in //MajorNodes::pre_pass// + 32.2% in //Sequence::undertake_queued_tasks// + 5.5% in //InferenceSubjects::emit_all// + 3.3% in //MajorNodes::pre_pass// 3.0% in //MajorNodes::pass_1// - 1.7% in //ImperativeDefinitions::compile_first_block// - 1.4% in //ImperativeDefinitions::assess_all// + 1.5% in //ImperativeDefinitions::assess_all// + 1.5% in //ImperativeDefinitions::compile_first_block// 0.9% in //RTVerbs::ConjugateVerb// 0.6% in //RTRules::compile_rulebooks// - 0.4% in //MajorNodes::pass_2// - 0.4% in //World::stage_V// + 0.3% in //MajorNodes::pass_2// + 0.3% in //World::stage_V// 0.1% in //RTActions::compile_functions// 0.1% in //RTCommandGrammars::compile_all// 0.1% in //RTKinds::compile_data_type_support_routines// 0.1% in //RTRelations::compile_defined_relations// 0.1% in //RTRules::compile_metadata// + 0.1% in //RTTables::compile// 0.1% in //Task::make_built_in_kind_constructors// 0.1% in //World::stages_II_and_III// - 2.7% not specifically accounted for - 44.4% in running Inter pipeline - 14.3% in inter step 10/14: consolidate-text - 10.4% in step preparation - 8.7% in inter step 2/14: link - 6.3% in inter step 14/14: generate inform6 -> auto.inf + 2.6% not specifically accounted for + 44.7% in running Inter pipeline + 14.2% in inter step 10/14: consolidate-text + 10.7% in step preparation + 8.5% in inter step 2/14: link + 6.7% in inter step 14/14: generate inform6 -> auto.inf 0.6% in inter step 9/14: make-identifiers-unique + 0.3% in inter step 11/14: reconcile-verbs 0.3% in inter step 13/14: eliminate-redundant-operations - 0.1% in inter step 11/14: reconcile-verbs + 0.3% in inter step 6/14: assimilate 0.1% in inter step 12/14: eliminate-redundant-labels 0.1% in inter step 4/14: parse-linked-matter 0.1% in inter step 5/14: resolve-conditional-compilation - 0.1% in inter step 6/14: assimilate 0.1% in inter step 7/14: resolve-external-symbols 0.1% in inter step 8/14: inspect-plugs - 2.5% not specifically accounted for - 1.8% in supervisor - 0.4% not specifically accounted for + 2.1% not specifically accounted for + 1.7% in supervisor + 0.2% not specifically accounted for diff --git a/inform7/core-module/Chapter 1/How To Compile.w b/inform7/core-module/Chapter 1/How To Compile.w index 977da3a2d..bf84fa512 100644 --- a/inform7/core-module/Chapter 1/How To Compile.w +++ b/inform7/core-module/Chapter 1/How To Compile.w @@ -207,6 +207,7 @@ so on. Those absolute basics are made here. BENCH(RTRules::rulebook_var_creators) BENCH(RTRules::compile_rulebooks) BENCH(RTRules::compile_metadata) + BENCH(RTInstances::compile_metadata) BENCH(RTProperties::compile_metadata) BENCH(RTActivities::activity_var_creators) BENCH(RTVerbs::ConjugateVerb) diff --git a/inform7/if-module/Chapter 3/Scenes.w b/inform7/if-module/Chapter 3/Scenes.w index 44accc9cf..ea159f669 100644 --- a/inform7/if-module/Chapter 3/Scenes.w +++ b/inform7/if-module/Chapter 3/Scenes.w @@ -24,8 +24,11 @@ void Scenes::start(void) { int Scenes::production_line(int stage, int debugging, stopwatch_timer *sequence_timer) { if (stage == INTER1_CSEQ) { - BENCH(RTScenes::DetectSceneChange_routine); - BENCH(RTScenes::ShowSceneStatus_routine); + BENCH(RTScenes::compile_change_functions); + BENCH(RTScenes::compile_show_status_functions); + } + if (stage == INTER3_CSEQ) { + BENCH(RTScenes::compile_synoptic_resources); } return FALSE; } diff --git a/inform7/runtime-module/Chapter 2/Hierarchy.w b/inform7/runtime-module/Chapter 2/Hierarchy.w index 401639cf1..7b61ca773 100644 --- a/inform7/runtime-module/Chapter 2/Hierarchy.w +++ b/inform7/runtime-module/Chapter 2/Hierarchy.w @@ -191,6 +191,7 @@ void Hierarchy::establish(void) { @; @; @; + @; @; @; @; @@ -245,11 +246,11 @@ void Hierarchy::establish(void) { H_C_T(KIT_CONFIGURATION_BITMAP_HL, I"KIT_CONFIGURATION_BITMAP") H_C_T(KIT_CONFIGURATION_LOOKMODE_HL, I"KIT_CONFIGURATION_LOOKMODE") H_C_T(LOCALPARKING_HL, I"LocalParking") + H_C_T(RNG_SEED_AT_START_OF_PLAY_HL, I"RNG_SEED_AT_START_OF_PLAY") H_END H_BEGIN(HierarchyLocations::synoptic_submodule(I, basics)) H_C_T(MAX_FRAME_SIZE_NEEDED_HL, I"MAX_FRAME_SIZE_NEEDED") - H_C_T(RNG_SEED_AT_START_OF_PLAY_HL, I"RNG_SEED_AT_START_OF_PLAY") H_END submodule_identity *basic_extras = Packaging::register_submodule(I"BasicInformExtrasKit"); @@ -704,7 +705,14 @@ void Hierarchy::establish(void) { @e INSTANCES_HAP @e INSTANCE_NAME_METADATA_HL +@e INSTANCE_VALUE_METADATA_HL +@e INSTANCE_KIND_METADATA_HL +@e INSTANCE_IS_SCENE_METADATA_HL +@e INSTANCE_SSF_METADATA_HL +@e INSTANCE_SCF_METADATA_HL @e INSTANCE_HL +@e SCENE_STATUS_FN_HL +@e SCENE_CHANGE_FN_HL @e BACKDROP_FOUND_IN_FN_HL @e REGION_FOUND_IN_FN_HL @e SHORT_NAME_FN_HL @@ -720,7 +728,14 @@ void Hierarchy::establish(void) { H_BEGIN(HierarchyLocations::local_submodule(instances)) H_BEGIN_AP(INSTANCES_HAP, I"instance", I"_instance") H_C_U(INSTANCE_NAME_METADATA_HL, I"^name") + H_C_U(INSTANCE_VALUE_METADATA_HL, I"^value") + H_C_U(INSTANCE_KIND_METADATA_HL, I"^kind") + H_C_U(INSTANCE_IS_SCENE_METADATA_HL, I"^is_scene") + H_C_U(INSTANCE_SSF_METADATA_HL, I"^scene_status_fn") + H_C_U(INSTANCE_SCF_METADATA_HL, I"^scene_change_fn") H_C_U(INSTANCE_HL, I"I") + H_F_U(SCENE_STATUS_FN_HL, I"scene_status_fn") + H_F_U(SCENE_CHANGE_FN_HL, I"scene_change_fn") H_F_U(BACKDROP_FOUND_IN_FN_HL, I"backdrop_found_in_fn") H_F_G(SHORT_NAME_FN_HL, I"short_name_fn", I"SN_R") H_F_G(SHORT_NAME_PROPERTY_FN_HL, I"short_name_property_fn", I"SN_R_A") @@ -737,8 +752,6 @@ void Hierarchy::establish(void) { @e INITIAL_MAX_SCORE_HL @e NO_DIRECTIONS_HL -@e SHOWSCENESTATUS_HL -@e DETECTSCENECHANGE_HL @e MAP_STORAGE_HL @e INITIALSITUATION_HL @e PLAYER_OBJECT_INIS_HL @@ -752,18 +765,19 @@ void Hierarchy::establish(void) { @ = submodule_identity *interactive_fiction = Packaging::register_submodule(I"interactive_fiction"); - H_BEGIN(HierarchyLocations::synoptic_submodule(I, interactive_fiction)) - H_C_T(INITIAL_MAX_SCORE_HL, I"INITIAL_MAX_SCORE") - H_C_T(NO_DIRECTIONS_HL, I"No_Directions") - H_F_T(SHOWSCENESTATUS_HL, I"show_scene_status_fn", I"ShowSceneStatus") - H_F_T(DETECTSCENECHANGE_HL, I"detect_scene_change_fn", I"DetectSceneChange") - H_C_T(MAP_STORAGE_HL, I"Map_Storage") - H_C_T(INITIALSITUATION_HL, I"InitialSituation") + H_BEGIN(HierarchyLocations::generic_submodule(I, interactive_fiction)) H_C_T(PLAYER_OBJECT_INIS_HL, I"PLAYER_OBJECT_INIS") H_C_T(START_OBJECT_INIS_HL, I"START_OBJECT_INIS") H_C_T(START_ROOM_INIS_HL, I"START_ROOM_INIS") H_C_T(START_TIME_INIS_HL, I"START_TIME_INIS") H_C_T(DONE_INIS_HL, I"DONE_INIS") + H_END + + H_BEGIN(HierarchyLocations::synoptic_submodule(I, interactive_fiction)) + H_C_T(INITIAL_MAX_SCORE_HL, I"INITIAL_MAX_SCORE") + H_C_T(NO_DIRECTIONS_HL, I"No_Directions") + H_C_T(MAP_STORAGE_HL, I"Map_Storage") + H_C_T(INITIALSITUATION_HL, I"InitialSituation") H_BEGIN_AP(DIRECTIONS_HAP, I"direction", I"_direction") H_C_G(DIRECTION_HL, I"DirectionObject") H_END @@ -1157,6 +1171,18 @@ void Hierarchy::establish(void) { H_F_T(RULEPRINTINGRULE_HL, I"print_fn", I"RulePrintingRule") H_END +@h Scenes. + +@e SHOWSCENESTATUS_HL +@e DETECTSCENECHANGE_HL + +@ = + submodule_identity *scenes = Packaging::register_submodule(I"scenes"); + H_BEGIN(HierarchyLocations::synoptic_submodule(I, scenes)) + H_F_T(SHOWSCENESTATUS_HL, I"show_scene_status_fn", I"ShowSceneStatus") + H_F_T(DETECTSCENECHANGE_HL, I"detect_scene_change_fn", I"DetectSceneChange") + H_END + @h Tables. @e TABLES_HAP diff --git a/inform7/runtime-module/Chapter 5/Instances.w b/inform7/runtime-module/Chapter 5/Instances.w index 993a6864c..123b93da7 100644 --- a/inform7/runtime-module/Chapter 5/Instances.w +++ b/inform7/runtime-module/Chapter 5/Instances.w @@ -16,11 +16,28 @@ void RTInstances::initialise_icd(instance *I) { NounIdentifiers::noun_compose_identifier(I->icd.instance_package, I->as_noun, I->allocation_id); I->icd.instance_iname = NounIdentifiers::iname(I->as_noun); - Hierarchy::apply_metadata_from_wording(I->icd.instance_package, INSTANCE_NAME_METADATA_HL, - Nouns::nominative(I->as_noun, FALSE)); I->icd.instance_emitted = FALSE; } +void RTInstances::compile_metadata(void) { + instance *I; + LOOP_OVER(I, instance) { + Hierarchy::apply_metadata_from_wording(I->icd.instance_package, + INSTANCE_NAME_METADATA_HL, + Nouns::nominative(I->as_noun, FALSE)); + Hierarchy::apply_metadata_from_iname(I->icd.instance_package, + INSTANCE_VALUE_METADATA_HL, + I->icd.instance_iname); + inter_name *kn_iname = Hierarchy::make_iname_in(INSTANCE_KIND_METADATA_HL, + I->icd.instance_package); + kind *K = Instances::to_kind(I); + RTKinds::constant_from_strong_id(kn_iname, K); + if ((K_scene) && (Kinds::eq(K, K_scene))) + Hierarchy::apply_metadata_from_number(I->icd.instance_package, + INSTANCE_IS_SCENE_METADATA_HL, 1); + } +} + inter_name *RTInstances::iname(instance *I) { if (I == NULL) return NULL; return I->icd.instance_iname; diff --git a/inform7/runtime-module/Chapter 6/Scenes.w b/inform7/runtime-module/Chapter 6/Scenes.w index 6b28661d8..7bbe90c83 100644 --- a/inform7/runtime-module/Chapter 6/Scenes.w +++ b/inform7/runtime-module/Chapter 6/Scenes.w @@ -34,76 +34,25 @@ The following generates the necessary code to (a) detect when a scene end occurs, and (b) act upon it. This is all handled by the following Inter function. -There is one argument, |chs|: the number of iterations so far. Iterations -occur because each set of scene changes could change the circumstances in such -a way that other scene changes are now required (through external conditions, -not through anchors); we don't want this to lock up, so we will cap recursion. -Within the routine, a second local variable, |ch|, is a flag indicating -whether any change in status has or has not occurred. - There is no significance to the return value. -@d MAX_SCENE_CHANGE_ITERATION 20 - = -void RTScenes::DetectSceneChange_routine(void) { - inter_name *iname = Hierarchy::find(DETECTSCENECHANGE_HL); - packaging_state save = Functions::begin(iname); - inter_symbol *chs_s = - LocalVariables::new_internal_commented_as_symbol(I"chs", I"count of changes made"); - inter_symbol *ch_s = - LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made"); - inter_symbol *CScene_l = EmitCode::reserve_label(I".CScene"); - +void RTScenes::compile_change_functions(void) { scene *sc; - LOOP_OVER(sc, scene) @; - - EmitCode::place_label(CScene_l); - @; - - Functions::end(save); - Hierarchy::make_available(iname); + LOOP_OVER(sc, scene) { + inter_name *iname = + Hierarchy::make_iname_in(SCENE_CHANGE_FN_HL, RTInstances::package(sc->as_instance)); + packaging_state save = Functions::begin(iname); + inter_symbol *ch_s = + LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made"); + @; + EmitCode::rfalse(); + Functions::end(save); + inter_name *md_iname = Hierarchy::make_iname_in(INSTANCE_SCF_METADATA_HL, RTInstances::package(sc->as_instance)); + Emit::iname_constant(md_iname, K_value, iname); + } } -@ = - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(GT_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, chs_s); - EmitCode::val_number((inter_ti) MAX_SCENE_CHANGE_ITERATION); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::inv(PRINT_BIP); - EmitCode::down(); - EmitCode::val_text(I">--> The scene change machinery is stuck.\n"); - EmitCode::up(); - EmitCode::rtrue(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(GT_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, ch_s); - EmitCode::val_number(0); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::call(iname); - EmitCode::down(); - EmitCode::inv(PREINCREMENT_BIP); - EmitCode::down(); - EmitCode::ref_symbol(K_value, chs_s); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::rfalse(); - @ Recall that ends numbered 1, 2, 3, ... are all ways for the scene to end, so they are only checked if its status is currently running; end 0 is the beginning, checked only if it isn't. We give priority to the higher end @@ -124,7 +73,7 @@ numbers so that more abstruse ways to end take precedence over less. EmitCode::code(); EmitCode::down(); for (int end=sc->no_ends-1; end>=1; end--) - RTScenes::test_scene_end(sc, end, ch_s, CScene_l); + RTScenes::test_scene_end(sc, end, ch_s); EmitCode::up(); EmitCode::up(); @@ -141,7 +90,7 @@ numbers so that more abstruse ways to end take precedence over less. EmitCode::up(); EmitCode::code(); EmitCode::down(); - RTScenes::test_scene_end(sc, 0, ch_s, CScene_l); + RTScenes::test_scene_end(sc, 0, ch_s); EmitCode::up(); EmitCode::up(); @@ -152,7 +101,7 @@ two, because the third way will be taken care of by the consequences code below. = -void RTScenes::test_scene_end(scene *sc, int end, inter_symbol *ch_s, inter_symbol *CScene_l) { +void RTScenes::test_scene_end(scene *sc, int end, inter_symbol *ch_s) { if ((end == 0) && (sc->start_of_play)) { EmitCode::inv(IF_BIP); EmitCode::down(); @@ -217,10 +166,7 @@ instruction because we're not compiling a loop.) EmitCode::val_number(1); EmitCode::up(); RTScenes::compile_scene_end(sc, end); - EmitCode::inv(JUMP_BIP); - EmitCode::down(); - EmitCode::lab(CScene_l); - EmitCode::up(); + EmitCode::rtrue(); EmitCode::up(); EmitCode::up(); @@ -461,15 +407,16 @@ scene status at the moment the command is typed, and the following code is what handles this. = -void RTScenes::ShowSceneStatus_routine(void) { - inter_name *iname = Hierarchy::find(SHOWSCENESTATUS_HL); - packaging_state save = Functions::begin(iname); - EmitCode::inv(IFDEBUG_BIP); - EmitCode::down(); - EmitCode::code(); +void RTScenes::compile_show_status_functions(void) { + scene *sc; + LOOP_OVER(sc, scene) { + inter_name *iname = + Hierarchy::make_iname_in(SCENE_STATUS_FN_HL, RTInstances::package(sc->as_instance)); + packaging_state save = Functions::begin(iname); + EmitCode::inv(IFDEBUG_BIP); EmitCode::down(); - scene *sc; - LOOP_OVER(sc, scene) { + EmitCode::code(); + EmitCode::down(); wording NW = Instances::get_name(sc->as_instance, FALSE); EmitCode::inv(IFELSE_BIP); @@ -492,11 +439,12 @@ void RTScenes::ShowSceneStatus_routine(void) { @; EmitCode::up(); EmitCode::up(); - } + EmitCode::up(); EmitCode::up(); - EmitCode::up(); - Functions::end(save); - Hierarchy::make_available(iname); + Functions::end(save); + inter_name *md_iname = Hierarchy::make_iname_in(INSTANCE_SSF_METADATA_HL, RTInstances::package(sc->as_instance)); + Emit::iname_constant(md_iname, K_value, iname); + } } @ = @@ -638,3 +586,33 @@ void RTScenes::emit_during_clause(parse_node *spec) { return; } } + +@ + += +void RTScenes::compile_synoptic_resources(void) { + @; + @; +} + +@ = + inter_name *iname = Hierarchy::find(SHOWSCENESTATUS_HL); + Produce::annotate_i(iname, SYNOPTIC_IANN, SHOWSCENESTATUS_SYNID); + packaging_state save = Functions::begin(iname); + EmitCode::comment(I"This function is consolidated"); + Functions::end(save); + Hierarchy::make_available(iname); + +@ = + inter_name *iname = Hierarchy::find(DETECTSCENECHANGE_HL); + Produce::annotate_i(iname, SYNOPTIC_IANN, DETECTSCENECHANGE_SYNID); + packaging_state save = Functions::begin(iname); + LocalVariables::new_internal_commented_as_symbol(I"chs", I"count of changes made"); + inter_symbol *ch_s = + LocalVariables::new_internal_commented_as_symbol(I"ch", I"flag: change made"); + inter_symbol *myself_s = InterSymbolsTables::create_with_unique_name(ch_s->owning_table, I"myself"); + InterSymbolsTables::equate(myself_s, InterNames::to_symbol(iname)); + + EmitCode::comment(I"This function is consolidated"); + Functions::end(save); + Hierarchy::make_available(iname); diff --git a/inter/codegen-module/Chapter 3/Instances.w b/inter/codegen-module/Chapter 3/Instances.w new file mode 100644 index 000000000..2441577e7 --- /dev/null +++ b/inter/codegen-module/Chapter 3/Instances.w @@ -0,0 +1,20 @@ +[SynopticInstances::] Instances. + +To renumber the instances and construct suitable functions and arrays. + +@ Before this runs, instance packages are scattered all over the Inter tree. + +As this is called, //Synoptic Utilities// has already formed a list |instance_nodes| +of packages of type |_instance|. + += +void SynopticInstances::renumber(inter_tree *I, inter_tree_location_list *instance_nodes) { + if (TreeLists::len(instance_nodes) > 0) { + TreeLists::sort(instance_nodes, Synoptic::module_order); +// for (int i=0; ilist[i].node); +// inter_tree_node *D = Synoptic::get_definition(pack, I"scene_id"); +// D->W.data[DATA_CONST_IFLD+1] = (inter_ti) i; +// } + } +} diff --git a/inter/codegen-module/Chapter 3/Scenes.w b/inter/codegen-module/Chapter 3/Scenes.w new file mode 100644 index 000000000..ed4a6c36b --- /dev/null +++ b/inter/codegen-module/Chapter 3/Scenes.w @@ -0,0 +1,123 @@ +[SynopticScenes::] Scenes. + +To renumber the scenes and construct suitable functions and arrays. + +@ Before this runs, property packages are scattered all over the Inter tree. +We must allocate each one a unique ID. + +As this is called, //Synoptic Utilities// has already formed a list |property_nodes| +of packages of type |_activity|. + += +void SynopticScenes::renumber(inter_tree *I, inter_tree_location_list *scene_nodes) { + if (TreeLists::len(scene_nodes) > 0) { + TreeLists::sort(scene_nodes, Synoptic::module_order); + for (int i=0; ilist[i].node); + text_stream *name = Metadata::read_optional_textual(pack, I"^name"); + LOG("scene %d: %S\n", i, name); + } + } +} + +@ There are also resources to create in the |synoptic| module: + +@e SHOWSCENESTATUS_SYNID +@e DETECTSCENECHANGE_SYNID + += +int SynopticScenes::redefine(inter_tree *I, inter_tree_node *P, inter_symbol *con_s, int synid) { + inter_package *pack = Inter::Packages::container(P); + inter_bookmark IBM = Inter::Bookmarks::at_end_of_this_package(pack); + switch (synid) { + case SHOWSCENESTATUS_SYNID: { + packaging_state save = Synoptic::begin_redefining_function(&IBM, I, P); + @; + Synoptic::end_redefining_function(I, save); + break; + } + case DETECTSCENECHANGE_SYNID: { + packaging_state save = Synoptic::begin_redefining_function(&IBM, I, P); + @; + Synoptic::end_redefining_function(I, save); + break; + } + default: return FALSE; + } + return TRUE; +} + +@ = + for (int i=0; ilist[i].node); + inter_symbol *ssf_s = Metadata::read_symbol(pack, I"^scene_status_fn"); + Produce::inv_call(I, ssf_s); + } + +@ There is one argument, |chs|: the number of iterations so far. Iterations +occur because each set of scene changes could change the circumstances in such +a way that other scene changes are now required (through external conditions, +not through anchors); we don't want this to lock up, so we will cap recursion. +Within the routine, a second local variable, |ch|, is a flag indicating +whether any change in status has or has not occurred. + + +@d MAX_SCENE_CHANGE_ITERATION 20 + +@ = + inter_symbol *chs_s = Synoptic::get_local(I, I"chs"); + inter_symbol *myself_s = Synoptic::get_local(I, I"myself"); + inter_symbol *Again_l = Produce::reserve_label(I, I".Again"); + inter_symbol *CScene_l = Produce::reserve_label(I, I".CScene"); + Produce::place_label(I, Again_l); + for (int i=0; ilist[i].node); + inter_symbol *scf_s = Metadata::read_symbol(pack, I"^scene_change_fn"); + Produce::inv_primitive(I, IF_BIP); + Produce::down(I); + Produce::inv_call(I, scf_s); + Produce::code(I); + Produce::down(I); + Produce::inv_primitive(I, JUMP_BIP); + Produce::down(I); + Produce::lab(I, CScene_l); + Produce::up(I); + Produce::up(I); + Produce::up(I); + } + Produce::rfalse(I); + + Produce::place_label(I, CScene_l); + + Produce::inv_primitive(I, IF_BIP); + Produce::down(I); + Produce::inv_primitive(I, GT_BIP); + Produce::down(I); + Produce::val_symbol(I, K_value, chs_s); + Produce::val(I, K_value, LITERAL_IVAL, (inter_ti) MAX_SCENE_CHANGE_ITERATION); + Produce::up(I); + Produce::code(I); + Produce::down(I); + Produce::inv_primitive(I, PRINT_BIP); + Produce::down(I); + Produce::val_text(I, I">--> The scene change machinery is stuck.\n"); + Produce::up(I); + Produce::rtrue(I); + Produce::up(I); + Produce::up(I); + Produce::inv_primitive(I, PREINCREMENT_BIP); + Produce::down(I); + Produce::ref_symbol(I, K_value, chs_s); + Produce::up(I); +// Produce::inv_call(I, myself_s); +// Produce::down(I); +// Produce::inv_primitive(I, PREINCREMENT_BIP); +// Produce::down(I); +// Produce::ref_symbol(I, K_value, chs_s); +// Produce::up(I); +// Produce::up(I); +// Produce::rtrue(I); + Produce::inv_primitive(I, JUMP_BIP); + Produce::down(I); + Produce::lab(I, Again_l); + Produce::up(I); diff --git a/inter/codegen-module/Chapter 3/Synoptic Utilities.w b/inter/codegen-module/Chapter 3/Synoptic Utilities.w index 85bc786ac..59545a91a 100644 --- a/inter/codegen-module/Chapter 3/Synoptic Utilities.w +++ b/inter/codegen-module/Chapter 3/Synoptic Utilities.w @@ -26,6 +26,8 @@ inter_tree_location_list *table_column_nodes = NULL; inter_tree_location_list *table_column_usage_nodes = NULL; inter_tree_location_list *past_tense_action_nodes = NULL; inter_tree_location_list *past_tense_condition_nodes = NULL; +inter_tree_location_list *instance_nodes = NULL; +inter_tree_location_list *scene_nodes = NULL; int Synoptic::go(pipeline_step *step) { text_nodes = TreeLists::new(); @@ -42,6 +44,8 @@ int Synoptic::go(pipeline_step *step) { table_column_usage_nodes = TreeLists::new(); past_tense_action_nodes = TreeLists::new(); past_tense_condition_nodes = TreeLists::new(); + instance_nodes = TreeLists::new(); + scene_nodes = TreeLists::new(); InterTree::traverse(step->repository, Synoptic::visitor, NULL, NULL, 0); SynopticText::alphabetise(step->repository, text_nodes); @@ -55,6 +59,8 @@ int Synoptic::go(pipeline_step *step) { SynopticRelations::renumber(step->repository, relation_nodes); SynopticTables::renumber(step->repository, table_nodes); SynopticChronology::renumber(step->repository, past_tense_action_nodes); + SynopticInstances::renumber(step->repository, instance_nodes); + SynopticScenes::renumber(step->repository, scene_nodes); return TRUE; } @@ -96,6 +102,12 @@ void Synoptic::visitor(inter_tree *I, inter_tree_node *P, void *state) { TreeLists::add(past_tense_action_nodes, P); if (ptype == PackageTypes::get(I, I"_past_condition")) TreeLists::add(past_tense_condition_nodes, P); + if (ptype == PackageTypes::get(I, I"_instance")) { + TreeLists::add(instance_nodes, P); + inter_package *pack = Inter::Package::defined_by_frame(P); + if (Metadata::exists(pack, I"^is_scene")) + TreeLists::add(scene_nodes, P); + } } } @@ -120,6 +132,7 @@ void Synoptic::syn_visitor(inter_tree *I, inter_tree_node *P, void *state) { if (SynopticRelations::redefine(I, P, con_s, synid)) return; if (SynopticTables::redefine(I, P, con_s, synid)) return; if (SynopticChronology::redefine(I, P, con_s, synid)) return; + if (SynopticScenes::redefine(I, P, con_s, synid)) return; LOG("Couldn't consolidate $3\n", con_s); internal_error("symbol cannot be consolidated"); } diff --git a/inter/codegen-module/Contents.w b/inter/codegen-module/Contents.w index 3729ea46b..2e26ed355 100644 --- a/inter/codegen-module/Contents.w +++ b/inter/codegen-module/Contents.w @@ -33,10 +33,12 @@ Chapter 3: Synoptic Resources Rules Activities Actions + Instances Properties Relations Tables Chronology + Scenes Chapter 4: Inter to Final Code Code Generation