From 20d024c37eaefc7d22f451470955398354d15832 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Thu, 18 Apr 2019 09:51:47 +0100 Subject: [PATCH] Abolished action iname renaming --- docs/core-module/26-rt.html | 7 +- docs/core-module/27-ei.html | 2 +- docs/core-module/27-hl.html | 12 ++-- docs/core-module/27-hr.html | 10 ++- docs/core-module/27-in.html | 68 +++++++++---------- docs/core-module/27-pc.html | 62 ++++++----------- docs/core-module/27-tr.html | 2 +- docs/if-module/4-act.html | 43 ++++++++---- docs/index-module/3-dr.html | 22 +++--- inform7/core-module/Chapter 26/Routines.w | 7 +- .../Chapter 27/Hierarchy Locations.w | 12 ++-- inform7/core-module/Chapter 27/Hierarchy.w | 10 ++- .../core-module/Chapter 27/Inter Namespace.w | 60 ++++++++-------- inform7/core-module/Chapter 27/Packaging.w | 58 ++++++---------- inform7/if-module/Chapter 4/Actions.w | 39 +++++++---- .../Chapter 3/Documentation References.w | 20 +++--- 16 files changed, 210 insertions(+), 224 deletions(-) diff --git a/docs/core-module/26-rt.html b/docs/core-module/26-rt.html index fc52a532a..ec628db60 100644 --- a/docs/core-module/26-rt.html +++ b/docs/core-module/26-rt.html @@ -129,12 +129,9 @@ create a new nonphrasal stack frame. inter_name *kernel_name = NULL, *public_name = currently_compiling_iname; if ((currently_compiling_in_frame->allocated_pointers) || (currently_compiling_in_frame->no_formal_parameters_needed > 0)) { - if (Packaging::houseed_in_function(public_name)) { + if (Packaging::houseed_in_function(public_name)) kernel_name = Hierarchy::make_kernel_iname(Packaging::home_of(public_name)); - } else { - internal_error("routine not housed in function"); - } - Packaging::house_with(kernel_name, public_name); + else internal_error("routine not housed in function"); } int needed = LocalVariables::count(currently_compiling_in_frame); diff --git a/docs/core-module/27-ei.html b/docs/core-module/27-ei.html index 782b415f2..d9f86e70d 100644 --- a/docs/core-module/27-ei.html +++ b/docs/core-module/27-ei.html @@ -425,7 +425,7 @@

The function Emit::kind_to_symbol is used in §4, §5.

-

The function Emit::extern is used in 27/hl (§1).

+

The function Emit::extern is used in 27/in (§8).

The function Emit::response is used in 17/rs (§7.1).

diff --git a/docs/core-module/27-hl.html b/docs/core-module/27-hl.html index 5e3909212..732caa07c 100644 --- a/docs/core-module/27-hl.html +++ b/docs/core-module/27-hl.html @@ -188,7 +188,7 @@ } inter_name *HierarchyLocations::function(package_request *R, text_stream *name, text_stream *trans) { - inter_name *iname = Packaging::function(InterNames::explicitly_named(name, R), R, NULL); + inter_name *iname = Packaging::function(InterNames::explicitly_named(name, R), NULL); if (trans) InterNames::change_translation(iname, trans); return iname; } @@ -204,17 +204,15 @@ if (nrl->requirements.this_mundane_package == Hierarchy::template()) { packaging_state save = Packaging::enter(nrl->requirements.this_mundane_package); nrl->equates_to_iname = InterNames::explicitly_named(nrl->access_name, Hierarchy::template()); - nrl->equates_to_iname->symbol = Emit::extern(nrl->access_name, K_value); + InterNames::externalise_symbol(nrl->equates_to_iname, nrl->access_name); Packaging::exit(save); } else if (Str::len(nrl->function_package_name) > 0) { nrl->equates_to_iname = Packaging::function_text( InterNames::explicitly_named(nrl->function_package_name, nrl->requirements.this_mundane_package), - nrl->requirements.this_mundane_package, nrl->access_name); } else if (Str::len(nrl->datum_package_name) > 0) { nrl->equates_to_iname = Packaging::datum_text( InterNames::explicitly_named(nrl->datum_package_name, nrl->requirements.this_mundane_package), - nrl->requirements.this_mundane_package, nrl->access_name); } else if ((nrl->requirements.this_mundane_package) && (nrl->equates_to_iname == NULL)) { nrl->equates_to_iname = InterNames::explicitly_named(nrl->access_name, nrl->requirements.this_mundane_package); @@ -329,7 +327,7 @@
         if (Str::len(nrl->function_package_name) > 0) {
             iname = Packaging::function(
-                InterNames::explicitly_named(nrl->function_package_name, P), P, NULL);
+                InterNames::explicitly_named(nrl->function_package_name, P), NULL);
         } else {
             if (nrl->trans.by_imposition) iname = InterNames::explicitly_named_with_memo(imposed_name, P, W);
             else if (Str::len(nrl->access_name) == 0) iname = InterNames::explicitly_named_with_memo(T, P, W);
@@ -362,7 +360,7 @@
                 internal_error("subpackage not in enclosing superpackage");
         } else internal_error("NRL accessed inappropriately");
 
-        return Packaging::request(InterNames::explicitly_named(nrl->access_name, P), P, nrl->package_type);
+        return Packaging::request(InterNames::explicitly_named(nrl->access_name, P), nrl->package_type);
     }
     typedef struct hierarchy_attachment_point {
         int hap_id;
@@ -412,7 +410,7 @@
                     internal_error("subpackage in wrong superpackage");
         }
 
-        return Packaging::request(Packaging::supply_iname(R, hap->counter), R, hap->type);
+        return Packaging::request(Packaging::supply_iname(R, hap->counter), hap->type);
     }
 
diff --git a/docs/core-module/27-hr.html b/docs/core-module/27-hr.html index d4604abcb..5c695ef9c 100644 --- a/docs/core-module/27-hr.html +++ b/docs/core-module/27-hr.html @@ -148,6 +148,8 @@ enum MISTAKEACTION_HL enum ACTIONS_HAP enum ACTION_BASE_NAME_HL + enum WAIT_HL + enum TRANSLATED_BASE_NAME_HL enum DOUBLE_SHARP_NAME_HL enum PERFORM_FN_HL enum CHECK_RB_HL @@ -177,6 +179,8 @@ HierarchyLocations::ap(ACTIONS_HAP, local_actions, I"action", I"_action"); location_requirement in_action = HierarchyLocations::any_package_of_type(I"_action"); HierarchyLocations::con(ACTION_BASE_NAME_HL, I"A", Translation::uniqued(), in_action); + HierarchyLocations::con(WAIT_HL, I"Wait", Translation::same(), in_action); + HierarchyLocations::con(TRANSLATED_BASE_NAME_HL, NULL, Translation::imposed(), in_action); HierarchyLocations::con(DOUBLE_SHARP_NAME_HL, NULL, Translation::prefix(I"##"), in_action); HierarchyLocations::func(PERFORM_FN_HL, I"perform_fn", Translation::suffix(I"Sub"), in_action); HierarchyLocations::package(CHECK_RB_HL, I"check_rb", I"_rulebook", in_action); @@ -1882,7 +1886,7 @@ package_request *main_pr = NULL; package_request *Hierarchy::main(void) { if (main_pr == NULL) - main_pr = Packaging::request(InterNames::explicitly_named(I"main", NULL), NULL, plain_ptype); + main_pr = Packaging::request(InterNames::explicitly_named(I"main", NULL), plain_ptype); return main_pr; } @@ -1891,7 +1895,7 @@ if (resources_pr == NULL) resources_pr = Packaging::request( InterNames::explicitly_named(I"resources", Hierarchy::main()), - Hierarchy::main(), plain_ptype); + plain_ptype); return resources_pr; } @@ -1900,7 +1904,7 @@ if (template_pr == NULL) template_pr = Packaging::request( InterNames::explicitly_named(I"template", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return template_pr; } diff --git a/docs/core-module/27-in.html b/docs/core-module/27-in.html index 951312926..3f87c5083 100644 --- a/docs/core-module/27-in.html +++ b/docs/core-module/27-in.html @@ -73,7 +73,7 @@ any text to be stored, is used only for a small proportion of inames.)
     typedef struct inter_name {
-        struct inter_name_generator *family;
+        struct inter_name_generator *generated_by;
         int unique_number;
         struct inter_symbol *symbol;
         struct package_request *location_in_hierarchy;
@@ -84,7 +84,7 @@ any text to be stored, is used only for a small proportion of inames.)
 
 

-

The structure inter_name is accessed in 27/hl, 27/pc and here.

+

The structure inter_name is private to this section.

§3. This implements the %n escape, which prints an iname:

@@ -95,18 +95,18 @@ any text to be stored, is used only for a small proportion of inames.) inter_name *iname = (inter_name *) vI; if (iname == NULL) WRITE("<no-inter-name>"); else { - if (iname->family == NULL) internal_error("bad inter_name"); - switch (iname->family->ingen) { + if (iname->generated_by == NULL) internal_error("bad inter_name"); + switch (iname->generated_by->ingen) { case DERIVED_INGEN: - WRITE("%S", iname->family->derived_prefix); + WRITE("%S", iname->generated_by->derived_prefix); InterNames::writer(OUT, format_string, iname->derived_from); - WRITE("%S", iname->family->derived_suffix); + WRITE("%S", iname->generated_by->derived_suffix); break; case UNIQUE_INGEN: - WRITE("%S", iname->family->name_stem); + WRITE("%S", iname->generated_by->name_stem); break; case MULTIPLE_INGEN: - WRITE("%S", iname->family->name_stem); + WRITE("%S", iname->generated_by->name_stem); if (iname->unique_number >= 0) WRITE("%d", iname->unique_number); break; default: internal_error("unknown ingen"); @@ -137,7 +137,7 @@ for some inames it never will.
     inter_name *InterNames::new(inter_name_generator *F, package_request *R, wording W) {
         inter_name *iname = CREATE(inter_name);
-        iname->family = F;
+        iname->generated_by = F;
         iname->unique_number = 0;
         iname->symbol = NULL;
         iname->derived_from = NULL;
@@ -225,23 +225,23 @@ a memo to attach):
 
 
 
-    inter_name *InterNames::multiple(inter_name_generator *F, package_request *R, wording W) {
-        if (F == NULL) internal_error("no family");
-        if (F->ingen == UNIQUE_INGEN) internal_error("not a family name");
-        inter_name *iname = InterNames::new(F, R, W);
-        if (F->ingen != DERIVED_INGEN) iname->unique_number = ++F->no_generated;
+    inter_name *InterNames::multiple(inter_name_generator *G, package_request *R, wording W) {
+        if (G == NULL) internal_error("no generator");
+        if (G->ingen == UNIQUE_INGEN) internal_error("not a generator name");
+        inter_name *iname = InterNames::new(G, R, W);
+        if (G->ingen != DERIVED_INGEN) iname->unique_number = ++G->no_generated;
         return iname;
     }
 
-    inter_name *InterNames::generated(inter_name_generator *F, int fix, wording W) {
-        inter_name *iname = InterNames::multiple(F, NULL, W);
+    inter_name *InterNames::generated(inter_name_generator *G, int fix, wording W) {
+        inter_name *iname = InterNames::multiple(G, NULL, W);
         if (fix != -1) iname->unique_number = fix;
         return iname;
     }
 
-    inter_name *InterNames::derived(inter_name_generator *F, inter_name *from, wording W) {
-        if (F->ingen != DERIVED_INGEN) internal_error("not a derived family");
-        inter_name *iname = InterNames::multiple(F, from->location_in_hierarchy, W);
+    inter_name *InterNames::derived(inter_name_generator *G, inter_name *from, wording W) {
+        if (G->ingen != DERIVED_INGEN) internal_error("not a derived generator");
+        inter_name *iname = InterNames::multiple(G, from->location_in_hierarchy, W);
         iname->derived_from = from;
         return iname;
     }
@@ -255,39 +255,30 @@ a memo to attach):
 
 

The function InterNames::derived is used in 27/hl (§1).

-

§7. An ugly necessity is that a handful of inames representing actions have to -be renamed after creation, thanks to sentences such as: -

- -
-

The taking action translates into I6 as "Take".

- -
+

§7.

-    void InterNames::override_action_base_iname(inter_name *iname, text_stream *to) {
-        if (iname == NULL) internal_error("no such iname");
-    if (iname->symbol) internal_error("too late to rename iname");
-        iname->family->name_stem = Str::duplicate(to);
-        Str::clear(iname->memo);
+    package_request *InterNames::location(inter_name *iname) {
+        if (iname == NULL) return NULL;
+        return iname->location_in_hierarchy;
     }
 

-

The function InterNames::override_action_base_iname appears nowhere else.

+

The function InterNames::location is used in 27/pc (§4, §5, §6, §8).

§8. Conversion of inames to symbols. The purpose of inames is not quite to represent identifier names occurring in given packages inside the Inter hierarchy: it would be more accurate to say that they represent potential identifiers, which may or may not be used. At some point they will probably (but not certainly) undergo "conversion", when they are matched up with actual symbols in the symbols tables of the -given packages. Once this is done, an iname can't be renamed or moved. +given packages.

Conversion is done on-demand, and thus left as late as possible. It happens -automatically in the following function: +automatically in one of the following two functions:

@@ -303,6 +294,11 @@ automatically in the following function: return iname->symbol; } + void InterNames::externalise_symbol(inter_name *iname, inter_name *ext_iname) { + if (iname->symbol != NULL) internal_error("iname already converted"); + iname->symbol = Emit::extern(ext_iname, K_value);; + } + @@ -408,6 +404,8 @@ automatically in the following function:

The function InterNames::to_symbol is used in 13/rsfk (§5), 15/epv (§4), 21/rl (§9, §11.2, §22), 26/iti (§9), 27/is (§32), 27/ei (§3, §4, §5).

+

The function InterNames::externalise_symbol is used in 27/hl (§1).

+

The function InterNames::change_translation is used in 5/un (§1), 13/rsfk (§25), 15/pr (§21), 27/hl (§1, §1.1), 27/pc (§8).

The function InterNames::get_translation is used in 15/pr (§22.1).

diff --git a/docs/core-module/27-pc.html b/docs/core-module/27-pc.html index db847adf8..96cf05461 100644 --- a/docs/core-module/27-pc.html +++ b/docs/core-module/27-pc.html @@ -84,13 +84,12 @@
-    package_request *Packaging::request(inter_name *name, package_request *parent, inter_symbol *pt) {
+    package_request *Packaging::request(inter_name *name, inter_symbol *pt) {
         package_request *R = CREATE(package_request);
         R->eventual_name = name;
-        if (parent) name->location_in_hierarchy = parent;
         R->eventual_type = pt;
         R->actual_package = NULL;
-        R->parent_request = parent;
+        R->parent_request = InterNames::location(name);
         R->write_position = Inter::Bookmarks::new_IRS(Emit::repository());
         R->counters = NULL;
         return R;
@@ -135,7 +134,7 @@
     }
 
     package_request *Packaging::home_of(inter_name *N) {
-        return N->location_in_hierarchy;
+        return InterNames::location(N);
     }
 
     packaging_state Packaging::enter_home_of(inter_name *N) {
@@ -229,8 +228,9 @@
 
     inter_symbols_table *Packaging::scope(inter_repository *I, inter_name *N) {
         if (N == NULL) internal_error("can't determine scope of null name");
-        if (N->location_in_hierarchy == NULL) return Inter::get_global_symbols(Emit::repository());
-        return Inter::Packages::scope(Packaging::incarnate(N->location_in_hierarchy));
+        package_request *P = InterNames::location(N);
+        if (P == NULL) return Inter::get_global_symbols(Emit::repository());
+        return Inter::Packages::scope(Packaging::incarnate(P));
     }
 
@@ -253,7 +253,7 @@ if (generic_pr == NULL) generic_pr = Packaging::request( InterNames::explicitly_named(I"generic", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return generic_pr; } @@ -262,7 +262,7 @@ if (synoptic_pr == NULL) synoptic_pr = Packaging::request( InterNames::explicitly_named(I"synoptic", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return synoptic_pr; } @@ -290,7 +290,7 @@ package_request *Packaging::resources_for_new_submodule(text_stream *name, submodule_requests *SR) { inter_name *package_iname = InterNames::explicitly_named(name, Hierarchy::resources()); - package_request *P = Packaging::request(package_iname, Hierarchy::resources(), module_ptype); + package_request *P = Packaging::request(package_iname, module_ptype); Packaging::initialise_submodules(SR); return P; } @@ -385,7 +385,7 @@ inter_name *iname = InterNames::explicitly_named(sid->submodule_name, parent); sr = CREATE(submodule_request); sr->which_submodule = sid; - sr->where_found = Packaging::request(iname, parent, plain_ptype); + sr->where_found = Packaging::request(iname, plain_ptype); ADD_TO_LINKED_LIST(sr, submodule_request, SR->submodules); return sr->where_found;
@@ -436,10 +436,9 @@ return iname; } - inter_name *Packaging::function(inter_name *function_iname, package_request *R2, inter_name *temp_iname) { - package_request *R3 = Packaging::request(function_iname, R2, function_ptype); - inter_name *iname = InterNames::explicitly_named(I"call", R3); - Packaging::house(iname, R3); + inter_name *Packaging::function(inter_name *function_iname, inter_name *temp_iname) { + package_request *P = Packaging::request(function_iname, function_ptype); + inter_name *iname = InterNames::explicitly_named(I"call", P); if (temp_iname) { TEMPORARY_TEXT(T); WRITE_TO(T, "%n", temp_iname); @@ -449,38 +448,25 @@ return iname; } - inter_name *Packaging::function_text(inter_name *function_iname, package_request *R2, text_stream *translation) { - package_request *R3 = Packaging::request(function_iname, R2, function_ptype); - inter_name *iname = InterNames::explicitly_named(I"call", R3); - Packaging::house(iname, R3); + inter_name *Packaging::function_text(inter_name *function_iname, text_stream *translation) { + package_request *P = Packaging::request(function_iname, function_ptype); + inter_name *iname = InterNames::explicitly_named(I"call", P); if (translation) InterNames::change_translation(iname, translation); return iname; } - inter_name *Packaging::datum_text(inter_name *function_iname, package_request *R2, text_stream *translation) { - package_request *R3 = Packaging::request(function_iname, R2, data_ptype); - inter_name *iname = InterNames::explicitly_named(translation, R3); - Packaging::house(iname, R3); + inter_name *Packaging::datum_text(inter_name *function_iname, text_stream *translation) { + package_request *P = Packaging::request(function_iname, data_ptype); + inter_name *iname = InterNames::explicitly_named(translation, P); return iname; } - void Packaging::house(inter_name *iname, package_request *at) { - if (iname == NULL) internal_error("can't house null name"); - if (at == NULL) internal_error("can't house nowhere"); - iname->location_in_hierarchy = at; - } - - void Packaging::house_with(inter_name *iname, inter_name *landlord) { - if (iname == NULL) internal_error("can't house null name"); - if (landlord == NULL) internal_error("can't house with nobody"); - iname->location_in_hierarchy = landlord->location_in_hierarchy; - } - int Packaging::houseed_in_function(inter_name *iname) { if (iname == NULL) return FALSE; - if (iname->location_in_hierarchy == NULL) return FALSE; - if (iname->location_in_hierarchy->eventual_type == function_ptype) return TRUE; + package_request *P = InterNames::location(iname); + if (P == NULL) return FALSE; + if (P->eventual_type == function_ptype) return TRUE; return FALSE; }
@@ -497,10 +483,6 @@

The function Packaging::datum_text is used in 27/hl (§1).

-

The function Packaging::house appears nowhere else.

- -

The function Packaging::house_with is used in 26/rt (§4).

-

The function Packaging::houseed_in_function is used in 26/rt (§4), 27/ei (§4).


diff --git a/docs/core-module/27-tr.html b/docs/core-module/27-tr.html index 54d90e3c2..26f54aaa7 100644 --- a/docs/core-module/27-tr.html +++ b/docs/core-module/27-tr.html @@ -83,7 +83,7 @@

The function Translation::uniqued is used in 27/hr (§1.4, §1.6, §1.8, §1.14, §1.16, §1.20, §1.22, §1.24, §1.28, §1.30, §1.32, §1.36, §1.38, §1.40, §1.42, §1.46).

-

The function Translation::imposed is used in 27/hr (§1.28).

+

The function Translation::imposed is used in 27/hr (§1.4, §1.28).

The function Translation::to is used in 27/hr (§1.4, §1.10, §1.12, §1.18, §1.22, §1.26, §1.28, §1.36, §1.38, §1.40, §1.42, §1.48).

diff --git a/docs/if-module/4-act.html b/docs/if-module/4-act.html index 8fd6de6cd..fa427c576 100644 --- a/docs/if-module/4-act.html +++ b/docs/if-module/4-act.html @@ -48,6 +48,7 @@ and maximum below are always equal. int it_optional; noun optional when describing the second noun? int abbreviable; preposition optional when describing the second noun? int translated; + struct text_stream *translated_name; struct inter_name *an_base_iname; e.g., Take struct inter_name *an_iname; e.g., ##Take struct inter_name *an_routine_iname; e.g., TakeSub @@ -329,9 +330,10 @@ make that explicit: for instance, "taking" becomes "the taking action". an->it_optional = TRUE; an->abbreviable = FALSE; an->translated = FALSE; + an->translated_name = NULL; an->an_package = Hierarchy::local_package(ACTIONS_HAP); - an->an_base_iname = Hierarchy::make_iname_with_memo(ACTION_BASE_NAME_HL, an->an_package, W); + an->an_base_iname = NULL; an->use_verb_routine_in_I6_library = TRUE; an->check_rules = NULL; an->carry_out_rules = NULL; @@ -406,10 +408,7 @@ make that explicit: for instance, "taking" becomes "the taking action". an->it_optional = FALSE; an2->it_optional = FALSE; } - if (make_ds) { - InterNames::override_action_base_iname(an->an_base_iname, I"Wait"); - PL::Actions::double_sharp(an); - } + return an; } @@ -552,7 +551,7 @@ then that's what "listening" will match.) } text_stream *PL::Actions::identifier(action_name *an) { - return InterNames::to_text(an->an_base_iname); + return InterNames::to_text(PL::Actions::base_iname(an)); } action_name *PL::Actions::Wait(void) { @@ -560,9 +559,21 @@ then that's what "listening" will match.) return waiting_action; } + inter_name *PL::Actions::base_iname(action_name *an) { + if (an->an_base_iname == NULL) { + if (waiting_action == an) + an->an_base_iname = Hierarchy::make_iname_in(WAIT_HL, an->an_package); + else if (Str::len(an->translated_name) > 0) + an->an_base_iname = Hierarchy::make_iname_with_specific_name(TRANSLATED_BASE_NAME_HL, an->translated_name, an->an_package); + else + an->an_base_iname = Hierarchy::make_iname_with_memo(ACTION_BASE_NAME_HL, an->an_package, an->present_name); + } + return an->an_base_iname; + } + inter_name *PL::Actions::double_sharp(action_name *an) { if (an->an_iname == NULL) { - an->an_iname = Hierarchy::derive_iname_in(DOUBLE_SHARP_NAME_HL, an->an_base_iname, an->an_package); + an->an_iname = Hierarchy::derive_iname_in(DOUBLE_SHARP_NAME_HL, PL::Actions::base_iname(an), an->an_package); packaging_state save = Packaging::enter(an->an_package); Emit::ds_named_pseudo_numeric_constant(an->an_iname, K_value, (inter_t) an->allocation_id); InterNames::annotate_i(an->an_iname, ACTION_IANN, 1); @@ -573,7 +584,7 @@ then that's what "listening" will match.) inter_name *PL::Actions::Sub(action_name *an) { if (an->an_routine_iname == NULL) - an->an_routine_iname = Hierarchy::derive_iname_in(PERFORM_FN_HL, an->an_base_iname, an->an_package); + an->an_routine_iname = Hierarchy::derive_iname_in(PERFORM_FN_HL, PL::Actions::base_iname(an), an->an_package); return an->an_routine_iname; } @@ -619,7 +630,9 @@ then that's what "listening" will match.)

The function PL::Actions::Wait appears nowhere else.

-

The function PL::Actions::double_sharp is used in §16, §37, 4/anl (§9), 4/ap (§29, §35).

+

The function PL::Actions::base_iname is used in §22.

+ +

The function PL::Actions::double_sharp is used in §37, 4/anl (§9), 4/ap (§29, §35).

The function PL::Actions::Sub is used in §36.

@@ -654,18 +667,18 @@ names of significance in the I6 library. return; } if (an->translated) { - LOG("Tried action name %W = %n\n", W, an->an_base_iname); + LOG("Tried action name %W = %n\n", W, PL::Actions::base_iname(an)); Problems::Issue::sentence_problem(_p_(PM_TranslatesActionAlready), "this action has already been translated", "so there must be some duplication somewhere."); return; } + if (an->an_base_iname) internal_error("too late for action base name translation"); + an->translated = TRUE; - TEMPORARY_TEXT(TO); - WRITE_TO(TO, "%N", Wordings::first_wn(ParseTree::get_text(p2))); - InterNames::override_action_base_iname(an->an_base_iname, TO); - DISCARD_TEXT(TO); - LOGIF(ACTION_CREATIONS, "Translated action: $l as %n\n", an, an->an_base_iname); + an->translated_name = Str::new(); + WRITE_TO(an->translated_name, "%N", Wordings::first_wn(ParseTree::get_text(p2))); + LOGIF(ACTION_CREATIONS, "Translated action: $l as %n\n", an, PL::Actions::base_iname(an)); } int PL::Actions::get_stem_length(action_name *an) { diff --git a/docs/index-module/3-dr.html b/docs/index-module/3-dr.html index 62ffa1484..3238a8490 100644 --- a/docs/index-module/3-dr.html +++ b/docs/index-module/3-dr.html @@ -43,7 +43,7 @@ documentation.
     typedef struct documentation_ref {
-        struct text_stream *symbol;     Reference is by this piece of text
+        struct text_stream *doc_symbol;     Reference is by this piece of text
         int section;     HTML page number
         int used_already;     Has this been used in a problem message already?
         int usage_count;     For statistical purposes
@@ -59,7 +59,7 @@ documentation.
 
 

-

The structure documentation_ref is accessed in 3/ifs and here.

+

The structure documentation_ref is private to this section.

§3.

@@ -108,8 +108,8 @@ references: } LOOP_THROUGH_WORDING(i, SW) { documentation_ref *dr = CREATE(documentation_ref); - dr->symbol = Str::new(); - WRITE_TO(dr->symbol, "%+W", Wordings::one_word(i)); + dr->doc_symbol = Str::new(); + WRITE_TO(dr->doc_symbol, "%+W", Wordings::one_word(i)); dr->section = Wordings::first_wn(RW); dr->used_already = FALSE; dr->usage_count = 0; @@ -142,7 +142,7 @@ extension (say doc24); int Index::DocReferences::validate_if_possible(text_stream *temp) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, temp)) + if (Str::eq(dr->doc_symbol, temp)) return TRUE; return FALSE; } @@ -160,7 +160,7 @@ extension (say doc24); wchar_t *Index::DocReferences::link_if_possible_once(text_stream *temp, wchar_t **chap, wchar_t **sec) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, temp)) { + if (Str::eq(dr->doc_symbol, temp)) { if (dr->used_already == FALSE) { wchar_t *leaf = Lexer::word_text(dr->section); *chap = dr->chapter_reference; @@ -227,7 +227,7 @@ such a phrase, it increments the usage count by calling the following: if (Log::aspect_switched_on(PHRASE_USAGE_DA)) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) { - if (Str::eq(dr->symbol, symb)) { + if (Str::eq(dr->doc_symbol, symb)) { extension_file *loc = NULL; if (at_word >= 0) { source_file *pos = Lexer::file_of_origin(at_word); @@ -261,8 +261,8 @@ especially, but to be accumulated over a whole corpus of source texts, e.g.: LOGIF(PHRASE_USAGE, "The following shows how often each built-in phrase was used:\n"); documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::begins_with_wide_string(dr->symbol, L"ph")) - LOGIF(PHRASE_USAGE, "USAGE: %S %d %d %d\n", dr->symbol, + if (Str::begins_with_wide_string(dr->doc_symbol, L"ph")) + LOGIF(PHRASE_USAGE, "USAGE: %S %d %d %d\n", dr->doc_symbol, dr->usage_count, dr->sr_usage_count, dr->ext_usage_count); }
@@ -447,7 +447,7 @@ nothing at all — not issuing any internal errors. documentation_ref *Index::DocReferences::name_to_dr(text_stream *fn) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, fn)) + if (Str::eq(dr->doc_symbol, fn)) return dr; <Complain about a bad documentation reference 13.1>; return NULL; @@ -471,7 +471,7 @@ nothing at all — not issuing any internal errors. if (problem_count == 0) { LOG("Bad ref was <%s>. Known references are:\n", fn); LOOP_OVER(dr, documentation_ref) - LOG("%S = %+N\n", dr->symbol, dr->section); + LOG("%S = %+N\n", dr->doc_symbol, dr->section); internal_error("Bad index documentation reference"); }
diff --git a/inform7/core-module/Chapter 26/Routines.w b/inform7/core-module/Chapter 26/Routines.w index d8ff173fd..a08a6e7dc 100644 --- a/inform7/core-module/Chapter 26/Routines.w +++ b/inform7/core-module/Chapter 26/Routines.w @@ -82,12 +82,9 @@ void Routines::end_in_current_package(void) { inter_name *kernel_name = NULL, *public_name = currently_compiling_iname; if ((currently_compiling_in_frame->allocated_pointers) || (currently_compiling_in_frame->no_formal_parameters_needed > 0)) { - if (Packaging::houseed_in_function(public_name)) { + if (Packaging::houseed_in_function(public_name)) kernel_name = Hierarchy::make_kernel_iname(Packaging::home_of(public_name)); - } else { - internal_error("routine not housed in function"); - } - Packaging::house_with(kernel_name, public_name); + else internal_error("routine not housed in function"); } int needed = LocalVariables::count(currently_compiling_in_frame); diff --git a/inform7/core-module/Chapter 27/Hierarchy Locations.w b/inform7/core-module/Chapter 27/Hierarchy Locations.w index 76da2f1ff..d9fa5882d 100644 --- a/inform7/core-module/Chapter 27/Hierarchy Locations.w +++ b/inform7/core-module/Chapter 27/Hierarchy Locations.w @@ -178,7 +178,7 @@ inter_name *HierarchyLocations::find_by_name(text_stream *name) { } inter_name *HierarchyLocations::function(package_request *R, text_stream *name, text_stream *trans) { - inter_name *iname = Packaging::function(InterNames::explicitly_named(name, R), R, NULL); + inter_name *iname = Packaging::function(InterNames::explicitly_named(name, R), NULL); if (trans) InterNames::change_translation(iname, trans); return iname; } @@ -194,17 +194,15 @@ inter_name *HierarchyLocations::nrl_to_iname(named_resource_location *nrl) { if (nrl->requirements.this_mundane_package == Hierarchy::template()) { packaging_state save = Packaging::enter(nrl->requirements.this_mundane_package); nrl->equates_to_iname = InterNames::explicitly_named(nrl->access_name, Hierarchy::template()); - nrl->equates_to_iname->symbol = Emit::extern(nrl->access_name, K_value); + InterNames::externalise_symbol(nrl->equates_to_iname, nrl->access_name); Packaging::exit(save); } else if (Str::len(nrl->function_package_name) > 0) { nrl->equates_to_iname = Packaging::function_text( InterNames::explicitly_named(nrl->function_package_name, nrl->requirements.this_mundane_package), - nrl->requirements.this_mundane_package, nrl->access_name); } else if (Str::len(nrl->datum_package_name) > 0) { nrl->equates_to_iname = Packaging::datum_text( InterNames::explicitly_named(nrl->datum_package_name, nrl->requirements.this_mundane_package), - nrl->requirements.this_mundane_package, nrl->access_name); } else if ((nrl->requirements.this_mundane_package) && (nrl->equates_to_iname == NULL)) { nrl->equates_to_iname = InterNames::explicitly_named(nrl->access_name, nrl->requirements.this_mundane_package); @@ -265,7 +263,7 @@ inter_name *HierarchyLocations::find_in_package(int id, package_request *P, word @ = if (Str::len(nrl->function_package_name) > 0) { iname = Packaging::function( - InterNames::explicitly_named(nrl->function_package_name, P), P, NULL); + InterNames::explicitly_named(nrl->function_package_name, P), NULL); } else { if (nrl->trans.by_imposition) iname = InterNames::explicitly_named_with_memo(imposed_name, P, W); else if (Str::len(nrl->access_name) == 0) iname = InterNames::explicitly_named_with_memo(T, P, W); @@ -290,7 +288,7 @@ package_request *HierarchyLocations::package_in_package(int id, package_request internal_error("subpackage not in enclosing superpackage"); } else internal_error("NRL accessed inappropriately"); - return Packaging::request(InterNames::explicitly_named(nrl->access_name, P), P, nrl->package_type); + return Packaging::request(InterNames::explicitly_named(nrl->access_name, P), nrl->package_type); } = @@ -342,7 +340,7 @@ package_request *HierarchyLocations::attach_new_package(compilation_module *C, p internal_error("subpackage in wrong superpackage"); } - return Packaging::request(Packaging::supply_iname(R, hap->counter), R, hap->type); + return Packaging::request(Packaging::supply_iname(R, hap->counter), hap->type); } @ diff --git a/inform7/core-module/Chapter 27/Hierarchy.w b/inform7/core-module/Chapter 27/Hierarchy.w index 0e2484418..d7175e61c 100644 --- a/inform7/core-module/Chapter 27/Hierarchy.w +++ b/inform7/core-module/Chapter 27/Hierarchy.w @@ -119,6 +119,8 @@ void Hierarchy::establish(void) { @e ACTIONS_HAP @e ACTION_BASE_NAME_HL +@e WAIT_HL +@e TRANSLATED_BASE_NAME_HL @e DOUBLE_SHARP_NAME_HL @e PERFORM_FN_HL @e CHECK_RB_HL @@ -144,6 +146,8 @@ void Hierarchy::establish(void) { HierarchyLocations::ap(ACTIONS_HAP, local_actions, I"action", I"_action"); location_requirement in_action = HierarchyLocations::any_package_of_type(I"_action"); HierarchyLocations::con(ACTION_BASE_NAME_HL, I"A", Translation::uniqued(), in_action); + HierarchyLocations::con(WAIT_HL, I"Wait", Translation::same(), in_action); + HierarchyLocations::con(TRANSLATED_BASE_NAME_HL, NULL, Translation::imposed(), in_action); HierarchyLocations::con(DOUBLE_SHARP_NAME_HL, NULL, Translation::prefix(I"##"), in_action); HierarchyLocations::func(PERFORM_FN_HL, I"perform_fn", Translation::suffix(I"Sub"), in_action); HierarchyLocations::package(CHECK_RB_HL, I"check_rb", I"_rulebook", in_action); @@ -1570,7 +1574,7 @@ inter_name *Hierarchy::find_by_name(text_stream *name) { package_request *main_pr = NULL; package_request *Hierarchy::main(void) { if (main_pr == NULL) - main_pr = Packaging::request(InterNames::explicitly_named(I"main", NULL), NULL, plain_ptype); + main_pr = Packaging::request(InterNames::explicitly_named(I"main", NULL), plain_ptype); return main_pr; } @@ -1579,7 +1583,7 @@ package_request *Hierarchy::resources(void) { if (resources_pr == NULL) resources_pr = Packaging::request( InterNames::explicitly_named(I"resources", Hierarchy::main()), - Hierarchy::main(), plain_ptype); + plain_ptype); return resources_pr; } @@ -1588,7 +1592,7 @@ package_request *Hierarchy::template(void) { if (template_pr == NULL) template_pr = Packaging::request( InterNames::explicitly_named(I"template", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return template_pr; } diff --git a/inform7/core-module/Chapter 27/Inter Namespace.w b/inform7/core-module/Chapter 27/Inter Namespace.w index 0534e8d04..438c3a913 100644 --- a/inform7/core-module/Chapter 27/Inter Namespace.w +++ b/inform7/core-module/Chapter 27/Inter Namespace.w @@ -49,7 +49,7 @@ any text to be stored, is used only for a small proportion of inames.) = typedef struct inter_name { - struct inter_name_generator *family; + struct inter_name_generator *generated_by; int unique_number; struct inter_symbol *symbol; struct package_request *location_in_hierarchy; @@ -64,18 +64,18 @@ void InterNames::writer(OUTPUT_STREAM, char *format_string, void *vI) { inter_name *iname = (inter_name *) vI; if (iname == NULL) WRITE(""); else { - if (iname->family == NULL) internal_error("bad inter_name"); - switch (iname->family->ingen) { + if (iname->generated_by == NULL) internal_error("bad inter_name"); + switch (iname->generated_by->ingen) { case DERIVED_INGEN: - WRITE("%S", iname->family->derived_prefix); + WRITE("%S", iname->generated_by->derived_prefix); InterNames::writer(OUT, format_string, iname->derived_from); - WRITE("%S", iname->family->derived_suffix); + WRITE("%S", iname->generated_by->derived_suffix); break; case UNIQUE_INGEN: - WRITE("%S", iname->family->name_stem); + WRITE("%S", iname->generated_by->name_stem); break; case MULTIPLE_INGEN: - WRITE("%S", iname->family->name_stem); + WRITE("%S", iname->generated_by->name_stem); if (iname->unique_number >= 0) WRITE("%d", iname->unique_number); break; default: internal_error("unknown ingen"); @@ -99,7 +99,7 @@ for some inames it never will. = inter_name *InterNames::new(inter_name_generator *F, package_request *R, wording W) { inter_name *iname = CREATE(inter_name); - iname->family = F; + iname->generated_by = F; iname->unique_number = 0; iname->symbol = NULL; iname->derived_from = NULL; @@ -151,38 +151,31 @@ inter_name *InterNames::explicitly_named(text_stream *name, package_request *R) @ Second, the generated or derived cases: = -inter_name *InterNames::multiple(inter_name_generator *F, package_request *R, wording W) { - if (F == NULL) internal_error("no family"); - if (F->ingen == UNIQUE_INGEN) internal_error("not a family name"); - inter_name *iname = InterNames::new(F, R, W); - if (F->ingen != DERIVED_INGEN) iname->unique_number = ++F->no_generated; +inter_name *InterNames::multiple(inter_name_generator *G, package_request *R, wording W) { + if (G == NULL) internal_error("no generator"); + if (G->ingen == UNIQUE_INGEN) internal_error("not a generator name"); + inter_name *iname = InterNames::new(G, R, W); + if (G->ingen != DERIVED_INGEN) iname->unique_number = ++G->no_generated; return iname; } -inter_name *InterNames::generated(inter_name_generator *F, int fix, wording W) { - inter_name *iname = InterNames::multiple(F, NULL, W); +inter_name *InterNames::generated(inter_name_generator *G, int fix, wording W) { + inter_name *iname = InterNames::multiple(G, NULL, W); if (fix != -1) iname->unique_number = fix; return iname; } -inter_name *InterNames::derived(inter_name_generator *F, inter_name *from, wording W) { - if (F->ingen != DERIVED_INGEN) internal_error("not a derived family"); - inter_name *iname = InterNames::multiple(F, from->location_in_hierarchy, W); +inter_name *InterNames::derived(inter_name_generator *G, inter_name *from, wording W) { + if (G->ingen != DERIVED_INGEN) internal_error("not a derived generator"); + inter_name *iname = InterNames::multiple(G, from->location_in_hierarchy, W); iname->derived_from = from; return iname; } -@ An ugly necessity is that a handful of inames representing actions have to -be renamed after creation, thanks to sentences such as: - ->> The taking action translates into I6 as "Take". - -= -void InterNames::override_action_base_iname(inter_name *iname, text_stream *to) { - if (iname == NULL) internal_error("no such iname"); -// if (iname->symbol) internal_error("too late to rename iname"); - iname->family->name_stem = Str::duplicate(to); - Str::clear(iname->memo); +@ = +package_request *InterNames::location(inter_name *iname) { + if (iname == NULL) return NULL; + return iname->location_in_hierarchy; } @h Conversion of inames to symbols. @@ -191,10 +184,10 @@ given packages inside the Inter hierarchy: it would be more accurate to say that they represent potential identifiers, which may or may not be used. At some point they will probably (but not certainly) undergo "conversion", when they are matched up with actual symbols in the symbols tables of the -given packages. Once this is done, an iname can't be renamed or moved. +given packages. Conversion is done on-demand, and thus left as late as possible. It happens -automatically in the following function: +automatically in one of the following two functions: = inter_symbol *InterNames::to_symbol(inter_name *iname) { @@ -208,6 +201,11 @@ inter_symbol *InterNames::to_symbol(inter_name *iname) { return iname->symbol; } +void InterNames::externalise_symbol(inter_name *iname, inter_name *ext_iname) { + if (iname->symbol != NULL) internal_error("iname already converted"); + iname->symbol = Emit::extern(ext_iname, K_value);; +} + diff --git a/inform7/core-module/Chapter 27/Packaging.w b/inform7/core-module/Chapter 27/Packaging.w index b19f630aa..89b14c214 100644 --- a/inform7/core-module/Chapter 27/Packaging.w +++ b/inform7/core-module/Chapter 27/Packaging.w @@ -50,13 +50,12 @@ typedef struct submodule_request_counter { } submodule_request_counter; @ = -package_request *Packaging::request(inter_name *name, package_request *parent, inter_symbol *pt) { +package_request *Packaging::request(inter_name *name, inter_symbol *pt) { package_request *R = CREATE(package_request); R->eventual_name = name; - if (parent) name->location_in_hierarchy = parent; R->eventual_type = pt; R->actual_package = NULL; - R->parent_request = parent; + R->parent_request = InterNames::location(name); R->write_position = Inter::Bookmarks::new_IRS(Emit::repository()); R->counters = NULL; return R; @@ -91,7 +90,7 @@ packaging_state Packaging::stateless(void) { } package_request *Packaging::home_of(inter_name *N) { - return N->location_in_hierarchy; + return InterNames::location(N); } packaging_state Packaging::enter_home_of(inter_name *N) { @@ -167,8 +166,9 @@ inter_package *Packaging::incarnate(package_request *R) { inter_symbols_table *Packaging::scope(inter_repository *I, inter_name *N) { if (N == NULL) internal_error("can't determine scope of null name"); - if (N->location_in_hierarchy == NULL) return Inter::get_global_symbols(Emit::repository()); - return Inter::Packages::scope(Packaging::incarnate(N->location_in_hierarchy)); + package_request *P = InterNames::location(N); + if (P == NULL) return Inter::get_global_symbols(Emit::repository()); + return Inter::Packages::scope(Packaging::incarnate(P)); } @ = @@ -177,7 +177,7 @@ package_request *Packaging::request_generic(void) { if (generic_pr == NULL) generic_pr = Packaging::request( InterNames::explicitly_named(I"generic", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return generic_pr; } @@ -186,7 +186,7 @@ package_request *Packaging::request_synoptic(void) { if (synoptic_pr == NULL) synoptic_pr = Packaging::request( InterNames::explicitly_named(I"synoptic", Hierarchy::resources()), - Hierarchy::resources(), module_ptype); + module_ptype); return synoptic_pr; } @@ -214,7 +214,7 @@ typedef struct submodule_requests { package_request *Packaging::resources_for_new_submodule(text_stream *name, submodule_requests *SR) { inter_name *package_iname = InterNames::explicitly_named(name, Hierarchy::resources()); - package_request *P = Packaging::request(package_iname, Hierarchy::resources(), module_ptype); + package_request *P = Packaging::request(package_iname, module_ptype); Packaging::initialise_submodules(SR); return P; } @@ -277,7 +277,7 @@ package_request *Packaging::synoptic_resource(submodule_identity *sid) { inter_name *iname = InterNames::explicitly_named(sid->submodule_name, parent); sr = CREATE(submodule_request); sr->which_submodule = sid; - sr->where_found = Packaging::request(iname, parent, plain_ptype); + sr->where_found = Packaging::request(iname, plain_ptype); ADD_TO_LINKED_LIST(sr, submodule_request, SR->submodules); return sr->where_found; @@ -320,10 +320,9 @@ inter_name *Packaging::supply_iname(package_request *R, int what_for) { return iname; } -inter_name *Packaging::function(inter_name *function_iname, package_request *R2, inter_name *temp_iname) { - package_request *R3 = Packaging::request(function_iname, R2, function_ptype); - inter_name *iname = InterNames::explicitly_named(I"call", R3); - Packaging::house(iname, R3); +inter_name *Packaging::function(inter_name *function_iname, inter_name *temp_iname) { + package_request *P = Packaging::request(function_iname, function_ptype); + inter_name *iname = InterNames::explicitly_named(I"call", P); if (temp_iname) { TEMPORARY_TEXT(T); WRITE_TO(T, "%n", temp_iname); @@ -333,37 +332,24 @@ inter_name *Packaging::function(inter_name *function_iname, package_request *R2, return iname; } -inter_name *Packaging::function_text(inter_name *function_iname, package_request *R2, text_stream *translation) { - package_request *R3 = Packaging::request(function_iname, R2, function_ptype); - inter_name *iname = InterNames::explicitly_named(I"call", R3); - Packaging::house(iname, R3); +inter_name *Packaging::function_text(inter_name *function_iname, text_stream *translation) { + package_request *P = Packaging::request(function_iname, function_ptype); + inter_name *iname = InterNames::explicitly_named(I"call", P); if (translation) InterNames::change_translation(iname, translation); return iname; } -inter_name *Packaging::datum_text(inter_name *function_iname, package_request *R2, text_stream *translation) { - package_request *R3 = Packaging::request(function_iname, R2, data_ptype); - inter_name *iname = InterNames::explicitly_named(translation, R3); - Packaging::house(iname, R3); +inter_name *Packaging::datum_text(inter_name *function_iname, text_stream *translation) { + package_request *P = Packaging::request(function_iname, data_ptype); + inter_name *iname = InterNames::explicitly_named(translation, P); return iname; } -void Packaging::house(inter_name *iname, package_request *at) { - if (iname == NULL) internal_error("can't house null name"); - if (at == NULL) internal_error("can't house nowhere"); - iname->location_in_hierarchy = at; -} - -void Packaging::house_with(inter_name *iname, inter_name *landlord) { - if (iname == NULL) internal_error("can't house null name"); - if (landlord == NULL) internal_error("can't house with nobody"); - iname->location_in_hierarchy = landlord->location_in_hierarchy; -} - int Packaging::houseed_in_function(inter_name *iname) { if (iname == NULL) return FALSE; - if (iname->location_in_hierarchy == NULL) return FALSE; - if (iname->location_in_hierarchy->eventual_type == function_ptype) return TRUE; + package_request *P = InterNames::location(iname); + if (P == NULL) return FALSE; + if (P->eventual_type == function_ptype) return TRUE; return FALSE; } diff --git a/inform7/if-module/Chapter 4/Actions.w b/inform7/if-module/Chapter 4/Actions.w index f864ffeb4..f15ca845e 100644 --- a/inform7/if-module/Chapter 4/Actions.w +++ b/inform7/if-module/Chapter 4/Actions.w @@ -33,6 +33,7 @@ typedef struct action_name { int it_optional; /* noun optional when describing the second noun? */ int abbreviable; /* preposition optional when describing the second noun? */ int translated; + struct text_stream *translated_name; struct inter_name *an_base_iname; /* e.g., |Take| */ struct inter_name *an_iname; /* e.g., |##Take| */ struct inter_name *an_routine_iname; /* e.g., |TakeSub| */ @@ -231,9 +232,10 @@ action_name *PL::Actions::act_new(wording W, int implemented_by_I7) { an->it_optional = TRUE; an->abbreviable = FALSE; an->translated = FALSE; + an->translated_name = NULL; an->an_package = Hierarchy::local_package(ACTIONS_HAP); - an->an_base_iname = Hierarchy::make_iname_with_memo(ACTION_BASE_NAME_HL, an->an_package, W); + an->an_base_iname = NULL; an->use_verb_routine_in_I6_library = TRUE; an->check_rules = NULL; an->carry_out_rules = NULL; @@ -308,10 +310,7 @@ action_name *PL::Actions::act_new(wording W, int implemented_by_I7) { an->it_optional = FALSE; an2->it_optional = FALSE; } - if (make_ds) { - InterNames::override_action_base_iname(an->an_base_iname, I"Wait"); - PL::Actions::double_sharp(an); - } + return an; } @@ -413,7 +412,7 @@ int PL::Actions::abbreviable(action_name *an) { } text_stream *PL::Actions::identifier(action_name *an) { - return InterNames::to_text(an->an_base_iname); + return InterNames::to_text(PL::Actions::base_iname(an)); } action_name *PL::Actions::Wait(void) { @@ -421,9 +420,21 @@ action_name *PL::Actions::Wait(void) { return waiting_action; } +inter_name *PL::Actions::base_iname(action_name *an) { + if (an->an_base_iname == NULL) { + if (waiting_action == an) + an->an_base_iname = Hierarchy::make_iname_in(WAIT_HL, an->an_package); + else if (Str::len(an->translated_name) > 0) + an->an_base_iname = Hierarchy::make_iname_with_specific_name(TRANSLATED_BASE_NAME_HL, an->translated_name, an->an_package); + else + an->an_base_iname = Hierarchy::make_iname_with_memo(ACTION_BASE_NAME_HL, an->an_package, an->present_name); + } + return an->an_base_iname; +} + inter_name *PL::Actions::double_sharp(action_name *an) { if (an->an_iname == NULL) { - an->an_iname = Hierarchy::derive_iname_in(DOUBLE_SHARP_NAME_HL, an->an_base_iname, an->an_package); + an->an_iname = Hierarchy::derive_iname_in(DOUBLE_SHARP_NAME_HL, PL::Actions::base_iname(an), an->an_package); packaging_state save = Packaging::enter(an->an_package); Emit::ds_named_pseudo_numeric_constant(an->an_iname, K_value, (inter_t) an->allocation_id); InterNames::annotate_i(an->an_iname, ACTION_IANN, 1); @@ -434,7 +445,7 @@ inter_name *PL::Actions::double_sharp(action_name *an) { inter_name *PL::Actions::Sub(action_name *an) { if (an->an_routine_iname == NULL) - an->an_routine_iname = Hierarchy::derive_iname_in(PERFORM_FN_HL, an->an_base_iname, an->an_package); + an->an_routine_iname = Hierarchy::derive_iname_in(PERFORM_FN_HL, PL::Actions::base_iname(an), an->an_package); return an->an_routine_iname; } @@ -486,18 +497,18 @@ void PL::Actions::translates(wording W, parse_node *p2) { return; } if (an->translated) { - LOG("Tried action name %W = %n\n", W, an->an_base_iname); + LOG("Tried action name %W = %n\n", W, PL::Actions::base_iname(an)); Problems::Issue::sentence_problem(_p_(PM_TranslatesActionAlready), "this action has already been translated", "so there must be some duplication somewhere."); return; } + if (an->an_base_iname) internal_error("too late for action base name translation"); + an->translated = TRUE; - TEMPORARY_TEXT(TO); - WRITE_TO(TO, "%N", Wordings::first_wn(ParseTree::get_text(p2))); - InterNames::override_action_base_iname(an->an_base_iname, TO); - DISCARD_TEXT(TO); - LOGIF(ACTION_CREATIONS, "Translated action: $l as %n\n", an, an->an_base_iname); + an->translated_name = Str::new(); + WRITE_TO(an->translated_name, "%N", Wordings::first_wn(ParseTree::get_text(p2))); + LOGIF(ACTION_CREATIONS, "Translated action: $l as %n\n", an, PL::Actions::base_iname(an)); } int PL::Actions::get_stem_length(action_name *an) { diff --git a/inform7/index-module/Chapter 3/Documentation References.w b/inform7/index-module/Chapter 3/Documentation References.w index 6c0ddc20a..95a776dff 100644 --- a/inform7/index-module/Chapter 3/Documentation References.w +++ b/inform7/index-module/Chapter 3/Documentation References.w @@ -25,7 +25,7 @@ documentation. = typedef struct documentation_ref { - struct text_stream *symbol; /* Reference is by this piece of text */ + struct text_stream *doc_symbol; /* Reference is by this piece of text */ int section; /* HTML page number */ int used_already; /* Has this been used in a problem message already? */ int usage_count; /* For statistical purposes */ @@ -81,8 +81,8 @@ void Index::DocReferences::dref_new(parse_node *p) { } LOOP_THROUGH_WORDING(i, SW) { documentation_ref *dr = CREATE(documentation_ref); - dr->symbol = Str::new(); - WRITE_TO(dr->symbol, "%+W", Wordings::one_word(i)); + dr->doc_symbol = Str::new(); + WRITE_TO(dr->doc_symbol, "%+W", Wordings::one_word(i)); dr->section = Wordings::first_wn(RW); dr->used_already = FALSE; dr->usage_count = 0; @@ -106,7 +106,7 @@ extension (say |doc24|); if it does not exist, we return NULL. int Index::DocReferences::validate_if_possible(text_stream *temp) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, temp)) + if (Str::eq(dr->doc_symbol, temp)) return TRUE; return FALSE; } @@ -117,7 +117,7 @@ int Index::DocReferences::validate_if_possible(text_stream *temp) { wchar_t *Index::DocReferences::link_if_possible_once(text_stream *temp, wchar_t **chap, wchar_t **sec) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, temp)) { + if (Str::eq(dr->doc_symbol, temp)) { if (dr->used_already == FALSE) { wchar_t *leaf = Lexer::word_text(dr->section); *chap = dr->chapter_reference; @@ -164,7 +164,7 @@ void Index::DocReferences::doc_mark_used(text_stream *symb, int at_word) { if (Log::aspect_switched_on(PHRASE_USAGE_DA)) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) { - if (Str::eq(dr->symbol, symb)) { + if (Str::eq(dr->doc_symbol, symb)) { extension_file *loc = NULL; if (at_word >= 0) { source_file *pos = Lexer::file_of_origin(at_word); @@ -190,8 +190,8 @@ void Index::DocReferences::log_statistics(void) { LOGIF(PHRASE_USAGE, "The following shows how often each built-in phrase was used:\n"); documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::begins_with_wide_string(dr->symbol, L"ph")) - LOGIF(PHRASE_USAGE, "USAGE: %S %d %d %d\n", dr->symbol, + if (Str::begins_with_wide_string(dr->doc_symbol, L"ph")) + LOGIF(PHRASE_USAGE, "USAGE: %S %d %d %d\n", dr->doc_symbol, dr->usage_count, dr->sr_usage_count, dr->ext_usage_count); } @@ -314,7 +314,7 @@ and we need to search fairly seldom: documentation_ref *Index::DocReferences::name_to_dr(text_stream *fn) { documentation_ref *dr; LOOP_OVER(dr, documentation_ref) - if (Str::eq(dr->symbol, fn)) + if (Str::eq(dr->doc_symbol, fn)) return dr; @; return NULL; @@ -326,6 +326,6 @@ documentation_ref *Index::DocReferences::name_to_dr(text_stream *fn) { if (problem_count == 0) { LOG("Bad ref was <%s>. Known references are:\n", fn); LOOP_OVER(dr, documentation_ref) - LOG("%S = %+N\n", dr->symbol, dr->section); + LOG("%S = %+N\n", dr->doc_symbol, dr->section); internal_error("Bad index documentation reference"); }