I want to include certain I6 parser routines using Include (-...-) replacing "SomeParserRoutine"
so that I can tinker with them, but some run into a problem because they reference I6 variables, arrays or routines that seem to be created only in the final stages of Inter compilation to I6 and therefore fail the Inter pipeline ‘shorten-wiring’ stage.
e.g.
"Include (- [ DoScopeActionAndRecurse ... -) replacing "DoScopeActionAndRecurse".
Include (-
[ DoScopeActionAndRecurse domain nosearch context i ad n obj next_obj;
DoScopeAction(domain);
if ((((domain ~= nosearch)) && ((((domain ofclass K1_room or K8_person)) || ((IsSeeThrough(domain) == 1)))))) {
(obj = child(domain));
while (obj) {
(next_obj = sibling(obj));
if ((((domain == actor)) || ((TestConcealment(domain, obj) == 0)))) {
DoScopeActionAndRecurse(obj, nosearch, context);
}
(obj = next_obj);
}
}
if ((_final_propertyexists(OBJECT_TY, domain, A_component_child))) {
(obj = (domain.component_child));
while (obj) {
(next_obj = (obj.component_sibling));
if ((((domain == actor)) || ((TestConcealment(domain, obj) == 0)))) {
DoScopeActionAndRecurse(obj, 0, context);
}
(obj = next_obj);
}
}
(ad = (_final_propertyarray(OBJECT_TY, domain, A_add_to_scope)));
if ((ad ~= 0)) {
(i = (metaclass((ad-->(0))) == Object));
if (i) {
(ats_flag = (2 + context));
RunRoutines(domain, A_add_to_scope);
(ats_flag = 0);
} else {
(n = (_final_propertylength(OBJECT_TY, domain, A_add_to_scope)));
for ((i = 0):((WORDSIZE*i) < n):(i)++) {
if ((ad-->(i))) {
DoScopeActionAndRecurse((ad-->(i)), 0, context);
}
}
}
}
];
-) replacing "DoScopeActionAndRecurse".
results in
Problem. Something went wrong late in compilation, when working through the ‘pipeline’ of code-generation steps. (This should not normally happen unless your source text is making use of ‘(-’ and ‘-)’ and getting that wrong, or unless you are experimenting with non-standard pipelines.) The pipeline looks like so:
view earlier steps
read ← *memory
parse-insertions
resolve-conditional-compilation
compile-splats
load-binary-kits
make-synoptic-module
- shorten-wiring
Problem: unable to find definitions for the following name(s): _final_propertyexists, A_component_child, _final_propertyarray, A_add_to_scope, _final_propertylength
view later steps
detect-indirect-calls
make-identifiers-unique
reconcile-verbs
eliminate-redundant-labels
eliminate-redundant-operations
optionally-generate text →
generate
index
Because of this problem, the source could not be translated into a working game. (Correct the source text to remove the difficulty and click on Go once again.)
Now, it’s possible to get past this block by subterfuge, i.e. by writing another I6 inclusion that defines the problem names as dummy variables, arrays and routines:
view including dummy definitions
Include (-
#ifndef _final_propertyexists;
[ _final_propertyexists; ]; !###Delete
#endif;
#ifndef A_component_child;
Array A_component_child --> 1; !###Delete
#endif;
#ifndef _final_propertyarray;
[ _final_propertyarray;]; !###Delete
#endif;
#ifndef A_add_to_scope;
Array A_add_to_scope --> 1; !###Delete
#endif;
#ifndef _final_propertylength;
[ _final_propertylength; ]; !###Delete
#endif;
-).
and this will now compile to an I6 ‘auto.inf’ source file, but the problem now is that the I7->Inter->I6 compilation steps strip out the #ifndef and #endif statements, so that these variables, arrays and routines are now defined twice in the I6 source- causing the I6 compiler to bail with errors:
view generated errors
C:\Program Files\Inform\Compilers\inform6
-wSDGk +include_path=…\Source,.\ auto.inf output.ulx
Inform 6.41 for Win32 (22nd July 2022)
auto.inf(4159): Error: “A_component_child” is a name already in use and may not be used as a new array name (Array “A_component_child” was defined at line 4091)
> Array A_component_child
auto.inf(4159): Error: Expected ‘;’ but found Array
> Array
auto.inf(4160): Error: “A_add_to_scope” is a name already in use and may not be used as a new array name (Array “A_add_to_scope” was defined at line 4088)
> Array A_add_to_scope
auto.inf(4160): Error: Expected ‘;’ but found Array
> Array
auto.inf(80622): Error: “_final_propertyexists” is a name already in use and may not be used as a routine name (Routine “_final_propertyexists” was defined at line 6194)
> [ _final_propertyexists
This isn’t a problem for global variables- I6 doesn’t seem to mind these being defined twice- but it clearly can be for arrays and routines (I’m not sure why only one of the three routines here generates an error- perhaps the compiler gives up in disgust after finding the first one?)
At present I’m manually commenting out the duplicate definitions in ‘auto.inf’ and running the I6 compiler on the edited source from the command line, but is there a less troublesome approach?