From eec32b0f4bdade11a62282339f41f9bd926a25a0 Mon Sep 17 00:00:00 2001
From: Graham Nelson §3.1. Headings cause us to begin a fresh topic of discussion, on a fresh piece of
diff --git a/docs/assertions-module/5-adf.html b/docs/assertions-module/5-adf.html
index 52cc084c7..70a68c968 100644
--- a/docs/assertions-module/5-adf.html
+++ b/docs/assertions-module/5-adf.html
@@ -222,8 +222,6 @@ container (called the sack) is capacious if...".
void AdjectivalDefinitionFamily::look_for_headers(parse_node *p) {
if (Node::get_type(p) == IMPERATIVE_NT)
if (<definition-header>(Node::get_text(p))) {
- compilation_unit *cm = CompilationUnits::current();
- CompilationUnits::set_current(p);
parse_node *q = NULL;
if (Node::get_type(p->next) == DEFN_CONT_NT) q = p->next;
else q = (p->down)?(p->down->down):NULL;
@@ -240,8 +238,6 @@ container (called the sack) is capacious if...".
Register the resulting adjective9.3;
if (the_format != DEFINED_PHRASALLY) p->down = NULL;
-
- CompilationUnits::set_current_to(cm);
}
}
diff --git a/docs/building-module/1-bm.html b/docs/building-module/1-bm.html
index 8df3dc9f9..9c190514b 100644
--- a/docs/building-module/1-bm.html
+++ b/docs/building-module/1-bm.html
@@ -82,7 +82,6 @@
enum module_package_CLASS
enum submodule_identity_CLASS
enum submodule_request_CLASS
-enum compilation_unit_CLASS
enum inter_schema_CLASS
enum inter_schema_node_CLASS
enum inter_schema_token_CLASS
@@ -98,7 +97,6 @@
DECLARE_CLASS(module_package)
DECLARE_CLASS(submodule_identity)
DECLARE_CLASS(submodule_request)
-DECLARE_CLASS(compilation_unit)
DECLARE_CLASS(inter_schema)
DECLARE_CLASS(inter_schema_node)
DECLARE_CLASS(inter_schema_token)
@@ -108,7 +106,6 @@
#ifdef CORE_MODULE
MAKE_ANNOTATION_FUNCTIONS(explicit_iname, inter_name)
-MAKE_ANNOTATION_FUNCTIONS(unit, compilation_unit)
#endif
§4. The beginning. (The client doesn't need to call the start and end routines, because the
diff --git a/docs/building-module/1-bs.html b/docs/building-module/1-bs.html
index d725ec88d..a80145e00 100644
--- a/docs/building-module/1-bs.html
+++ b/docs/building-module/1-bs.html
@@ -265,14 +265,14 @@ itself during compilation.
I->site.assimilation_package = M;
}
-dictionary *Site::modules_dictionary(inter_tree *I) {
+dictionary *Site::modules_dictionary(inter_tree *I) {
if (I->site.modules_indexed_by_name == NULL) {
I->site.modules_indexed_by_name = Dictionaries::new(512, FALSE);
}
return I->site.modules_indexed_by_name;
}
-package_request *Site::main_request(inter_tree *I) {
+package_request *Site::main_request(inter_tree *I) {
if (I->site.main_pr == NULL)
I->site.main_pr = Packaging::request(I, InterNames::explicitly_named(I"main", NULL),
PackageTypes::get(I, I"_plain"));
@@ -281,7 +281,7 @@ itself during compilation.
package_request *Site::connectors_request(inter_tree *I) {
if (I->site.connectors_pr == NULL) {
- module_package *T = Packaging::get_unit(I, I"connectors");
+ module_package *T = Packaging::get_unit(I, I"connectors");
I->site.connectors_pr = T->the_package;
}
return I->site.connectors_pr;
@@ -289,7 +289,7 @@ itself during compilation.
package_request *Site::veneer_request(inter_tree *I) {
if (I->site.veneer_pr == NULL) {
- module_package *T = Packaging::get_unit(I, I"veneer");
+ module_package *T = Packaging::get_unit(I, I"veneer");
I->site.veneer_pr = T->the_package;
packaging_state save = Packaging::enter(I->site.veneer_pr);
I->site.veneer_bookmark = Packaging::bubble(I);
diff --git a/docs/building-module/1-hl.html b/docs/building-module/1-hl.html
index 1c29133d9..6a627c678 100644
--- a/docs/building-module/1-hl.html
+++ b/docs/building-module/1-hl.html
@@ -115,13 +115,13 @@ following fields set.
location_requirement HierarchyLocations::generic_submodule(inter_tree *I, submodule_identity *sid) {
location_requirement req = HierarchyLocations::blank();
- req.this_exact_package = Packaging::generic_submodule(I, sid);
+ req.this_exact_package = Packaging::generic_submodule(I, sid);
return req;
}
location_requirement HierarchyLocations::synoptic_submodule(inter_tree *I, submodule_identity *sid) {
location_requirement req = HierarchyLocations::blank();
- req.this_exact_package = Packaging::synoptic_submodule(I, sid);
+ req.this_exact_package = Packaging::synoptic_submodule(I, sid);
return req;
}
@@ -259,7 +259,7 @@ following fields set.
}
inter_name *HierarchyLocations::function(inter_tree *I, package_request *R, text_stream *name, text_stream *trans) {
- inter_name *iname = Packaging::function(I, InterNames::explicitly_named(name, R), NULL);
+ inter_name *iname = Packaging::function(I, InterNames::explicitly_named(name, R), NULL);
if (trans) Produce::change_translation(iname, trans);
return iname;
}
@@ -281,11 +281,11 @@ following fields set.
} else internal_error("package can't be found");
}
if (Str::len(hl->function_package_name) > 0) {
- hl->equates_to_iname = Packaging::function_text(I,
+ hl->equates_to_iname = Packaging::function_text(I,
InterNames::explicitly_named(hl->function_package_name, hl->requirements.this_exact_package),
hl->access_name);
} else if (Str::len(hl->datum_package_name) > 0) {
- hl->equates_to_iname = Packaging::datum_text(I,
+ hl->equates_to_iname = Packaging::datum_text(I,
InterNames::explicitly_named(hl->datum_package_name, hl->requirements.this_exact_package),
hl->access_name);
} else if ((hl->requirements.this_exact_package) && (hl->equates_to_iname == NULL)) {
@@ -348,7 +348,7 @@ following fields set.
void MajorNodes::visit(parse_node *p, parse_node **last) {
global_pass_state.assembly_position = current_sentence;
- compilation_unit *cm = CompilationUnits::current();
- CompilationUnits::set_current(p);
*last = p;
Deal with an individual major node3.1;
- CompilationUnits::set_current_to(cm);
}
if (Str::len(hl->function_package_name) > 0) {
- iname = Packaging::function(I,
+ iname = Packaging::function(I,
InterNames::explicitly_named(hl->function_package_name, P), NULL);
} else {
if (hl->trans.by_imposition) iname = InterNames::explicitly_named_with_memo(imposed_name, P, W);
@@ -404,27 +404,18 @@ following fields set.
return hap;
}
-package_request *HierarchyLocations::attach_new_package(inter_tree *I, compilation_unit *C, package_request *R, int hap_id) {
+#ifdef CORE_MODULE
+package_request *HierarchyLocations::attach_new_package(inter_tree *I, compilation_unit *C, package_request *R, int hap_id) {
if ((hap_id < 0) || (hap_id >= NO_DEFINED_HAP_VALUES) || (I->site.haps_indexed_by_id[hap_id] == NULL))
internal_error("invalid HAP request");
hierarchy_attachment_point *hap = I->site.haps_indexed_by_id[hap_id];
if (hap->requirements.any_submodule_package_of_this_identity) {
- #ifdef CORE_MODULE
- R = Packaging::request_submodule(I, C, hap->requirements.any_submodule_package_of_this_identity);
- #endif
- #ifndef CORE_MODULE
- internal_error("feature available only within inform7 compiler");
- #endif
- } else if (hap->requirements.this_exact_package)
+ R = Packaging::request_submodule(I, C, hap->requirements.any_submodule_package_of_this_identity);
+ } else if (hap->requirements.this_exact_package) {
R = hap->requirements.this_exact_package;
- else if (hap->requirements.this_exact_package_not_yet_created >= 0) {
- #ifdef CORE_MODULE
+ } else if (hap->requirements.this_exact_package_not_yet_created >= 0) {
R = Hierarchy::exotic_package(hap->requirements.this_exact_package_not_yet_created);
- #endif
- #ifndef CORE_MODULE
- internal_error("feature available only within inform7 compiler");
- #endif
} else if (hap->requirements.any_package_of_this_type) {
if ((R == NULL) || (R->eventual_type != PackageTypes::get(I, hap->requirements.any_package_of_this_type)))
internal_error("subpackage in wrong superpackage");
@@ -432,6 +423,7 @@ following fields set.
return Packaging::request(I, Packaging::make_iname_within(R, hap->name_stem), PackageTypes::get(I, hap->type));
}
+#endif
diff --git a/docs/building-module/1-in.html b/docs/building-module/1-in.html
index b1b56c1c5..23a199afd 100644
--- a/docs/building-module/1-in.html
+++ b/docs/building-module/1-in.html
@@ -229,7 +229,7 @@ a memo to attach):
return InterNames::new(InterNames::single_use_generator(name), R, W);
}
-inter_name *InterNames::explicitly_named(text_stream *name, package_request *R) {
+inter_name *InterNames::explicitly_named(text_stream *name, package_request *R) {
return InterNames::explicitly_named_with_memo(name, R, EMPTY_WORDING);
}
@@ -274,7 +274,7 @@ a memo to attach):
-package_request *InterNames::location(inter_name *iname) { +package_request *InterNames::location(inter_name *iname) { if (iname == NULL) return NULL; return iname->location_in_hierarchy; } diff --git a/docs/building-module/1-pck.html b/docs/building-module/1-pck.html index 7e9e284dd..202c5e328 100644 --- a/docs/building-module/1-pck.html +++ b/docs/building-module/1-pck.html @@ -72,7 +72,7 @@ function togglePopup(material_id) {
To manage requests to build Inter packages, and then to generate inames within them; and to create modules and submodules.
-§1. Package requests. In the same way that inames are created as shadows of eventual inter symbols, and omly converted into the real thing on demand, "package requests" are @@ -98,7 +98,7 @@ called "incarnation".
-package_request *Packaging::request(inter_tree *I, inter_name *name, inter_symbol *pt) { +package_request *Packaging::request(inter_tree *I, inter_name *name, inter_symbol *pt) { package_request *R = CREATE(package_request); R->for_tree = I; R->eventual_name = name; @@ -358,21 +358,7 @@ specification. return R->actual_package; }- - -
-typedef struct compilation_unit { - struct module_package *inter_presence; - struct parse_node *hanging_from; - CLASS_DEFINITION -} compilation_unit; - -compilation_unit *Packaging::new_cu(void) { - return CREATE(compilation_unit); -} --
§15. Modules. With the code above, then, we can get the Inter hierarchy of packages set up +
§14. Modules. With the code above, then, we can get the Inter hierarchy of packages set up as far as creating main. After that the Hierarchy code takes over, but it calls the routines below to assist. It will want to create a number of "modules" and, within them, "submodules". @@ -389,7 +375,7 @@ following creates modules on demand. CLASS_DEFINITION } module_package; -module_package *Packaging::get_unit(inter_tree *I, text_stream *name) { +module_package *Packaging::get_unit(inter_tree *I, text_stream *name) { if (Dictionaries::find(Site::modules_dictionary(I), name)) return (module_package *) Dictionaries::read_value(Site::modules_dictionary(I), name); @@ -405,7 +391,7 @@ following creates modules on demand. }
§16. Submodules. Submodules have names such as properties, and the idea is that the same submodule +
§15. Submodules. Submodules have names such as properties, and the idea is that the same submodule (or rather, submodules with the same name) can be found in multiple modules. The different sorts of submodule are identified by submodule_identity pointers, though as it turns out, this is presently just a wrapper for a name. @@ -428,35 +414,35 @@ as it turns out, this is presently just a wrapper for a name. }
§17. Once the Hierarchy code has registered a submodule, it can request an existing +
§16. Once the Hierarchy code has registered a submodule, it can request an existing module to have this submodule. It should call one of the following four functions:
#ifdef CORE_MODULE -package_request *Packaging::request_submodule(inter_tree *I, compilation_unit *C, submodule_identity *sid) { - if (C == NULL) return Packaging::generic_submodule(I, sid); - return Packaging::new_submodule_inner(I, CompilationUnits::inter_presence(C), sid); +package_request *Packaging::request_submodule(inter_tree *I, compilation_unit *C, submodule_identity *sid) { + if (C == NULL) return Packaging::generic_submodule(I, sid); + return Packaging::new_submodule_inner(I, CompilationUnits::inter_presence(C), sid); } package_request *Packaging::local_submodule(inter_tree *I, submodule_identity *sid) { - return Packaging::request_submodule(I, CompilationUnits::find(current_sentence), sid); + return Packaging::request_submodule(I, CompilationUnits::find(current_sentence), sid); } #endif package_request *Packaging::generic_submodule(inter_tree *I, submodule_identity *sid) { - return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"generic"), sid); + return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"generic"), sid); } package_request *Packaging::synoptic_submodule(inter_tree *I, submodule_identity *sid) { - return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"synoptic"), sid); + return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"synoptic"), sid); } package_request *Packaging::template_submodule(inter_tree *I, submodule_identity *sid) { - return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"template"), sid); + return Packaging::new_submodule_inner(I, Packaging::get_unit(I, I"template"), sid); }-
§18. Those in turn all make use of this back-end function: +
§17. Those in turn all make use of this back-end function:
@@ -466,7 +452,7 @@ module to have this submodule. It should call one of the following four function CLASS_DEFINITION } submodule_request; -package_request *Packaging::new_submodule_inner(inter_tree *I, module_package *M, submodule_identity *sid) { +package_request *Packaging::new_submodule_inner(inter_tree *I, module_package *M, submodule_identity *sid) { submodule_request *sr; LOOP_OVER_LINKED_LIST(sr, submodule_request, M->submodules) if (sid == sr->which_submodule) @@ -480,7 +466,7 @@ module to have this submodule. It should call one of the following four function }
§19. Functions. Inter code has a standard layout for functions: an outer, enclosing, package of type +
§18. Functions. Inter code has a standard layout for functions: an outer, enclosing, package of type _function, inside which is an iname call for the actual code to call. All such functions are produced by the following routines:
@@ -514,7 +500,7 @@ functions are produced by the following routines: return FALSE; } -diff --git a/docs/building-module/1-pt.html b/docs/building-module/1-pt.html index f36586c36..bd58a9c3a 100644 --- a/docs/building-module/1-pt.html +++ b/docs/building-module/1-pt.html @@ -86,7 +86,7 @@ Instead we use the following function:-inter_symbol *PackageTypes::get(inter_tree *I, text_stream *name) { +inter_symbol *PackageTypes::get(inter_tree *I, text_stream *name) { inter_symbols_table *scope = Inter::Tree::global_scope(I); inter_symbol *ptype = Inter::SymbolsTables::symbol_from_name(scope, name); @@ -130,7 +130,7 @@ want to optimise this by cacheing the result:-inter_symbol *PackageTypes::function(inter_tree *I) { +inter_symbol *PackageTypes::function(inter_tree *I) { return PackageTypes::get(I, I"_function"); }diff --git a/docs/building-module/3-prd.html b/docs/building-module/3-prd.html index 9c9ca6f8f..58cc2590c 100644 --- a/docs/building-module/3-prd.html +++ b/docs/building-module/3-prd.html @@ -211,7 +211,7 @@ function togglePopup(material_id) { } -void Produce::change_translation(inter_name *iname, text_stream *new_text) { +void Produce::change_translation(inter_name *iname, text_stream *new_text) { Inter::Symbols::set_translate(InterNames::to_symbol(iname), new_text); } @@ -271,7 +271,7 @@ function togglePopup(material_id) { } inter_name *block_iname = NULL; - if (Packaging::housed_in_function(I, iname)) + if (Packaging::housed_in_function(I, iname)) block_iname = Packaging::make_iname_within(InterNames::location(iname), I"block"); else internal_error("routine outside function package"); inter_bookmark save_ib = Inter::Bookmarks::snapshot(Packaging::at(I)); @@ -293,7 +293,7 @@ function togglePopup(material_id) { } inter_name *Produce::kernel(inter_tree *I, inter_name *public_name) { - if (Packaging::housed_in_function(I, public_name) == FALSE) + if (Packaging::housed_in_function(I, public_name) == FALSE) internal_error("routine not housed in function"); package_request *P = InterNames::location(public_name); inter_name *kernel_name = Packaging::make_iname_within(P, I"kernel"); diff --git a/docs/core-module/1-cp.html b/docs/core-module/1-cp.html index 6cf48e05c..f0c660d4b 100644 --- a/docs/core-module/1-cp.html +++ b/docs/core-module/1-cp.html @@ -252,6 +252,7 @@ We begin with core itself.enum adjective_iname_holder_CLASS enum backdrop_found_in_notice_CLASS enum bp_runtime_implementation_CLASS +enum compilation_unit_CLASS enum definition_CLASS enum door_dir_notice_CLASS enum door_to_notice_CLASS @@ -273,6 +274,7 @@ We begin with core itself. DECLARE_CLASS(adjective_iname_holder) DECLARE_CLASS(backdrop_found_in_notice) DECLARE_CLASS(bp_runtime_implementation) +DECLARE_CLASS(compilation_unit) DECLARE_CLASS(definition) DECLARE_CLASS(door_dir_notice) DECLARE_CLASS(door_to_notice) diff --git a/docs/core-module/1-inaa.html b/docs/core-module/1-inaa.html index 75cadb5f2..1c2f43441 100644 --- a/docs/core-module/1-inaa.html +++ b/docs/core-module/1-inaa.html @@ -381,11 +381,11 @@ which compilation unit the node belongs.DECLARE_ANNOTATION_FUNCTIONS(unit, compilation_unit)-§10. For tedious code-sequencing reasons, the annotation functions for unit_ANNOT -are made in Building Module (in building). -
++MAKE_ANNOTATION_FUNCTIONS(unit, compilation_unit) + void CoreSyntax::declare_unit(void) { Annotations::declare_type(unit_ANNOT, CoreSyntax::write_unit_ANNOT); } @@ -932,6 +932,7 @@ are made in Building Mod Annotations::allow_for_category(CODE_NCAT, token_check_to_do_ANNOT); Annotations::allow_for_category(CODE_NCAT, token_to_be_parsed_against_ANNOT); Annotations::allow_for_category(CODE_NCAT, verb_problem_issued_ANNOT); + Annotations::allow(INVOCATION_LIST_NT, 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); diff --git a/docs/imperative-module/3-cid.html b/docs/imperative-module/3-cid.html index 10cce2637..de51a7294 100644 --- a/docs/imperative-module/3-cid.html +++ b/docs/imperative-module/3-cid.html @@ -108,8 +108,6 @@ That's a function called either from Phrase LOGIF(PHRASE_COMPILATION, "Compiling phrase:\n$T", code_at); current_sentence = code_at; - CompilationUnits::set_current(code_at); - stack_frame *frame = &(idb->compilation_data.id_stack_frame); inter_name *iname = req?(req->req_iname):(CompileImperativeDefn::iname(idb)); @@ -121,7 +119,6 @@ That's a function called either from Phrase Functions::end(save); current_sentence = NULL; - CompilationUnits::set_current(NULL); }§2.1. Compile some commentary about the function to follow2.1 = @@ -216,7 +213,6 @@ value for its return kind: for example, the empty text for typedef struct id_compilation_data { - struct compilation_unit *owning_module; struct stack_frame id_stack_frame; int at_least_one_compiled_form_needed; do we still need to compile this? @@ -232,7 +228,6 @@ value for its return kind: for example, the empty text for struct linked_list *label_namespaces; of label_namespace int compile_with_run_time_debugging; in the RULES command struct inter_name *ph_iname; or NULL for inline phrases - } id_compilation_data;
void CompileImperativeDefn::prepare_for_requests(id_body *idb) { idb->compilation_data.requests_package = - Hierarchy::package(idb->compilation_data.owning_module, PHRASES_HAP); + Hierarchy::local_package_to(PHRASES_HAP, idb->head_of_defn->at); } package_request *CompileImperativeDefn::requests_package(id_body *idb) { return idb->compilation_data.requests_package; diff --git a/docs/inflections-module/3-vc.html b/docs/inflections-module/3-vc.html index 4dca46ecb..e52be4d5b 100644 --- a/docs/inflections-module/3-vc.html +++ b/docs/inflections-module/3-vc.html @@ -427,7 +427,7 @@ values representing verbs in story files compiled by Inform. if (vc->vc_iname == NULL) { if (vc->vc_conjugates == NULL) { package_request *R = - Hierarchy::package(CompilationUnits::find(vc->where_vc_created), MVERBS_HAP); + Hierarchy::local_package_to(MVERBS_HAP, vc->where_vc_created); TEMPORARY_TEXT(ANT) WRITE_TO(ANT, "%A (modal)", &(vc->tabulations[ACTIVE_VOICE].vc_text[IS_TENSE][POSITIVE_SENSE][THIRD_PERSON])); Hierarchy::markup(R, MVERB_NAME_HMD, ANT); diff --git a/docs/inflections-module/P-wtmd.html b/docs/inflections-module/P-wtmd.html index 0d296e8d5..7f3b05463 100644 --- a/docs/inflections-module/P-wtmd.html +++ b/docs/inflections-module/P-wtmd.html @@ -264,15 +264,15 @@ For example, there's one group which goes something like:@@ -204,7 +204,7 @@ the same object may be thing number 17 but vehicle number 3 — and secondly because we won't know the exact kind of objects until much later on; for now the only thing we are sure of is that they are indeed objects. Enumeration for objects within kinds is certainly useful, but it's harder to do and will -be done later on: see Instance Counting (in runtime). +be done later on: see Instance Counting (in runtime).- Kraft Kraft Kraft Kraft - Kräfte Kräfte Kräften Kräfte + Kraft Kraft Kraft Kraft + Kräfte Kräfte Kräften Kräfteand another which goes like:
- Kamera Kamera Kamera Kamera - Kameras Kameras Kameras Kameras + Kamera Kamera Kamera Kamera + Kameras Kameras Kameras KamerasFor German, we might then have
diff --git a/docs/kinds-module/4-kc2.html b/docs/kinds-module/4-kc2.html index 5c9b870dd..5676b7d0d 100644 --- a/docs/kinds-module/4-kc2.html +++ b/docs/kinds-module/4-kc2.html @@ -516,11 +516,11 @@ of the kind which the constructor makes: package_request *Kinds::Constructors::package(kind_constructor *con) { if (con->kc_package == NULL) { if (con->where_defined_in_source_text) { - compilation_unit *C = CompilationUnits::find(con->where_defined_in_source_text); - con->kc_package = Hierarchy::package(C, KIND_HAP); + con->kc_package = Hierarchy::local_package_to(KIND_HAP, + con->where_defined_in_source_text); } else if (con->superkind_set_at) { - compilation_unit *C = CompilationUnits::find(con->superkind_set_at); - con->kc_package = Hierarchy::package(C, KIND_HAP); + con->kc_package = Hierarchy::local_package_to(KIND_HAP, + con->superkind_set_at); } else { con->kc_package = Hierarchy::synoptic_package(KIND_HAP); } @@ -528,7 +528,8 @@ of the kind which the constructor makes: if (Wordings::nonempty(W)) Hierarchy::markup_wording(con->kc_package, KIND_NAME_HMD, W); else if (Str::len(con->name_in_template_code) > 0) - Hierarchy::markup(con->kc_package, KIND_NAME_HMD, con->name_in_template_code); + Hierarchy::markup(con->kc_package, KIND_NAME_HMD, + con->name_in_template_code); else Hierarchy::markup(con->kc_package, KIND_NAME_HMD, I"(anonymous kind)"); } diff --git a/docs/knowledge-module/2-ins.html b/docs/knowledge-module/2-ins.html index 41772006c..4eda656b6 100644 --- a/docs/knowledge-module/2-ins.html +++ b/docs/knowledge-module/2-ins.html @@ -127,7 +127,7 @@ hierarchy. See Instances::to_kind int enumeration_index; within each non-object kind, instances are counted from 1 struct instance_index_data iid; see Instances (in index) - struct instance_compilation_data icd; see Instances (in runtime) + struct instance_compilation_data icd; see Instances (in runtime) CLASS_DEFINITION } instance;
Add the new instance to its enumeration4.3 = diff --git a/docs/knowledge-module/2-nv.html b/docs/knowledge-module/2-nv.html index 96da8073e..e0c3d9e07 100644 --- a/docs/knowledge-module/2-nv.html +++ b/docs/knowledge-module/2-nv.html @@ -94,7 +94,7 @@ These variables are created by assertion sentences.
These semantics are so different that it makes no compelling sense to try to give them a common implementation inside the compiler; so, nonlocal variables are handled below, but local variables have a different implementation at -Local Variables (in imperative). +Local Variables (in imperative).
A pragmatic, but questionable,2 implementation decision by Inform is that @@ -103,7 +103,7 @@ that happen not to vary.
Nonlocal variables are stored in all kinds of ways at run-time. See -Variables (in runtime) for more. +Variables (in runtime) for more.
1 At one time the term used here was "quantity", which sounded philosophical diff --git a/docs/knowledge-module/4-is.html b/docs/knowledge-module/4-is.html index 2230b8015..6a61c2574 100644 --- a/docs/knowledge-module/4-is.html +++ b/docs/knowledge-module/4-is.html @@ -172,7 +172,6 @@ which all of the links run upwards to a common root — the ↩
3 The subject hierarchy thus contains the same tree structure of The Lattice of Kinds (in kinds), which is not a coincidence — see -// but of course it includes instances and much else as well. ↩
§4. The top of the inference hierarchy is essentially fixed, and contains a number diff --git a/docs/knowledge-module/4-is2.html b/docs/knowledge-module/4-is2.html index 14f62ac1c..e4347e76c 100644 --- a/docs/knowledge-module/4-is2.html +++ b/docs/knowledge-module/4-is2.html @@ -72,7 +72,7 @@ function togglePopup(material_id) {
The instances family of inference subjects.
-§1. See Instances and Instances (in runtime) for more; this section is only +
§1. See Instances and Instances (in runtime) for more; this section is only a go-between.
diff --git a/docs/knowledge-module/5-tmw.html b/docs/knowledge-module/5-tmw.html index 554fed1c7..ad7fbd53f 100644 --- a/docs/knowledge-module/5-tmw.html +++ b/docs/knowledge-module/5-tmw.html @@ -301,7 +301,7 @@ of whatever a plugin is concerned with, but which is not allowed to make changes to the model as it would be understood by the author. -For example, the Instance Counting (in runtime) plugin adds low-level properties +
For example, the Instance Counting (in runtime) plugin adds low-level properties to improve run-time performance, but they have no names and cannot be referred to or accessed by code written in Inform 7; they exist at the level of Inter only.
diff --git a/docs/runtime-module/2-cu.html b/docs/runtime-module/2-cu.html index 16328278a..bf098364d 100644 --- a/docs/runtime-module/2-cu.html +++ b/docs/runtime-module/2-cu.html @@ -72,7 +72,7 @@ function togglePopup(material_id) {To identify which parts of the source text come from which source (the main source text, the Standard Rules, or another extension).
-§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 @@ -89,14 +89,17 @@ in (a) or (b) above. This section of code determines to which unit any new definition (of, say, a property or kind) belongs.
--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:
+typedef struct compilation_unit { + struct module_package *inter_presence; + struct parse_node *hanging_from; + CLASS_DEFINITION +} compilation_unit; + void CompilationUnits::determine(void) { SyntaxTree::traverse(Task::syntax_tree(), CompilationUnits::look_for_cu); } @@ -108,36 +111,41 @@ level-0 headings, which are the nodes from which these blocks of source text han } } -compilation_unit *CompilationUnits::new(parse_node *from) { +void CompilationUnits::log(compilation_unit *cu) { + if (cu == NULL) LOG("<null>"); + else LOG("unit'%W'", Node::get_text(cu->hanging_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_unit *C = Packaging::new_cu(); - C->hanging_from = from; + compilation_unit *C = CREATE(compilation_unit); + C->inter_presence = NULL; + C->hanging_from = from; Node::set_unit(from, C); CompilationUnits::propagate_downwards(from->down, C); TEMPORARY_TEXT(pname) Compose a name for the unit package this will lead to2.1; - C->inter_presence = Packaging::get_unit(Emit::tree(), pname); + C->inter_presence = Packaging::get_unit(Emit::tree(), pname); DISCARD_TEXT(pname) if (owner) { - Hierarchy::markup(C->inter_presence->the_package, EXT_AUTHOR_HMD, owner->as_copy->edition->work->raw_author_name); - Hierarchy::markup(C->inter_presence->the_package, EXT_TITLE_HMD, owner->as_copy->edition->work->raw_title); + Hierarchy::markup(C->inter_presence->the_package, EXT_AUTHOR_HMD, owner->as_copy->edition->work->raw_author_name); + Hierarchy::markup(C->inter_presence->the_package, EXT_TITLE_HMD, owner->as_copy->edition->work->raw_title); TEMPORARY_TEXT(V) semantic_version_number N = owner->as_copy->edition->version; WRITE_TO(V, "%v", &N); - Hierarchy::markup(C->inter_presence->the_package, EXT_VERSION_HMD, V); + Hierarchy::markup(C->inter_presence->the_package, EXT_VERSION_HMD, V); DISCARD_TEXT(V) } - - 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 unit will go into a package of that name.
@@ -169,52 +177,36 @@ them. This is done by "propagating downwards", as follows.-void CompilationUnits::propagate_downwards(parse_node *P, compilation_unit *C) { +void CompilationUnits::propagate_downwards(parse_node *P, compilation_unit *C) { while (P) { Node::set_unit(P, C); CompilationUnits::propagate_downwards(P->down, C); P = P->next; } } + +void CompilationUnits::assign_to_same_unit(parse_node *to, parse_node *from) { + Node::set_unit(to, Node::get_unit(from)); +}
§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_unit *CompilationUnits::find(parse_node *from) { +compilation_unit *CompilationUnits::find(parse_node *from) { if (from == NULL) return NULL; return Node::get_unit(from); }-
§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_unit *current_CM = NULL; - -compilation_unit *CompilationUnits::current(void) { - return current_CM; -} - -void CompilationUnits::set_current_to(compilation_unit *CM) { - current_CM = CM; -} - -void CompilationUnits::set_current(parse_node *P) { - if (P) current_CM = CompilationUnits::find(P); - else current_CM = NULL; -} --
§7. Relating to Inter. Creating the necessary package, of type _module, is the work of the +
§6. Relating to Inter. Creating the necessary package, of type _module, is the work of the Packaging code.
-module_package *CompilationUnits::inter_presence(compilation_unit *C) { +module_package *CompilationUnits::inter_presence(compilation_unit *C) { if (C == NULL) internal_error("no unit"); - return C->inter_presence; + return C->inter_presence; }