- Home
- Inform7 Modules
- core
- Chapter 27: Bridge to Inter Module
- Compilation Units
To identify which parts of the source text come from which source (the main source text, the Standard Rules, or another extension).
-+
-
§1. Compilation modules. Inform is a language in which it is semantically relevant which source file the +
§1. Inform is a language in which it is semantically relevant which source file the source text is coming from: unlike, say, C, where #include allows files to include each other in arbitrary ways. In Inform, all source text comes from one of the following places: @@ -78,49 +78,44 @@ following places:
The Inter hierarchy also splits, with named modules representing each possibility -in (a) or (b) above. This section of code determines to which module any new +
The Inter hierarchy also splits, with named units representing each possibility +in (a) or (b) above. This section of code determines to which unit any new definition (of, say, a property or kind) belongs.
-compilation_module *source_text_module = NULL; the one for the main text -compilation_module *SR_module = NULL; the one for the Standard Rules - -compilation_module *Modules::SR(void) { - return SR_module; -} +compilation_unit *source_text_unit = NULL; the one for the main text
§2. We find these by performing a traverse of the parse tree, and looking for level-0 headings, which are the nodes from which these blocks of source text hang:
-void Modules::traverse_to_define(void) { - SyntaxTree::traverse(Task::syntax_tree(), Modules::look_for_cu); +void CompilationUnits::determine(void) { + SyntaxTree::traverse(Task::syntax_tree(), CompilationUnits::look_for_cu); } -void Modules::look_for_cu(parse_node *p) { +void CompilationUnits::look_for_cu(parse_node *p) { if (Node::get_type(p) == HEADING_NT) { heading *h = Headings::from_node(p); - if ((h) && (h->level == 0)) Modules::new(p); + if ((h) && (h->level == 0)) CompilationUnits::new(p); } } -compilation_module *Modules::new(parse_node *from) { +compilation_unit *CompilationUnits::new(parse_node *from) { source_location sl = Wordings::location(Node::get_text(from)); if (sl.file_of_origin == NULL) return NULL; inform_extension *owner = Extensions::corresponding_to( Lexer::file_of_origin(Wordings::first_wn(Node::get_text(from)))); - compilation_module *C = Packaging::new_cm(); + compilation_unit *C = Packaging::new_cu(); C->hanging_from = from; - Node::set_module(from, C); - Modules::propagate_downwards(from->down, C); + Node::set_unit(from, C); + CompilationUnits::propagate_downwards(from->down, C); TEMPORARY_TEXT(pname) - Compose a name for the module package this will lead to2.1; - C->inter_presence = Packaging::get_module(Emit::tree(), pname); + Compose a name for the unit package this will lead to2.1; + C->inter_presence = Packaging::get_unit(Emit::tree(), pname); DISCARD_TEXT(pname) if (owner) { @@ -133,16 +128,15 @@ level-0 headings, which are the nodes from which these blocks of source text han DISCARD_TEXT(V) } - if (Extensions::is_standard(owner)) SR_module = C; - if (owner == NULL) source_text_module = C; + if (owner == NULL) source_text_unit = C; return C; }
§2.1. Here we must find a unique name, valid as an Inter identifier: the code -compiled from the compilation module will go into a package of that name. +compiled from the compilation unit will go into a package of that name.
-Compose a name for the module package this will lead to2.1 = +
Compose a name for the unit package this will lead to2.1 =
@@ -159,51 +153,51 @@ compiled from the compilation module will go into a package of that name.
- This code is used in §2.
§3. We are eventually going to need to be able to look at a given node in the parse -tree and say which compilation module it belongs to. If there were a fast way +tree and say which compilation unit it belongs to. If there were a fast way to go up in the tree, that would be easy — we could simply run upward until we reach a level-0 heading. But the node links all run downwards. Instead, we'll -"mark" nodes in the tree, annotating them with the compilation module which owns +"mark" nodes in the tree, annotating them with the compilation unit which owns them. This is done by "propagating downwards", as follows.
-void Modules::propagate_downwards(parse_node *P, compilation_module *C) { +void CompilationUnits::propagate_downwards(parse_node *P, compilation_unit *C) { while (P) { - Node::set_module(P, C); - Modules::propagate_downwards(P->down, C); + Node::set_unit(P, C); + CompilationUnits::propagate_downwards(P->down, C); P = P->next; } }-
§5. As promised, then, given a parse node, we have to return its compilation module: +
§5. As promised, then, given a parse node, we have to return its compilation unit: but that's now easy, as we just have to read off the annotation made above —
-compilation_module *Modules::find(parse_node *from) { +compilation_unit *CompilationUnits::find(parse_node *from) { if (from == NULL) return NULL; - return Node::get_module(from); + return Node::get_unit(from); }-
§6. Current module. Inform has a concept of the "current module" it's working on, much as it has +
§6. Current unit. Inform has a concept of the "current unit" it's working on, much as it has a concept of "current sentence".
-compilation_module *current_CM = NULL; +compilation_unit *current_CM = NULL; -compilation_module *Modules::current(void) { +compilation_unit *CompilationUnits::current(void) { return current_CM; } -void Modules::set_current_to(compilation_module *CM) { +void CompilationUnits::set_current_to(compilation_unit *CM) { current_CM = CM; } -void Modules::set_current(parse_node *P) { - if (P) current_CM = Modules::find(P); +void CompilationUnits::set_current(parse_node *P) { + if (P) current_CM = CompilationUnits::find(P); else current_CM = NULL; }@@ -212,8 +206,8 @@ Packaging code.
-module_package *Modules::inter_presence(compilation_module *C) { - if (C == NULL) internal_error("no module"); +module_package *CompilationUnits::inter_presence(compilation_unit *C) { + if (C == NULL) internal_error("no unit"); return C->inter_presence; }diff --git a/docs/core-module/27-em.html b/docs/core-module/27-em.html index c042b8790..b475bf96d 100644 --- a/docs/core-module/27-em.html +++ b/docs/core-module/27-em.html @@ -78,7 +78,7 @@ function togglePopup(material_id) { inter_tree *I7_generation_tree = NULL; -inter_tree *Emit::tree(void) { +inter_tree *Emit::tree(void) { return I7_generation_tree; } @@ -89,9 +89,9 @@ function togglePopup(material_id) { I7_generation_tree = I; Packaging::incarnate(Site::veneer_request(I)); - Packaging::incarnate(Packaging::get_module(I, I"generic")->the_package); - Packaging::incarnate(Packaging::get_module(I, I"synoptic")->the_package); - Packaging::incarnate(Packaging::get_module(I, I"standard_rules")->the_package); + Packaging::incarnate(Packaging::get_unit(I, I"generic")->the_package); + Packaging::incarnate(Packaging::get_unit(I, I"synoptic")->the_package); + Packaging::incarnate(Packaging::get_unit(I, I"standard_rules")->the_package); Hierarchy::establish(I); diff --git a/docs/core-module/27-hr.html b/docs/core-module/27-hr.html index d8352bfc1..53b30c02a 100644 --- a/docs/core-module/27-hr.html +++ b/docs/core-module/27-hr.html @@ -1730,7 +1730,7 @@ function togglePopup(material_id) { Inter::Connectors::socket(Emit::tree(), ma_as, S); } -package_request *Hierarchy::package(compilation_module *C, int hap_id) { +package_request *Hierarchy::package(compilation_unit *C, int hap_id) { return HierarchyLocations::attach_new_package(Emit::tree(), C, NULL, hap_id); } @@ -1739,7 +1739,7 @@ function togglePopup(material_id) { } package_request *Hierarchy::local_package(int hap_id) { - return HierarchyLocations::attach_new_package(Emit::tree(), Modules::find(current_sentence), NULL, hap_id); + return HierarchyLocations::attach_new_package(Emit::tree(), CompilationUnits::find(current_sentence), NULL, hap_id); } package_request *Hierarchy::package_in_enclosure(int hap_id) { @@ -1762,7 +1762,7 @@ function togglePopup(material_id) { return HierarchyLocations::find_in_package(Emit::tree(), id, P, EMPTY_WORDING, derive_from, -1, NULL); } -inter_name *Hierarchy::make_localised_iname_in(int id, package_request *P, compilation_module *C) { +inter_name *Hierarchy::make_localised_iname_in(int id, package_request *P, compilation_unit *C) { return HierarchyLocations::find_in_package(Emit::tree(), id, P, EMPTY_WORDING, NULL, -1, NULL); } @@ -1780,7 +1780,7 @@ function togglePopup(material_id) { return HierarchyLocations::package_in_package(Emit::tree(), id, P); } -void Hierarchy::markup(package_request *R, int hm_id, text_stream *value) { +void Hierarchy::markup(package_request *R, int hm_id, text_stream *value) { HierarchyLocations::markup(Emit::tree(), R, hm_id, value); } diff --git a/docs/core-module/3-bv.html b/docs/core-module/3-bv.html index eb2907d72..ff392c7ae 100644 --- a/docs/core-module/3-bv.html +++ b/docs/core-module/3-bv.html @@ -87,7 +87,7 @@ means? We break this circularity by hard-wiring it, as follows.
-void BootVerbs::bootstrap(void) { +void BootVerbs::make_built_in(void) { verb *to_mean; special_meaning_holder *meaning_of_mean; Create the special meanings1.3; diff --git a/docs/core-module/3-cs.html b/docs/core-module/3-cs.html index d1e51d4ac..717c555f8 100644 --- a/docs/core-module/3-cs.html +++ b/docs/core-module/3-cs.html @@ -86,7 +86,7 @@ on, placing them in a subtree.int classification_traverse_done = FALSE; -void Classifying::traverse(void) { +void Classifying::traverse(void) { SyntaxTree::traverse(Task::syntax_tree(), Classifying::visit); classification_traverse_done = TRUE; } diff --git a/docs/core-module/4-am.html b/docs/core-module/4-am.html index 311e8d792..1f2125278 100644 --- a/docs/core-module/4-am.html +++ b/docs/core-module/4-am.html @@ -259,7 +259,7 @@ adjectival phrase in sorted order, so:void Adjectives::Meanings::initialise(adjective *adj) { - adj->adjective_compilation.aph_package = Hierarchy::package(Modules::current(), ADJECTIVES_HAP); + adj->adjective_compilation.aph_package = Hierarchy::package(CompilationUnits::current(), ADJECTIVES_HAP); adj->adjective_compilation.aph_iname = Hierarchy::make_iname_in(ADJECTIVE_HL, adj->adjective_compilation.aph_package); } @@ -1579,7 +1579,7 @@ prefaced "(of a rulebook)", "(of an activity)", and so on.-void Adjectives::Meanings::agreements(void) { +void Adjectives::Meanings::agreements(void) { if (Projects::get_language_of_play(Task::project()) == DefaultLanguage::get(NULL)) return; adjective *aph; LOOP_OVER(aph, adjective) { diff --git a/docs/core-module/5-ins.html b/docs/core-module/5-ins.html index 7db89be4c..733f9dde1 100644 --- a/docs/core-module/5-ins.html +++ b/docs/core-module/5-ins.html @@ -813,7 +813,7 @@ Note that only instances, not kinds, appear.-void Instances::place_objects_in_definition_sequence(void) { +void Instances::place_objects_in_definition_sequence(void) { Instances::begin_sequencing_objects(); instance *I; LOOP_OVER_OBJECT_INSTANCES(I) diff --git a/docs/core-module/5-lp.html b/docs/core-module/5-lp.html index 3c990e242..6372ca6b3 100644 --- a/docs/core-module/5-lp.html +++ b/docs/core-module/5-lp.html @@ -3383,7 +3383,7 @@ are declared.diff --git a/docs/core-module/5-nv.html b/docs/core-module/5-nv.html index 145aa8fed..ebc0e33d8 100644 --- a/docs/core-module/5-nv.html +++ b/docs/core-module/5-nv.html @@ -515,7 +515,7 @@ there's very little to say.-void LiteralPatterns::define_named_phrases(void) { +void LiteralPatterns::define_named_phrases(void) { literal_pattern_name *lpn; LOOP_OVER(lpn, literal_pattern_name) lpn->lpn_compiled_already = FALSE; @@ -3395,7 +3395,7 @@ are declared. Compile the printing phrase for this and perhaps subsequent LPs40.1; } } - Sentences::RuleSubtrees::register_recently_lexed_phrases(); + RuleSubtrees::register_recently_lexed_phrases(); }§40.1. These text substitutions correspond exactly neither to the LPs nor to the @@ -3458,7 +3458,7 @@ the LPs under each named possibility. Kinds::Textual::write(TEMP, K); Define phrases to convert from a packed value to individual parts41.1; Define a phrase to convert from numerical parts to a packed value41.2; - Sentences::RuleSubtrees::register_recently_lexed_phrases(); + RuleSubtrees::register_recently_lexed_phrases(); DISCARD_TEXT(TEMP) }
inter_name *NonlocalVariables::iname(nonlocal_variable *nlv) { if (nlv->nlv_iname == NULL) { - package_request *R = Hierarchy::package(Modules::find(nlv->nlv_created_at), VARIABLES_HAP); + package_request *R = Hierarchy::package(CompilationUnits::find(nlv->nlv_created_at), VARIABLES_HAP); Hierarchy::markup_wording(R, VARIABLE_NAME_HMD, nlv->name); nlv->nlv_iname = Hierarchy::make_iname_with_memo(VARIABLE_HL, R, nlv->name); } diff --git a/docs/core-module/5-un.html b/docs/core-module/5-un.html index 65cf97db9..b13b36546 100644 --- a/docs/core-module/5-un.html +++ b/docs/core-module/5-un.html @@ -140,7 +140,7 @@ instance, the Standard Rules want the player-character object to be called-void UseNouns::name_all(void) { +void UseNouns::name_all(void) { kind *K; LOOP_OVER_BASE_KINDS(K) Kinds::RunTime::assure_iname_exists(K); diff --git a/docs/core-module/6-bp.html b/docs/core-module/6-bp.html index 50c48863b..30b26a7d8 100644 --- a/docs/core-module/6-bp.html +++ b/docs/core-module/6-bp.html @@ -776,7 +776,7 @@ would always be NULL package_request *BinaryPredicates::package(binary_predicate *bp) { if (bp == NULL) internal_error("null bp"); if (bp->bp_package == NULL) - bp->bp_package = Hierarchy::package(Modules::find(bp->bp_created_at), RELATIONS_HAP); + bp->bp_package = Hierarchy::package(CompilationUnits::find(bp->bp_created_at), RELATIONS_HAP); return bp->bp_package; }@@ -1139,7 +1139,7 @@ above. This happens very early in compilation.§46. Other property-based relations.
-void BinaryPredicates::make_built_in_further(void) { +void BinaryPredicates::make_built_in_further(void) { Calculus::Equality::REL_create_second_stock(); Properties::ProvisionRelation::REL_create_second_stock(); Relations::Universal::REL_create_second_stock(); diff --git a/docs/core-module/6-nv.html b/docs/core-module/6-nv.html index b889cadbe..74d9fd6dc 100644 --- a/docs/core-module/6-nv.html +++ b/docs/core-module/6-nv.html @@ -112,7 +112,7 @@ implementation of it. But in practice they should never be reached. if (V == NULL) internal_error("no verb identity"); if (V->verb_compilation.verb_package == NULL) V->verb_compilation.verb_package = - Hierarchy::package(Modules::find(where), VERBS_HAP); + Hierarchy::package(CompilationUnits::find(where), VERBS_HAP); return V->verb_compilation.verb_package; } @@ -827,7 +827,7 @@ foreign verbs (4). Hierarchy::make_available(Emit::tree(), CV_MEANING_iname); } -void NewVerbs::ConjugateVerb(void) { +void NewVerbs::ConjugateVerb(void) { verb_conjugation *vc; LOOP_OVER(vc, verb_conjugation) Compile ConjugateVerb routine17.1; diff --git a/docs/core-module/6-rlt.html b/docs/core-module/6-rlt.html index c0680829c..c92c1b715 100644 --- a/docs/core-module/6-rlt.html +++ b/docs/core-module/6-rlt.html @@ -1068,7 +1068,7 @@ combinations. return iname; } -void Relations::compile_defined_relation_constants(void) { +void Relations::compile_defined_relation_constants(void) { RELS_SYMMETRIC_iname = Relations::compile_defined_relation_constant(RELS_SYMMETRIC_HL, 0x8000); RELS_EQUIVALENCE_iname = Relations::compile_defined_relation_constant(RELS_EQUIVALENCE_HL, 0x4000); RELS_X_UNIQUE_iname = Relations::compile_defined_relation_constant(RELS_X_UNIQUE_HL, 0x2000); @@ -2056,7 +2056,7 @@ between numbers and texts.§17. Support for the RELATIONS command.
-void Relations::IterateRelations(void) { +void Relations::IterateRelations(void) { inter_name *iname = Hierarchy::find(ITERATERELATIONS_HL); packaging_state save = Routines::begin(iname); inter_symbol *callback_s = LocalVariables::add_named_call_as_symbol(I"callback"); @@ -2678,7 +2678,7 @@ whether or not $R(t_0<-void Relations::compile_defined_relations(void) { +void Relations::compile_defined_relations(void) { Relations::compile_relation_records(); binary_predicate *bp; LOOP_OVER(bp, binary_predicate) diff --git a/docs/core-module/7-hdn.html b/docs/core-module/7-hdn.html index 533ffc0bb..d11e6c46c 100644 --- a/docs/core-module/7-hdn.html +++ b/docs/core-module/7-hdn.html @@ -257,7 +257,7 @@ and has no "level" or "indentation" as such.-void Sentences::Headings::make_the_tree(void) { +void Sentences::Headings::make_the_tree(void) { Headings::assemble_tree(Task::syntax_tree()); } @@ -674,7 +674,7 @@ Version", contains the Inform build number in its usual form: "4Q34", for instan-void Sentences::Headings::write_as_xml(void) { +void Sentences::Headings::write_as_xml(void) { text_stream xf_struct; text_stream *xf = &xf_struct; filename *F = Task::xml_headings_file(); if (STREAM_OPEN_TO_FILE(xf, F, UTF8_ENC) == FALSE) diff --git a/docs/core-module/7-ptu.html b/docs/core-module/7-ptu.html index b5c0edfee..9b7f871ac 100644 --- a/docs/core-module/7-ptu.html +++ b/docs/core-module/7-ptu.html @@ -245,7 +245,7 @@ also makes it easier for us to manipulate the results. Annotations::allow(HEADING_NT, interpretation_of_subject_ANNOT); Annotations::allow(HEADING_NT, suppress_heading_dependencies_ANNOT); Annotations::allow(HEADING_NT, implied_heading_ANNOT); - Annotations::allow_for_category(L1_NCAT, module_ANNOT); + Annotations::allow_for_category(L1_NCAT, unit_ANNOT); Annotations::allow_for_category(L2_NCAT, clears_pronouns_ANNOT); Annotations::allow_for_category(L2_NCAT, interpretation_of_subject_ANNOT); @@ -254,12 +254,12 @@ also makes it easier for us to manipulate the results. Annotations::allow(SENTENCE_NT, implicit_in_creation_of_ANNOT); Annotations::allow(SENTENCE_NT, implicitness_count_ANNOT); Annotations::allow(SENTENCE_NT, you_can_ignore_ANNOT); - Annotations::allow_for_category(L2_NCAT, module_ANNOT); + Annotations::allow_for_category(L2_NCAT, unit_ANNOT); LOOP_OVER_ENUMERATED_NTS(t) if (NodeType::has_flag(t, ASSERT_NFLAG)) Annotations::allow(t, resolved_ANNOT); - Annotations::allow_for_category(L3_NCAT, module_ANNOT); + Annotations::allow_for_category(L3_NCAT, unit_ANNOT); Annotations::allow_for_category(L3_NCAT, creation_proposition_ANNOT); Annotations::allow_for_category(L3_NCAT, evaluation_ANNOT); Annotations::allow_for_category(L3_NCAT, subject_ANNOT); @@ -309,7 +309,7 @@ also makes it easier for us to manipulate the results. Annotations::allow_for_category(L4_NCAT, token_to_be_parsed_against_ANNOT); Annotations::allow_for_category(L4_NCAT, verb_problem_issued_ANNOT); Annotations::allow_for_category(L4_NCAT, problem_falls_under_ANNOT); - Annotations::allow_for_category(L4_NCAT, module_ANNOT); + Annotations::allow_for_category(L4_NCAT, unit_ANNOT); Annotations::allow(INVOCATION_LIST_NT, from_text_substitution_ANNOT); Annotations::allow(INVOCATION_LIST_SAY_NT, suppress_newlines_ANNOT); Annotations::allow(INVOCATION_NT, epistemological_status_ANNOT); @@ -553,7 +553,7 @@ be such that their head nodes each pass this test:-void ParseTreeUsage::verify(void) { +void ParseTreeUsage::verify(void) { VerifyTree::verify_integrity(Task::syntax_tree()); VerifyTree::verify_structure(Task::syntax_tree()); } diff --git a/docs/core-module/7-rs.html b/docs/core-module/7-rs.html index 49a355dbd..cb48009fe 100644 --- a/docs/core-module/7-rs.html +++ b/docs/core-module/7-rs.html @@ -103,17 +103,17 @@ on childless nodes, it cannot ever act on the same node twice.-void Sentences::RuleSubtrees::register_recently_lexed_phrases(void) { +void RuleSubtrees::register_recently_lexed_phrases(void) { if (problem_count > 0) return; for then the tree is perhaps broken anyway - SyntaxTree::traverse(Task::syntax_tree(), Sentences::RuleSubtrees::demote_command_nodes); - SyntaxTree::traverse(Task::syntax_tree(), Sentences::RuleSubtrees::detect_loose_command_nodes); + SyntaxTree::traverse(Task::syntax_tree(), RuleSubtrees::demote_command_nodes); + SyntaxTree::traverse(Task::syntax_tree(), RuleSubtrees::detect_loose_command_nodes); }§4. Command nodes are demoted to be children of routine nodes:
-void Sentences::RuleSubtrees::demote_command_nodes(parse_node *p) { +void RuleSubtrees::demote_command_nodes(parse_node *p) { if ((Node::get_type(p) == RULE_NT) && (p->down == NULL)) { parse_node *end_def = p; while ((end_def->next) && (Node::get_type(end_def->next) == INVOCATION_LIST_NT)) @@ -123,7 +123,7 @@ on childless nodes, it cannot ever act on the same node twice. p->down = p->next; p->next = end_def->next; end_def->next = NULL; - Sentences::RuleSubtrees::parse_routine_structure(p); + RuleSubtrees::parse_routine_structure(p); } }@@ -131,7 +131,7 @@ on childless nodes, it cannot ever act on the same node twice.-void Sentences::RuleSubtrees::detect_loose_command_nodes(parse_node *p) { +void RuleSubtrees::detect_loose_command_nodes(parse_node *p) { if (Node::get_type(p) == INVOCATION_LIST_NT) internal_error("loose COMMAND node outside of rule definition"); } @@ -156,7 +156,7 @@ indentation difficult to manage with screen-readers.-void Sentences::RuleSubtrees::parse_routine_structure(parse_node *routine_node) { +void RuleSubtrees::parse_routine_structure(parse_node *routine_node) { int initial_problem_count = problem_count; parse_node *uses_colon_syntax = NULL; @@ -410,7 +410,7 @@ to break this up. Deal with an immediately following otherwise node, if there is one6.5.1.1; if (uses_colon_syntax == FALSE) { - last_node_of_if_construction->next = Sentences::RuleSubtrees::end_node(p); + last_node_of_if_construction->next = RuleSubtrees::end_node(p); last_node_of_if_construction->next->next = rest_of_routine; } else { last_node_of_if_construction->next = rest_of_routine; @@ -711,7 +711,7 @@ indentation implicitly requires it.- parse_node *implicit_end = Sentences::RuleSubtrees::end_node(opening); + parse_node *implicit_end = RuleSubtrees::end_node(opening); implicit_end->next = prev->next; prev->next = implicit_end; prev = implicit_end;@@ -1030,7 +1030,7 @@ where we look for such mistakes.int n = problem_count; - Sentences::RuleSubtrees::police_code_block(routine_node->down, NULL); + RuleSubtrees::police_code_block(routine_node->down, NULL); if (problem_count > n) LOG("Local parse tree: $T\n", routine_node);@@ -1038,7 +1038,7 @@ where we look for such mistakes.
- This code is used in §6.
-void Sentences::RuleSubtrees::police_code_block(parse_node *block, control_structure_phrase *context) { +void RuleSubtrees::police_code_block(parse_node *block, control_structure_phrase *context) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { current_sentence = p; @@ -1068,7 +1068,7 @@ where we look for such mistakes. } } - if (p->down) Sentences::RuleSubtrees::police_code_block(p, csp); + if (p->down) RuleSubtrees::police_code_block(p, csp); } }@@ -1214,7 +1214,7 @@ can now become "otherwise: if whatever: ...".int n = problem_count; - Sentences::RuleSubtrees::purge_otherwise_if(routine_node->down); + RuleSubtrees::purge_otherwise_if(routine_node->down); if (problem_count > n) LOG("Local parse tree: $T\n", routine_node);@@ -1225,7 +1225,7 @@ to issue good problem messages for failures to use "otherwise if" correctly.
- This code is used in §6.
-void Sentences::RuleSubtrees::purge_otherwise_if(parse_node *block) { +void RuleSubtrees::purge_otherwise_if(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { if (Node::get_control_structure_used(p) == otherwise_if_CSP) { parse_node *former_contents = p->down; @@ -1252,7 +1252,7 @@ to issue good problem messages for failures to use "otherwise if" correctly. any further "otherwise if" or "otherwise" nodes after p follow p->down->next = former_successors; } - if (p->down) Sentences::RuleSubtrees::purge_otherwise_if(p); + if (p->down) RuleSubtrees::purge_otherwise_if(p); } }@@ -1266,18 +1266,18 @@ We remove them.- Sentences::RuleSubtrees::purge_end_markers(routine_node->down); + RuleSubtrees::purge_end_markers(routine_node->down);
- This code is used in §6.
-void Sentences::RuleSubtrees::purge_end_markers(parse_node *block) { +void RuleSubtrees::purge_end_markers(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { if (Node::get_end_control_structure_used(p)) { if (prev_p) prev_p->next = p->next; else block->down = p->next; } - if (p->down) Sentences::RuleSubtrees::purge_end_markers(p); + if (p->down) RuleSubtrees::purge_end_markers(p); } }@@ -1289,18 +1289,18 @@ can now be removed, too.- Sentences::RuleSubtrees::purge_begin_markers(routine_node->down); + RuleSubtrees::purge_begin_markers(routine_node->down);
- This code is used in §6.
-void Sentences::RuleSubtrees::purge_begin_markers(parse_node *block) { +void RuleSubtrees::purge_begin_markers(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { if (Node::get_control_structure_used(p)) if (<phrase-beginning-block>(Node::get_text(p))) Node::set_text(p, GET_RW(<phrase-beginning-block>, 1)); - if (p->down) Sentences::RuleSubtrees::purge_begin_markers(p); + if (p->down) RuleSubtrees::purge_begin_markers(p); } }@@ -1316,13 +1316,13 @@ annotations to them.- Sentences::RuleSubtrees::insert_cb_nodes(routine_node->down); + RuleSubtrees::insert_cb_nodes(routine_node->down);
- This code is used in §6.
-void Sentences::RuleSubtrees::insert_cb_nodes(parse_node *block) { +void RuleSubtrees::insert_cb_nodes(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { if (ControlStructures::opens_block(Node::get_control_structure_used(p))) { parse_node *blank_cb_node = Node::new(CODE_BLOCK_NT); @@ -1336,7 +1336,7 @@ annotations to them. if (prev_p) prev_p->next = blank_cb_node; else block->down = blank_cb_node; p = blank_cb_node; } - if (p->down) Sentences::RuleSubtrees::insert_cb_nodes(p); + if (p->down) RuleSubtrees::insert_cb_nodes(p); } }@@ -1347,13 +1347,13 @@ annotations to them.- Sentences::RuleSubtrees::read_instead_markers(routine_node->down); + RuleSubtrees::read_instead_markers(routine_node->down);
- This code is used in §6.
-void Sentences::RuleSubtrees::read_instead_markers(parse_node *block) { +void RuleSubtrees::read_instead_markers(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { if (<instead-keyword>(Node::get_text(p))) { Node::set_text(p, GET_RW(<instead-keyword>, 1)); @@ -1362,7 +1362,7 @@ annotations to them. instead_node->next = p->next; p->next = instead_node; } - if (p->down) Sentences::RuleSubtrees::read_instead_markers(p); + if (p->down) RuleSubtrees::read_instead_markers(p); } }@@ -1373,13 +1373,13 @@ annotations to them.- Sentences::RuleSubtrees::break_up_says(routine_node->down); + RuleSubtrees::break_up_says(routine_node->down);
- This code is used in §6.
-void Sentences::RuleSubtrees::break_up_says(parse_node *block) { +void RuleSubtrees::break_up_says(parse_node *block) { for (parse_node *p = block->down, *prev_p = NULL; p; prev_p = p, p = p->next) { int sf = NO_SIGF; wording W = Node::get_text(p); @@ -1397,7 +1397,7 @@ annotations to them. if (prev_p) prev_p->next = blank_cb_node; else block->down = blank_cb_node; current_sentence = p; - Sentences::RuleSubtrees::unroll_says(blank_cb_node, W, 0); + RuleSubtrees::unroll_says(blank_cb_node, W, 0); p = blank_cb_node; break; } @@ -1409,11 +1409,11 @@ annotations to them. break; } } - if (p->down) Sentences::RuleSubtrees::break_up_says(p); + if (p->down) RuleSubtrees::break_up_says(p); } } -void Sentences::RuleSubtrees::unroll_says(parse_node *cb_node, wording W, int depth) { +void RuleSubtrees::unroll_says(parse_node *cb_node, wording W, int depth) { while (<phrase-with-comma-notation>(W)) { wording AW = GET_RW(<phrase-with-comma-notation>, 1); wording BW = GET_RW(<phrase-with-comma-notation>, 2); @@ -1434,7 +1434,7 @@ annotations to them. Check that substitution does not contain suspicious punctuation8.1.1; wording A = Feeds::feed_C_string_expanding_strings(p); if (<verify-expanded-text-substitution>(A)) - Sentences::RuleSubtrees::unroll_says(cb_node, A, depth+1); + RuleSubtrees::unroll_says(cb_node, A, depth+1); } else { parse_node *say_term_node = Node::new(INVOCATION_LIST_SAY_NT); Node::set_text(say_term_node, W); @@ -1602,7 +1602,7 @@ match a given begin node.- To identify which parts of the source text come from which source (the main source text, the Standard Rules, or another extension).-parse_node *Sentences::RuleSubtrees::end_node(parse_node *opening) { +parse_node *RuleSubtrees::end_node(parse_node *opening) { parse_node *implicit_end = Node::new(INVOCATION_LIST_NT); Node::set_end_control_structure_used(implicit_end, Node::get_control_structure_used(opening)); diff --git a/docs/core-module/8-ef.html b/docs/core-module/8-ef.html index c9a1358d3..85cd7016d 100644 --- a/docs/core-module/8-ef.html +++ b/docs/core-module/8-ef.html @@ -228,7 +228,7 @@ feelings of modesty.-void Extensions::Files::ShowExtensionVersions_routine(void) { +void Extensions::Files::ShowExtensionVersions_routine(void) { inter_name *iname = Hierarchy::find(SHOWEXTENSIONVERSIONS_HL); packaging_state save = Routines::begin(iname); inform_extension *E; diff --git a/docs/core-module/9-tfa.html b/docs/core-module/9-tfa.html index 88da70272..ef0682048 100644 --- a/docs/core-module/9-tfa.html +++ b/docs/core-module/9-tfa.html @@ -176,10 +176,10 @@ we don't bother to print details of the closing int sentence_handlers_initialised = FALSE; parse_node *assembly_position = NULL; where assembled sentences are added -void Assertions::Traverse::traverse1(void) { +void Assertions::Traverse::traverse1(void) { Assertions::Traverse::traverse(1); } -void Assertions::Traverse::traverse2(void) { +void Assertions::Traverse::traverse2(void) { Assertions::Traverse::traverse(2); } void Assertions::Traverse::traverse(int pass) { @@ -240,12 +240,12 @@ artificially to run through those sentences.void Assertions::Traverse::visit(parse_node *p, parse_node **last) { assembly_position = current_sentence; - compilation_module *cm = Modules::current(); - Modules::set_current(p); + compilation_unit *cm = CompilationUnits::current(); + CompilationUnits::set_current(p); Take a sceptical look at WITH nodes in the light of subsequent knowledge7.2.1; *last = p; Deal with an individual sentence7.2.2; - Modules::set_current_to(cm); + CompilationUnits::set_current_to(cm); }§7.3. If this hasn't already been done: diff --git a/docs/core-module/index.html b/docs/core-module/index.html index 74fc0ecb3..5ec5277d6 100644 --- a/docs/core-module/index.html +++ b/docs/core-module/index.html @@ -1041,7 +1041,7 @@
- + Compilation Units
-void PL::Backdrops::index_object_further(OUTPUT_STREAM, instance *loc, int depth, +void PL::Backdrops::index_object_further(OUTPUT_STREAM, instance *loc, int depth, int details, int how) { int discoveries = 0; instance *bd; diff --git a/docs/if-module/3-em.html b/docs/if-module/3-em.html index 2d05d14b1..b5a6c36a8 100644 --- a/docs/if-module/3-em.html +++ b/docs/if-module/3-em.html @@ -284,7 +284,7 @@ If all are null, then the global scope is used. void PL::EPSMap::put_mp(wchar_t *name, map_parameter_scope *scope, instance *scope_I, kind *scope_k, wchar_t *put_string, int put_integer) { if (scope_I) { - if (PL::Spatial::object_is_a_room(scope_I)) + if (PL::Spatial::object_is_a_room(scope_I)) scope = PL::EPSMap::scope_for_single_room(scope_I); else if (PL::Regions::object_is_a_region(scope_I)) { instance *rm; @@ -712,12 +712,12 @@ the following: instance *I2 = <<instance:y>>; int exit = PF_I(map, <<instance:dir>>)->direction_index; - if ((I == NULL) || (PL::Spatial::object_is_a_room(I) == FALSE)) { + if ((I == NULL) || (PL::Spatial::object_is_a_room(I) == FALSE)) { if (pass == 1) StandardProblems::map_problem(_p_(PM_MapFromNonRoom), p, "The first-named thing must be a room (beware ambiguities!)."); return; } - if ((I2 == NULL) || (PL::Spatial::object_is_a_room(I2) == FALSE)) { + if ((I2 == NULL) || (PL::Spatial::object_is_a_room(I2) == FALSE)) { if (pass == 1) StandardProblems::map_problem(_p_(PM_MapToNonRoom), p, "The second-named thing must be a room (beware ambiguities!)."); return; @@ -862,7 +862,7 @@ the following: } else bad_scope = TRUE; break; case INSTANCE_MAP_SCOPE: - if ((PL::Spatial::object_is_a_room(<<instance:iscope>>)) || + if ((PL::Spatial::object_is_a_room(<<instance:iscope>>)) || (PL::Regions::object_is_a_region(<<instance:iscope>>))) scope_I = <<instance:iscope>>; if (scope_I) { @@ -1220,7 +1220,7 @@ rectangle around the whole thing... LOOP_OVER_STORY_DIRECTIONS(dir) { instance *T = PL::SpatialMap::room_exit(R, dir, NULL); int exit = story_dir_to_page_dir[dir]; - if (PL::Spatial::object_is_a_room(T)) + if (PL::Spatial::object_is_a_room(T)) Draw a single map connection as an EPS arrow26.6.1; } PL::EPSMap::EPS_compile_line_width_unsetting(OUT); diff --git a/docs/if-module/3-rgn.html b/docs/if-module/3-rgn.html index aa6ae05e8..c4304a768 100644 --- a/docs/if-module/3-rgn.html +++ b/docs/if-module/3-rgn.html @@ -106,6 +106,7 @@ following minimal structure, though it will only be relevant for instances ofvoid PL::Regions::start(void) { + PLUGIN_REGISTER(PLUGIN_CREATE_INFERENCES, PL::Regions::create_inference_subjects); PLUGIN_REGISTER(PLUGIN_NEW_BASE_KIND_NOTIFY, PL::Regions::regions_new_base_kind_notify); PLUGIN_REGISTER(PLUGIN_SET_SUBKIND_NOTIFY, PL::Regions::regions_set_subkind_notify); PLUGIN_REGISTER(PLUGIN_NEW_SUBJECT_NOTIFY, PL::Regions::regions_new_subject_notify); @@ -116,6 +117,9 @@ following minimal structure, though it will only be relevant for instances of PLUGIN_REGISTER(PLUGIN_INTERVENE_IN_ASSERTION, PL::Regions::regions_intervene_in_assertion); PLUGIN_REGISTER(PLUGIN_NAME_TO_EARLY_INFS, PL::Regions::regions_name_to_early_infs); PLUGIN_REGISTER(PLUGIN_ADD_TO_WORLD_INDEX, PL::Regions::regions_add_to_World_index); +} + +void PL::Regions::create_inference_subjects(void) { infs_region = InferenceSubjects::new(global_constants, FUND_SUB, NULL_GENERAL_POINTER, LIKELY_CE); } @@ -179,7 +183,7 @@ there is no need to translate this to other languages.)-int PL::Regions::object_is_a_region(instance *I) { +int PL::Regions::object_is_a_region(instance *I) { if ((Plugins::Manage::plugged_in(regions_plugin)) && (K_region) && (I) && (Instances::of_kind(I, K_region))) return TRUE; return FALSE; @@ -200,8 +204,8 @@ domains.) if ((r1) && (reg2)) return 1; if ((reg1) && (r2)) return -1; if ((reg1) && (reg2)) { - if (PL::Spatial::encloses(I1, I2)) return 1; - if (PL::Spatial::encloses(I2, I1)) return -1; + if (PL::Spatial::encloses(I1, I2)) return 1; + if (PL::Spatial::encloses(I2, I1)) return -1; } return 0; } @@ -387,8 +391,8 @@ region is either the next broadest region containing it, or else instance *PL::Regions::enclosing(instance *reg) { instance *P = NULL; - if (PL::Spatial::object_is_a_room(reg)) P = PF_I(regions, reg)->in_region; - if (PL::Regions::object_is_a_region(reg)) P = PL::Spatial::progenitor(reg); + if (PL::Spatial::object_is_a_room(reg)) P = PF_I(regions, reg)->in_region; + if (PL::Regions::object_is_a_region(reg)) P = PL::Spatial::progenitor(reg); if (PL::Regions::object_is_a_region(P) == FALSE) return NULL; return P; } diff --git a/docs/if-module/3-scn.html b/docs/if-module/3-scn.html index 4e35448eb..121f30874 100644 --- a/docs/if-module/3-scn.html +++ b/docs/if-module/3-scn.html @@ -391,7 +391,7 @@ ends merrily" and "when the Banquet Entertainment ends merrily". sc->allocation_id, end); Feeds::feed_text_expanding_strings(i6_code); Sentences::make_node(Task::syntax_tree(), Feeds::end(id), '.'); - Sentences::RuleSubtrees::register_recently_lexed_phrases(); + RuleSubtrees::register_recently_lexed_phrases(); DISCARD_TEXT(i6_code)
- This code is used in §15.
- Home
- Inform7 Modules
- if
- Chapter 3: Space and Time
- Spatial Model
A plugin which constructs the fundamental spatial model used by IF, to represent containment, support, carrying, wearing, and incorporation.
-- §1. Definitions
- §7. Initialisation
- §10. Special inferences
- §11. Special kinds
- §17. Special properties
- §19. Default appearances
- §20. Composite noun-quantifiers
- §22. Nowhere
- §25. Here
- §28. Completing the model, stages I and II
- §34. Completing the model, stages III and IV
+
- §1. Definitions
- §7. Initialisation
- §11. Special inferences
- §12. Special kinds
- §18. Special properties
- §20. Default appearances
- §21. Composite noun-quantifiers
- §23. Nowhere
- §26. Here
- §29. Completing the model, stages I and II
- §35. Completing the model, stages III and IV
@@ -168,25 +168,25 @@ timing issue to get around (see below).
void PL::Spatial::start(void) { - PLUGIN_REGISTER(PLUGIN_NEW_BASE_KIND_NOTIFY, PL::Spatial::spatial_new_base_kind_notify); - PLUGIN_REGISTER(PLUGIN_ACT_ON_SPECIAL_NPS, PL::Spatial::spatial_act_on_special_NPs); - PLUGIN_REGISTER(PLUGIN_COMPLETE_MODEL, PL::Spatial::IF_complete_model); - PLUGIN_REGISTER(PLUGIN_DEFAULT_APPEARANCE, PL::Spatial::spatial_default_appearance); - PLUGIN_REGISTER(PLUGIN_INFERENCES_CONTRADICT, PL::Spatial::spatial_inferences_contradict); - PLUGIN_REGISTER(PLUGIN_EXPLAIN_CONTRADICTION, PL::Spatial::spatial_explain_contradiction); - PLUGIN_REGISTER(PLUGIN_LOG_INFERENCE_TYPE, PL::Spatial::spatial_log_inference_type); - PLUGIN_REGISTER(PLUGIN_NAME_TO_EARLY_INFS, PL::Spatial::spatial_name_to_early_infs); - PLUGIN_REGISTER(PLUGIN_NEW_SUBJECT_NOTIFY, PL::Spatial::spatial_new_subject_notify); - PLUGIN_REGISTER(PLUGIN_NEW_PROPERTY_NOTIFY, PL::Spatial::spatial_new_property_notify); - PLUGIN_REGISTER(PLUGIN_PARSE_COMPOSITE_NQS, PL::Spatial::spatial_parse_composite_NQs); - PLUGIN_REGISTER(PLUGIN_SET_KIND_NOTIFY, PL::Spatial::spatial_set_kind_notify); - PLUGIN_REGISTER(PLUGIN_SET_SUBKIND_NOTIFY, PL::Spatial::spatial_set_subkind_notify); - PLUGIN_REGISTER(PLUGIN_ADD_TO_WORLD_INDEX, PL::Spatial::spatial_add_to_World_index); - PLUGIN_REGISTER(PLUGIN_INTERVENE_IN_ASSERTION, PL::Spatial::spatial_intervene_in_assertion); - Create early inference subjects7.1; + PLUGIN_REGISTER(PLUGIN_CREATE_INFERENCES, PL::Spatial::create_inference_subjects); + PLUGIN_REGISTER(PLUGIN_NEW_BASE_KIND_NOTIFY, PL::Spatial::spatial_new_base_kind_notify); + PLUGIN_REGISTER(PLUGIN_ACT_ON_SPECIAL_NPS, PL::Spatial::spatial_act_on_special_NPs); + PLUGIN_REGISTER(PLUGIN_COMPLETE_MODEL, PL::Spatial::IF_complete_model); + PLUGIN_REGISTER(PLUGIN_DEFAULT_APPEARANCE, PL::Spatial::spatial_default_appearance); + PLUGIN_REGISTER(PLUGIN_INFERENCES_CONTRADICT, PL::Spatial::spatial_inferences_contradict); + PLUGIN_REGISTER(PLUGIN_EXPLAIN_CONTRADICTION, PL::Spatial::spatial_explain_contradiction); + PLUGIN_REGISTER(PLUGIN_LOG_INFERENCE_TYPE, PL::Spatial::spatial_log_inference_type); + PLUGIN_REGISTER(PLUGIN_NAME_TO_EARLY_INFS, PL::Spatial::spatial_name_to_early_infs); + PLUGIN_REGISTER(PLUGIN_NEW_SUBJECT_NOTIFY, PL::Spatial::spatial_new_subject_notify); + PLUGIN_REGISTER(PLUGIN_NEW_PROPERTY_NOTIFY, PL::Spatial::spatial_new_property_notify); + PLUGIN_REGISTER(PLUGIN_PARSE_COMPOSITE_NQS, PL::Spatial::spatial_parse_composite_NQs); + PLUGIN_REGISTER(PLUGIN_SET_KIND_NOTIFY, PL::Spatial::spatial_set_kind_notify); + PLUGIN_REGISTER(PLUGIN_SET_SUBKIND_NOTIFY, PL::Spatial::spatial_set_subkind_notify); + PLUGIN_REGISTER(PLUGIN_ADD_TO_WORLD_INDEX, PL::Spatial::spatial_add_to_World_index); + PLUGIN_REGISTER(PLUGIN_INTERVENE_IN_ASSERTION, PL::Spatial::spatial_intervene_in_assertion); }-
§7.1. In talking about some of the fundamental spatial domains we potentially have +
§8. In talking about some of the fundamental spatial domains we potentially have a vicious circle, because
@@ -207,10 +207,8 @@ we will make them correspond to the actual kinds later on, at some point after stage (d) when they exist. -Create early inference subjects7.1 = -
-+void PL::Spatial::create_inference_subjects(void) { infs_room = InferenceSubjects::new(global_constants, FUND_SUB, NULL_GENERAL_POINTER, LIKELY_CE); infs_thing = InferenceSubjects::new(global_constants, @@ -219,9 +217,9 @@ after stage (d) when they exist. FUND_SUB, NULL_GENERAL_POINTER, LIKELY_CE); infs_person = InferenceSubjects::new(global_constants, FUND_SUB, NULL_GENERAL_POINTER, LIKELY_CE); +}-
- This code is used in §7.
§8. And this is where those IOUs are redeemed. What happens is that, ordinarily, +
§9. And this is where those IOUs are redeemed. What happens is that, ordinarily, the machinery creating objects (and kinds) will allocate a new inference structure for each object, but it first invites plugins to choose an existing one instead. (The INFS structure is rewritten, but the important thing is that @@ -229,7 +227,7 @@ pointers to it remain consistent and valid.)
-int PL::Spatial::spatial_name_to_early_infs(wording W, inference_subject **infs) { +int PL::Spatial::spatial_name_to_early_infs(wording W, inference_subject **infs) { if (<notable-spatial-kinds>(W)) { switch (<<r>>) { case 0: if (K_room == NULL) *infs = infs_room; break; @@ -242,11 +240,11 @@ pointers to it remain consistent and valid.) return FALSE; }-
§9. Here we initialise the data used by Spatial for each object: +
§10. Here we initialise the data used by Spatial for each object:
-spatial_data *PL::Spatial::new_data(inference_subject *subj) { +spatial_data *PL::Spatial::new_data(inference_subject *subj) { spatial_data *sd = CREATE(spatial_data); sd->progenitor = NULL; sd->progenitor_set_at = NULL; sd->part_flag = FALSE; sd->object_tree_parent = NULL; sd->object_tree_child = NULL; sd->object_tree_sibling = NULL; @@ -256,13 +254,13 @@ pointers to it remain consistent and valid.) return sd; }-
§10. Special inferences. Four of these are quite simple inferences, but PARENTAGE_INF stores the +
§11. Special inferences. Four of these are quite simple inferences, but PARENTAGE_INF stores the object to which a spatial relationship is being inferred; and this means that multiple PARENTAGE_INFs can contradict each other.
-int PL::Spatial::spatial_log_inference_type(int it) { +int PL::Spatial::spatial_log_inference_type(int it) { switch(it) { case CONTAINS_THINGS_INF: LOG("CONTAINS_THINGS_INF"); return TRUE; case IS_ROOM_INF: LOG("IS_ROOM_INF"); return TRUE; @@ -274,7 +272,7 @@ multiple PARENTAGE_INF return FALSE; } -int PL::Spatial::spatial_inferences_contradict(inference *A, inference *B, int similarity) { +int PL::Spatial::spatial_inferences_contradict(inference *A, inference *B, int similarity) { if ((World::Inferences::get_inference_type(A) == PARENTAGE_INF) && (World::Inferences::get_reference_as_object(A) != World::Inferences::get_reference_as_object(B))) @@ -282,7 +280,7 @@ multiple PARENTAGE_INF return FALSE; } -int PL::Spatial::spatial_explain_contradiction(inference *A, inference *B, int similarity, +int PL::Spatial::spatial_explain_contradiction(inference *A, inference *B, int similarity, inference_subject *subj) { if ((World::Inferences::get_inference_type(A) == PARENTAGE_INF) && (World::Inferences::get_reference_as_object(A) != @@ -307,7 +305,7 @@ multiple PARENTAGE_INF return FALSE; }-
§11. Special kinds. These are kind names to do with spatial layout which Inform provides special +
§12. Special kinds. These are kind names to do with spatial layout which Inform provides special support for; it recognises the Englishs name when defined by the Standard Rules. (So there is no need to translate this to other languages.)
@@ -322,10 +320,10 @@ Rules. (So there is no need to translate this to other languages.) player's holdall