1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00

Rehoused all remaining constants out of main package

This commit is contained in:
Graham Nelson 2019-04-08 09:03:53 +01:00
parent 682f9f2077
commit 6339c4002a
29 changed files with 435 additions and 273 deletions

View file

@ -126,7 +126,9 @@ proposition would be wasteful of space in the Z-machine.
WRITE_TO(COTT, "%~W", ParseTree::get_text(pdef->deferred_from));
else
WRITE_TO(COTT, "not sure where this came from");
packaging_state save = Packaging::enter_home_of(pdef->rtp_iname);
Emit::named_string_constant(pdef->rtp_iname, COTT);
Packaging::exit(save);
DISCARD_TEXT(COTT);
@ Just in case this hasn't already been done:
@ -1592,8 +1594,9 @@ pcalc_prop *Calculus::Propositions::Deferred::compile_loop_header(int var, local
if ((K) && (parent_optimised == FALSE)) { /* parent optimisation is stronger, so we prefer that */
if (Calculus::Deferrals::write_loop_schema(&loop_schema, K) == FALSE) {
if (pdef->rtp_iname == NULL) {
pdef->rtp_iname = InterNames::new(DEFERRED_PROPOSITION_RTP_INAMEF);
InterNames::to_symbol(pdef->rtp_iname);
package_request *P = Packaging::home_of(pdef->ppd_iname);
pdef->rtp_iname = InterNames::one_off(I"rtp", P);
Inter::Symbols::set_flag(InterNames::to_symbol(pdef->rtp_iname), MAKE_NAME_UNIQUE);
}
Calculus::Schemas::modify(&loop_schema, "if (RunTimeProblem(RTP_CANTITERATE, %n))",
pdef->rtp_iname);

View file

@ -587,9 +587,8 @@ compile under Inform 6.
DISCARD_TEXT(TEMP);
InterNames::attach_memo(rks->rks_iname, W);
InterNames::to_symbol(rks->rks_iname);
rks->rks_dv_iname = InterNames::new(DEFAULT_VALUE_INAMEF);
InterNames::attach_memo(rks->rks_dv_iname, W);
InterNames::to_symbol(rks->rks_dv_iname);
rks->rks_dv_iname = InterNames::one_off(I"default_value", PR);
Inter::Symbols::set_flag(InterNames::to_symbol(rks->rks_dv_iname), MAKE_NAME_UNIQUE);
@ It's convenient to combine this system with one which constructs default
values for kinds, since both involve tracking constructions uniquely.
@ -724,6 +723,7 @@ void Kinds::RunTime::compile_structures(void) {
@<Compile a constructed default value for this kind@> =
inter_name *identifier = rks->rks_dv_iname;
current_sentence = rks->default_requested_here;
packaging_state save = Packaging::enter_home_of(identifier);
if (Kinds::get_construct(K) == CON_phrase) {
Phrases::Constants::compile_default_closure(identifier, K);
} else if (Kinds::get_construct(K) == CON_relation) {
@ -739,6 +739,7 @@ void Kinds::RunTime::compile_structures(void) {
"for the kind '%2', but there's no obvious way to make one.");
Problems::issue_problem_end();
}
Packaging::exit(save);
@<Compile the default value finder@> =
package_request *R = Packaging::synoptic_resource(KINDS_SUBPACKAGE);

View file

@ -69,10 +69,14 @@ I6 code into object bodies, and the I6 template does make use of this a little.
In an ideal world we would revoke this ability.
@<Append any inclusions the source text requested@> =
packaging_state save = Packaging::enter_home_of(iname);
TEMPORARY_TEXT(incl);
Config::Inclusions::compile_inclusions_for_subject(incl, subj);
if (Str::len(incl) > 0) Emit::append(iname, incl);
if (Str::len(incl) > 0) {
Emit::append(iname, incl);
}
DISCARD_TEXT(incl);
Packaging::exit(save);
@ Now, here goes with the properties. We first compile clauses for those we
know about, then for any other properties which are permitted but apparently

View file

@ -105,7 +105,9 @@ literal_text *Strings::TextLiterals::lt_new(int w1, int colour) {
x->unexpanded = FALSE;
x->small_block_array_needed = FALSE;
x->lt_sba_iname = NULL;
x->lt_iname = InterNames::new_in(LITERAL_TEXT_INAMEF, Modules::current());
x->lt_iname = Packaging::supply_iname(Packaging::current_enclosure(), LITERAL_PR_COUNTER);
Inter::Symbols::set_flag(InterNames::to_symbol(x->lt_iname), MAKE_NAME_UNIQUE);
Emit::annotate_symbol_i(InterNames::to_symbol(x->lt_iname), TEXT_LITERAL_IANN, 1);
InterNames::to_symbol(x->lt_iname);
if ((wn_quote_suppressed >= 0) && (w1 == wn_quote_suppressed)) x->unexpanded = TRUE;
return x;
@ -178,8 +180,8 @@ which are null pointers.
if (encode_constant_text_bibliographically) x->bibliographic_conventions = TRUE;
if (write) {
if (x->lt_sba_iname == NULL) {
x->lt_sba_iname = InterNames::new_in(LITERAL_TEXT_SBA_INAMEF, Modules::current());
InterNames::to_symbol(x->lt_sba_iname);
x->lt_sba_iname = Packaging::supply_iname(Packaging::current_enclosure(), BLOCK_CONSTANT_PR_COUNTER);
Inter::Symbols::set_flag(InterNames::to_symbol(x->lt_sba_iname), MAKE_NAME_UNIQUE);
}
if (VH) InterNames::holster(VH, x->lt_sba_iname);
x->small_block_array_needed = TRUE;
@ -282,6 +284,7 @@ void Strings::TextLiterals::traverse_lts(literal_text *lt) {
}
@<Compile a standard literal text@> =
packaging_state save = Packaging::enter_home_of(lt->lt_iname);
if (existing_story_file) { /* to prevent trouble when no story file is really being made */
Emit::named_string_constant(lt->lt_iname, I"--");
} else {
@ -295,24 +298,31 @@ void Strings::TextLiterals::traverse_lts(literal_text *lt) {
Emit::named_string_constant(lt->lt_iname, TLT);
DISCARD_TEXT(TLT);
}
Packaging::exit(save);
if (lt->small_block_array_needed) {
packaging_state save = Packaging::enter_home_of(lt->lt_sba_iname);
Emit::named_array_begin(lt->lt_sba_iname, K_value);
Emit::array_iname_entry(InterNames::extern(CONSTANT_PACKED_TEXT_STORAGE_EXNAMEF));
Emit::array_iname_entry(lt->lt_iname);
Emit::array_end();
Packaging::exit(save);
}
@<Compile a boxed-quotation literal text@> =
if (lt->lt_sba_iname == NULL)
lt->lt_sba_iname = InterNames::new(LITERAL_TEXT_SBA_INAMEF);
if (lt->lt_sba_iname == NULL) {
lt->lt_sba_iname = Packaging::supply_iname(Packaging::current_enclosure(), BLOCK_CONSTANT_PR_COUNTER);
Inter::Symbols::set_flag(InterNames::to_symbol(lt->lt_sba_iname), MAKE_NAME_UNIQUE);
}
package_request *P = lt->lt_iname->eventual_owner;
inter_name *iname = Packaging::function(
InterNames::one_off(I"box_quotation_fn", P),
P,
InterNames::new(PAST_ACTION_ROUTINE_INAMEF));
packaging_state save = Packaging::enter_home_of(lt->lt_sba_iname);
Emit::named_iname_constant(lt->lt_sba_iname, K_value, iname);
Packaging::exit(save);
packaging_state save = Routines::begin(iname);
save = Routines::begin(iname);
Emit::inv_primitive(box_interp);
Emit::down();
TEMPORARY_TEXT(T);

View file

@ -24,6 +24,7 @@ typedef struct literal_list {
int kinds_known_to_be_inconsistent; /* problem(s) thrown when parsing these */
struct llist_entry *first_llist_entry; /* linked list of contents */
struct package_request *ll_package; /* which will be the enclosure for... */
struct inter_name *ll_iname;
int list_compiled; /* lists are compiled at several different points: has this one been done? */
@ -78,6 +79,7 @@ literal_list *Lists::empty_literal_list(wording W) {
ll->ll_iname = NULL;
ll->first_llist_entry = NULL;
ll->list_text = NULL;
ll->ll_package = Packaging::current_enclosure();
Kinds::RunTime::ensure_basic_heap_present();
return ll;
}
@ -270,8 +272,8 @@ inter_name *Lists::compile_literal_list(wording W) {
inter_name *Lists::iname(literal_list *ll) {
if (ll->ll_iname == NULL) {
ll->ll_iname = InterNames::new(LITERAL_LIST_INAMEF);
InterNames::to_symbol(ll->ll_iname);
ll->ll_iname = Packaging::supply_iname(Packaging::current_enclosure(), LITERAL_PR_COUNTER);
Inter::Symbols::set_flag(InterNames::to_symbol(ll->ll_iname), MAKE_NAME_UNIQUE);
}
return ll->ll_iname;
}
@ -301,6 +303,7 @@ the list!);
(d) that number of values, each representing one entry.
@<Actually compile the list array@> =
packaging_state save = Packaging::enter_home_of(ll->ll_iname);
Emit::named_array_begin(ll->ll_iname, K_value);
llist_entry *lle;
int n = 0;
@ -315,6 +318,7 @@ the list!);
Specifications::Compiler::emit_constant_to_kind(
lle->llist_entry_value, ll->entry_kind);
Emit::array_end();
Packaging::exit(save);
@ The default list of any given kind is empty.

View file

@ -32,8 +32,7 @@ constant_phrase *Phrases::Constants::create(wording NW, wording RW) {
cphr->name = Nouns::new_proper_noun(NW, NEUTER_GENDER,
REGISTER_SINGULAR_NTOPT + PARSE_EXACTLY_NTOPT,
PHRASE_CONSTANT_MC, Rvalues::from_constant_phrase(cphr));
cphr->cphr_iname = InterNames::new(CLOSURE_INAMEF);
InterNames::to_symbol(cphr->cphr_iname);
cphr->cphr_iname = NULL;
return cphr;
}
@ -99,6 +98,18 @@ inter_name *Phrases::Constants::compile(constant_phrase *cphr) {
if (Phrases::compiled_inline(ph) == FALSE)
Routines::ToPhrases::make_request(ph,
Phrases::Constants::kind(cphr), NULL, EMPTY_WORDING);
return Phrases::Constants::iname(cphr);
}
inter_name *Phrases::Constants::iname(constant_phrase *cphr) {
if (cphr->cphr_iname == NULL) {
phrase *ph = Phrases::Constants::as_phrase(cphr);
if (ph == NULL) internal_error("cannot reconstruct phrase from cphr");
package_request *closure_package =
Packaging::request(Packaging::supply_iname(ph->requests_package, CLOSURE_PR_COUNTER), ph->requests_package, closure_ptype);
cphr->cphr_iname = InterNames::one_off(I"closure_data", closure_package);
Inter::Symbols::set_flag(InterNames::to_symbol(cphr->cphr_iname), MAKE_NAME_UNIQUE);
}
return cphr->cphr_iname;
}
@ -122,7 +133,9 @@ phrase in order to make sure somebody has actually compiled it: this is in
case the phrase occurs as a constant but is never explicitly invoked.
@<Compile the closure array for this constant phrase@> =
Emit::named_array_begin(cphr->cphr_iname, K_value);
inter_name *iname = Phrases::Constants::iname(cphr);
packaging_state save = Packaging::enter_home_of(iname);
Emit::named_array_begin(iname, K_value);
Kinds::RunTime::emit_strong_id(cphr->cphr_kind);
@ -136,6 +149,7 @@ case the phrase occurs as a constant but is never explicitly invoked.
DISCARD_TEXT(name);
Emit::array_end();
Packaging::exit(save);
@ Now we come to something trickier. We want default values for kinds of phrases,
because otherwise we can't have variables holding phrases unless they are

View file

@ -580,7 +580,15 @@ void TemplateFiles::compile_I7_from_I6_inner(value_holster *VH, text_stream *OUT
Specifications::Compiler::compile_inner(&VH2, spec);
inter_t v1 = 0, v2 = 0;
Holsters::unholster_pair(&VH2, &v1, &v2);
CodeGen::val_from(OUT, Emit::IRS(), v1, v2);
if (v1 == ALIAS_IVAL) {
PUT(URL_SYMBOL_CHAR);
inter_symbols_table *T = Inter::Packages::scope(Packaging::current_enclosure()->actual_package);
inter_symbol *S = Inter::SymbolsTables::symbol_from_id(T, v2);
Inter::SymbolsTables::symbol_to_url_name(OUT, S);
PUT(URL_SYMBOL_CHAR);
} else {
CodeGen::val_from(OUT, Emit::IRS(), v1, v2);
}
}
}
END_COMPILATION_MODE;

View file

@ -47,7 +47,13 @@ label_namespace *JumpLabels::new_namespace(text_stream *name, compilation_module
lns->label_prefix = Str::new();
WRITE_TO(lns->label_prefix, "%S%S", cm->namespace->namespace_prefix, name);
lns->label_base_iname = InterNames::label_base_name(lns->label_prefix);
lns->label_storage_iname = InterNames::new_derived(LABEL_STORAGE_INAMEF, lns->label_base_iname);
package_request *PR = Packaging::synoptic_resource(PHRASES_SUBPACKAGE);
package_request *PR2 = Packaging::request(
Packaging::supply_iname(PR, LABEL_STORAGE_PR_COUNTER), PR, label_storage_ptype);
lns->label_storage_iname = InterNames::one_off(I"label_associated_storage", PR2);
Inter::Symbols::set_flag(InterNames::to_symbol(lns->label_storage_iname), MAKE_NAME_UNIQUE);
lns->label_counter = 0;
lns->allocate_storage = 0;
lns->module = cm;
@ -119,10 +125,12 @@ void JumpLabels::compile_necessary_storage(void) {
label_namespace *lns;
LOOP_OVER(lns, label_namespace)
if (lns->allocate_storage > 0) {
packaging_state save = Packaging::enter_home_of(lns->label_storage_iname);
Emit::named_array_begin(lns->label_storage_iname, K_number);
int N = (lns->allocate_storage)*(lns->label_counter) + 2;
for (int i=0; i<N; i++) Emit::array_numeric_entry(0);
Emit::array_end();
Packaging::exit(save);
}
}

View file

@ -36,7 +36,9 @@ inter_name *ListTogether::new(int include_articles) {
InterNames::one_off(I"list_together_fn", PR),
PR,
InterNames::new(LIST_TOGETHER_ROUTINE_INAMEF));
ltr->ltr_array_iname = InterNames::new(LIST_TOGETHER_ARRAY_INAMEF);
ltr->ltr_array_iname = InterNames::one_off(I"list_together_array", PR);
Inter::Symbols::set_flag(InterNames::to_symbol(ltr->ltr_array_iname), MAKE_NAME_UNIQUE);
ltr->articles_bit = include_articles;
return ltr->ltr_array_iname;
}
@ -107,7 +109,9 @@ int ListTogether::compilation_coroutine(void) {
Emit::rfalse();
Routines::end(save);
save = Packaging::enter_home_of(ltr->ltr_array_iname);
Emit::named_array_begin(ltr->ltr_array_iname, K_value);
Emit::array_iname_entry(InterNames::extern(CONSTANT_PACKED_TEXT_STORAGE_EXNAMEF));
Emit::array_iname_entry(ltr->ltr_routine_iname);
Emit::array_end();
Packaging::exit(save);

View file

@ -12,6 +12,7 @@ inter_symbol *mverb_ptype = NULL;
inter_symbol *to_phrase_ptype = NULL;
inter_symbol *rule_ptype = NULL;
inter_symbol *request_ptype = NULL;
inter_symbol *closure_ptype = NULL;
inter_symbol *response_ptype = NULL;
inter_symbol *adjective_ptype = NULL;
inter_symbol *adjective_meaning_ptype = NULL;
@ -28,6 +29,8 @@ inter_symbol *relation_ptype = NULL;
inter_symbol *test_ptype = NULL;
inter_symbol *outcome_ptype = NULL;
inter_symbol *data_ptype = NULL;
inter_symbol *external_file_ptype = NULL;
inter_symbol *label_storage_ptype = NULL;
@ =
void Packaging::emit_types(void) {
@ -49,6 +52,8 @@ void Packaging::emit_types(void) {
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), rule_ptype, Emit::baseline(Emit::IRS()), NULL));
request_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_request");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), request_ptype, Emit::baseline(Emit::IRS()), NULL));
closure_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_closure");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), closure_ptype, Emit::baseline(Emit::IRS()), NULL));
response_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_response");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), response_ptype, Emit::baseline(Emit::IRS()), NULL));
adjective_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_adjective");
@ -81,6 +86,10 @@ void Packaging::emit_types(void) {
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), outcome_ptype, Emit::baseline(Emit::IRS()), NULL));
data_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_data");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), data_ptype, Emit::baseline(Emit::IRS()), NULL));
external_file_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_external_file");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), external_file_ptype, Emit::baseline(Emit::IRS()), NULL));
label_storage_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_label_storage");
Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), label_storage_ptype, Emit::baseline(Emit::IRS()), NULL));
}
@
@ -93,11 +102,13 @@ void Packaging::emit_types(void) {
@e TO_PHRASE_PR_COUNTER
@e RULE_PR_COUNTER
@e REQUEST_PR_COUNTER
@e CLOSURE_PR_COUNTER
@e RESPONSE_PR_COUNTER
@e ADJECTIVE_PR_COUNTER
@e ADJECTIVE_MEANING_PR_COUNTER
@e TASK_PR_COUNTER
@e BLOCK_CONSTANT_PR_COUNTER
@e LITERAL_PR_COUNTER
@e PROPOSITION_PR_COUNTER
@e INSTANCE_PR_COUNTER
@e INLINE_PR_COUNTER
@ -116,6 +127,8 @@ void Packaging::emit_types(void) {
@e DATA_PR_COUNTER
@e OUTCOME_PR_COUNTER
@e TEST_PR_COUNTER
@e EXTERNAL_FILE_PR_COUNTER
@e LABEL_STORAGE_PR_COUNTER
@e MAX_PR_COUNTER
@ -171,6 +184,10 @@ packaging_state Packaging::stateless(void) {
return PS;
}
package_request *Packaging::home_of(inter_name *N) {
return N->eventual_owner;
}
packaging_state Packaging::enter_home_of(inter_name *N) {
return Packaging::enter(N->eventual_owner);
}
@ -216,7 +233,10 @@ packaging_state Packaging::enter(package_request *R) {
(S->eventual_type == table_column_ptype) ||
(S->eventual_type == data_ptype) ||
(S->eventual_type == outcome_ptype) ||
(S->eventual_type == external_file_ptype) ||
(S->eventual_type == adjective_ptype) ||
(S->eventual_type == test_ptype) ||
(S->eventual_type == closure_ptype) ||
(S->parent_request == NULL)) {
current_enclosure = S;
break;
@ -318,6 +338,7 @@ package_request *Packaging::request_synoptic(void) {
@e EQUATIONS_SUBPACKAGE
@e BIBLIOGRAPHIC_SUBPACKAGE
@e IF_SUBPACKAGE
@e EXTERNAL_FILES_SUBPACKAGE
@e MAX_SUBPACKAGE
@ -395,6 +416,7 @@ package_request *Packaging::synoptic_resource(int ix) {
case EQUATIONS_SUBPACKAGE: N = I"equations"; break;
case BIBLIOGRAPHIC_SUBPACKAGE: N = I"bibliographic"; break;
case IF_SUBPACKAGE: N = I"interactive_fiction"; break;
case EXTERNAL_FILES_SUBPACKAGE: N = I"external_files"; break;
default: internal_error("nameless resource");
}
inter_name *iname = InterNames::one_off(N, parent);
@ -416,10 +438,12 @@ inter_name *Packaging::supply_iname(package_request *R, int what_for) {
case TO_PHRASE_PR_COUNTER: WRITE_TO(P, "phrase"); break;
case RULE_PR_COUNTER: WRITE_TO(P, "rule"); break;
case REQUEST_PR_COUNTER: WRITE_TO(P, "request"); break;
case CLOSURE_PR_COUNTER: WRITE_TO(P, "closure"); break;
case RESPONSE_PR_COUNTER: WRITE_TO(P, "response"); break;
case ADJECTIVE_PR_COUNTER: WRITE_TO(P, "adjective"); break;
case ADJECTIVE_MEANING_PR_COUNTER: WRITE_TO(P, "adjective_meaning"); break;
case TASK_PR_COUNTER: WRITE_TO(P, "task"); break;
case LITERAL_PR_COUNTER: WRITE_TO(P, "literal"); break;
case BLOCK_CONSTANT_PR_COUNTER: WRITE_TO(P, "block_constant"); break;
case PROPOSITION_PR_COUNTER: WRITE_TO(P, "proposition"); break;
case INSTANCE_PR_COUNTER: WRITE_TO(P, "instance"); break;
@ -439,6 +463,8 @@ inter_name *Packaging::supply_iname(package_request *R, int what_for) {
case TEST_PR_COUNTER: WRITE_TO(P, "test"); break;
case OUTCOME_PR_COUNTER: WRITE_TO(P, "rulebook_outcome"); break;
case DATA_PR_COUNTER: WRITE_TO(P, "data"); break;
case EXTERNAL_FILE_PR_COUNTER: WRITE_TO(P, "external_file"); break;
case LABEL_STORAGE_PR_COUNTER: WRITE_TO(P, "label_associated_storage"); break;
default: internal_error("unimplemented");
}
WRITE_TO(P, "_%d", ++(R->counters[what_for]));

View file

@ -1827,7 +1827,10 @@ void Relations::compile_vtov_storage(binary_predicate *bp) {
if ((left_count > 0) && (right_count > 0))
@<Allocate a zeroed-out memory cache for relations with fast route-finding@>;
bp->v2v_bitmap_iname = InterNames::new(V2V_BITMAP_INAMEF);
package_request *P = BinaryPredicates::package(bp);
bp->v2v_bitmap_iname = InterNames::one_off(I"bitmap", P);
Inter::Symbols::set_flag(InterNames::to_symbol(bp->v2v_bitmap_iname), MAKE_NAME_UNIQUE);
packaging_state save = Packaging::enter_home_of(bp->v2v_bitmap_iname);
Emit::named_array_begin(bp->v2v_bitmap_iname, K_value);
@<Compile header information in the V-to-V structure@>;
@ -1835,6 +1838,7 @@ void Relations::compile_vtov_storage(binary_predicate *bp) {
@<Compile bitmap pre-initialised to the V-to-V relation at start of play@>;
Emit::array_end();
Packaging::exit(save);
TEMPORARY_TEXT(rname);
WRITE_TO(rname, "%A", &(bp->relation_name));
@ -1898,7 +1902,10 @@ and this is why the "cache broken" flag is initially set in the header
above: it forces the template layer to generate the cache when first used.
@<Allocate a zeroed-out memory cache for relations with fast route-finding@> =
inter_name *iname = InterNames::new(V2V_ROUTE_CACHE_INAMEF);
package_request *P = BinaryPredicates::package(bp);
inter_name *iname = InterNames::one_off(I"route_cache", P);
Inter::Symbols::set_flag(InterNames::to_symbol(iname), MAKE_NAME_UNIQUE);
packaging_state save = Packaging::enter_home_of(iname);
kind *left_kind = BinaryPredicates::term_kind(bp, 0);
kind *right_kind = BinaryPredicates::term_kind(bp, 1);
if ((bp->fast_route_finding) &&
@ -1921,6 +1928,7 @@ above: it forces the template layer to generate the cache when first used.
} else {
v2v_iname = Emit::named_numeric_constant(iname, 0);
}
Packaging::exit(save);
@ The following routine conveniently determines whether a given INFS is
within the domain of one of the terms of a relation; the rule is that it

View file

@ -41,7 +41,11 @@ void PL::Score::compile_max_score(void) {
(Kinds::Compare::eq(Tables::kind_of_ith_column(t, 0), K_number)) &&
(Kinds::Compare::eq(Tables::kind_of_ith_column(t, 1), K_text))) {
InterNames::to_symbol(Tables::identifier(t));
inter_name *iname = InterNames::iname(RANKING_TABLE_INAME);
Packaging::house(iname, Packaging::request_resource(NULL, BASICS_SUBPACKAGE));
packaging_state save = Packaging::enter_home_of(iname);
Emit::named_iname_constant(InterNames::iname(RANKING_TABLE_INAME), K_value, Tables::identifier(t));
Packaging::exit(save);
parse_node *PN = Tables::cells_in_ith_column(t, 0);
while ((PN != NULL) && (PN->next != NULL)) PN = PN->next;
if ((PN != NULL) && (max_score_VAR) &&

View file

@ -167,7 +167,13 @@ grammar_verb *PL::Parsing::Verbs::find_or_create_command(wording W) {
gv = PL::Parsing::Verbs::gv_new(GV_IS_COMMAND);
gv->command = W;
if (Wordings::empty(W)) Emit::named_numeric_constant(InterNames::iname(NO_VERB_VERB_DEFINED_INAME), (inter_t) 1);
if (Wordings::empty(W)) {
inter_name *iname = InterNames::iname(NO_VERB_VERB_DEFINED_INAME);
Packaging::house(iname, Packaging::request_resource(NULL, BASICS_SUBPACKAGE));
packaging_state save = Packaging::enter_home_of(iname);
Emit::named_numeric_constant(iname, (inter_t) 1);
Packaging::exit(save);
}
else LOGIF(GRAMMAR_CONSTRUCTION, "GV%d has verb %W\n", gv->allocation_id, W);
return gv;

View file

@ -33,7 +33,6 @@ kind *K_external_file = NULL;
@ =
void PL::Files::start(void) {
PLUGIN_REGISTER(PLUGIN_COMPILE_CONSTANT, PL::Files::files_compile_constant);
PLUGIN_REGISTER(PLUGIN_NEW_BASE_KIND_NOTIFY, PL::Files::files_new_base_kind_notify);
PLUGIN_REGISTER(PLUGIN_NEW_INSTANCE_NOTIFY, PL::Files::files_new_named_instance_notify);
}
@ -238,9 +237,15 @@ void PL::Files::register_file(wording F, wording FN) {
exf->file_is_binary = binary;
exf->file_ownership = ownership;
exf->IFID_of_owner = Str::duplicate(ifid_of_file);
exf->exf_iname = InterNames::new(EXTERNAL_FILE_INAMEF);
package_request *PR = Packaging::request_resource(Modules::find(current_sentence), EXTERNAL_FILES_SUBPACKAGE);
package_request *PR2 = Packaging::request(Packaging::supply_iname(PR, EXTERNAL_FILE_PR_COUNTER), PR, test_ptype);
exf->exf_iname = InterNames::one_off(I"file", PR2);
InterNames::attach_memo(exf->exf_iname, exf->name);
exf->IFID_array_iname = InterNames::new(IFID_ARRAY_INAMEF);
Inter::Symbols::set_flag(InterNames::to_symbol(exf->exf_iname), MAKE_NAME_UNIQUE);
exf->IFID_array_iname = InterNames::one_off(I"ifid", PR2);
InterNames::attach_memo(exf->IFID_array_iname, exf->name);
Inter::Symbols::set_flag(InterNames::to_symbol(exf->IFID_array_iname), MAKE_NAME_UNIQUE);
LOGIF(FIGURE_CREATIONS, "Created external file <%W> = filename '%N'\n",
F, exf->unextended_filename);
@ -250,26 +255,6 @@ void PL::Files::register_file(wording F, wording FN) {
@h I6 arrays of file structures.
External files are written in I6 as their array names:
=
int PL::Files::files_compile_constant(OUTPUT_STREAM, kind *K, parse_node *spec) {
if (Plugins::Manage::plugged_in(files_plugin) == FALSE)
internal_error("files plugin inactive");
wording W = ParseTree::get_text(spec);
if ((Kinds::Compare::eq(K, K_external_file)) && (<s-literal>(W))) {
internal_error("LAMIA");
external_file *exf;
LOOP_OVER(exf, external_file) {
if (exf->allocation_id == <<r>>) {
WRITE("%S", exf->exf_I6_identifier);
return TRUE;
}
}
}
return FALSE;
}
@ And the following declares the arrays:
=
void PL::Files::arrays(void) {
if (Plugins::Manage::plugged_in(files_plugin) == FALSE) return;
@ -283,16 +268,19 @@ void PL::Files::arrays(void) {
external_file *exf;
LOOP_OVER(exf, external_file) {
if (exf->file_ownership == OWNED_BY_SPECIFIC_PROJECT) {
packaging_state save = Packaging::enter_home_of(exf->IFID_array_iname);
Emit::named_string_array_begin(exf->IFID_array_iname, K_value);
TEMPORARY_TEXT(II);
WRITE_TO(II, "//%S//", exf->IFID_of_owner);
Emit::array_text_entry(II);
DISCARD_TEXT(II);
Emit::array_end();
Packaging::exit(save);
}
}
LOOP_OVER(exf, external_file) {
packaging_state save = Packaging::enter_home_of(exf->exf_iname);
Emit::named_array_begin(exf->exf_iname, K_value);
Emit::array_iname_entry(InterNames::extern(AUXF_MAGIC_VALUE_EXNAMEF));
Emit::array_iname_entry(InterNames::extern(AUXF_STATUS_IS_CLOSED_EXNAMEF));
@ -311,6 +299,7 @@ void PL::Files::arrays(void) {
case OWNED_BY_SPECIFIC_PROJECT: Emit::array_iname_entry(exf->IFID_array_iname); break;
}
Emit::array_end();
Packaging::exit(save);
}
iname = InterNames::one_off(I"TableOfExternalFiles", PR);

View file

@ -2,31 +2,32 @@ packagetype _plain
packagetype _code
package main _plain
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
kind K_typeless_int int32
kind K_list_of_values list of K_unchecked
kind K_truth_state int2
constant VERB_DIRECTIVE_DIVIDER K_unchecked = 1
constant VERB_DIRECTIVE_RESULT K_unchecked = 2
splat &"Constant DEBUG;\n"
splat &"Constant Badger = 12;\n"
splat &"[ Falsity; return false; ];\n"
splat &"[ Demo x y; return x+y; ];\n"
splat &"Array XA --> 2 4 56;\n"
splat &"Array XB--> (71 + 3);\n"
splat &"Array XC -> 17 91;\n"
splat &"Array XD-> 8 6;\n"
splat &"Array XE table 2 3 4 5;\n"
splat &"Array XF buffer 6 7 8 9;\n"
splat &"Constant Bodger $$10011101;\n"
splat &"Constant Budger $7fe2 ;\n"
splat &"Global nitwit = 2;\n"
splat &"Verb meta 'purloin'\n * scope=testcommandnoun -> XPurloin;\n"
splat &"Default Bodger = 77;\n"
splat &"Default Bydger = 777;\n"
splat &"#Stub Banana 2;\n"
splat &"#Stub Peach 0;\n"
splat &"Attribute marmorial;\n"
splat &"Property density;\n"
symbol external misc Falsity
package resources _plain
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
kind K_typeless_int int32
kind K_list_of_values list of K_unchecked
kind K_truth_state int2
constant VERB_DIRECTIVE_DIVIDER K_unchecked = 1
constant VERB_DIRECTIVE_RESULT K_unchecked = 2
splat &"Constant DEBUG;\n"
splat &"Constant Badger = 12;\n"
splat &"[ Falsity; return false; ];\n"
splat &"[ Demo x y; return x+y; ];\n"
splat &"Array XA --> 2 4 56;\n"
splat &"Array XB--> (71 + 3);\n"
splat &"Array XC -> 17 91;\n"
splat &"Array XD-> 8 6;\n"
splat &"Array XE table 2 3 4 5;\n"
splat &"Array XF buffer 6 7 8 9;\n"
splat &"Constant Bodger $$10011101;\n"
splat &"Constant Budger $7fe2 ;\n"
splat &"Global nitwit = 2;\n"
splat &"Verb meta 'purloin'\n * scope=testcommandnoun -> XPurloin;\n"
splat &"Default Bodger = 77;\n"
splat &"Default Bydger = 777;\n"
splat &"#Stub Banana 2;\n"
splat &"#Stub Peach 0;\n"
splat &"Attribute marmorial;\n"
splat &"Property density;\n"
symbol external misc Falsity

View file

@ -2,96 +2,98 @@ packagetype _plain
packagetype _code
package main _plain
symbol public misc K_unchecked
symbol public misc K_unchecked_function
symbol public misc K_typeless_int
symbol public misc K_list_of_values
symbol public misc K_truth_state
symbol public misc VERB_DIRECTIVE_DIVIDER
symbol public misc VERB_DIRECTIVE_RESULT
symbol external misc Falsity
symbol public misc Falsity_B
symbol public misc Falsity_1
symbol public misc Demo_B
symbol public misc Demo
symbol public misc Banana_B
symbol public misc Banana
symbol public misc Peach_B
symbol public misc Peach
symbol public misc marmorial -> marmorial
symbol public misc density
symbol public misc DEBUG
symbol public misc Badger
symbol public misc XA
symbol public misc XB
symbol public misc XC
symbol public misc XD
symbol public misc XE
symbol public misc XF
symbol public misc Bodger
symbol public misc Budger
symbol public misc assim_verb_1
symbol public misc Bodger_1
symbol public misc Bydger
symbol public misc nitwit
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
kind K_typeless_int int32
kind K_list_of_values list of K_unchecked
kind K_truth_state int2
constant VERB_DIRECTIVE_DIVIDER K_unchecked = 1
constant VERB_DIRECTIVE_RESULT K_unchecked = 2
constant DEBUG K_unchecked = 0 __assimilated=1
constant Badger K_unchecked = 12 __assimilated=1
package Falsity_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"return false;"
.end
constant Falsity_1 K_unchecked_function = Falsity_B __assimilated=1
package Demo_B _code
symbol public misc x
symbol external misc K_unchecked == /main/K_unchecked
symbol public misc y
symbol private label .begin
symbol private label .end
local x K_unchecked
local y K_unchecked
.begin
splat &"return x+y;"
.end
constant Demo K_unchecked_function = Demo_B __assimilated=1
constant XA K_list_of_values = { 2, 4, 56 } __assimilated=1
constant XB K_list_of_values = { &"(71 + 3)" } __assimilated=1
constant XC K_list_of_values = { 17, 91 } __assimilated=1 __byte_array=1
constant XD K_list_of_values = { 8, 6 } __assimilated=1 __byte_array=1
constant XE K_list_of_values = { 2, 3, 4, 5 } __assimilated=1 __table_array=1
constant XF K_list_of_values = { 6, 7, 8, 9 } __assimilated=1 __buffer_array=1
constant Bodger K_unchecked = 157 __assimilated=1
constant Budger K_unchecked = 32738 __assimilated=1
variable nitwit K_unchecked = 2 __assimilated=1
constant assim_verb_1 K_list_of_values = { dw'purloin', VERB_DIRECTIVE_DIVIDER, &"scope=testcommandnoun", VERB_DIRECTIVE_RESULT, &"##XPurloin" } __assimilated=1 __verb=1 __meta_verb=1
constant Bodger_1 K_unchecked = 77 __assimilated=1
constant Bydger K_unchecked = 777 __assimilated=1
package Banana_B _code
symbol public misc x1
symbol external misc K_unchecked == /main/K_unchecked
symbol public misc x2
symbol private label .begin
symbol private label .end
local x1 K_unchecked
local x2 K_unchecked
.begin
splat &"rfalse;"
.end
constant Banana K_unchecked_function = Banana_B __assimilated=1
package Peach_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"rfalse;"
.end
constant Peach K_unchecked_function = Peach_B __assimilated=1
property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1
property density K_unchecked __assimilated=1
symbol public misc resources
package resources _plain
symbol public misc K_unchecked
symbol public misc K_unchecked_function
symbol public misc K_typeless_int
symbol public misc K_list_of_values
symbol public misc K_truth_state
symbol public misc VERB_DIRECTIVE_DIVIDER
symbol public misc VERB_DIRECTIVE_RESULT
symbol external misc Falsity
symbol public misc Falsity_B
symbol public misc Falsity_1
symbol public misc Demo_B
symbol public misc Demo
symbol public misc Banana_B
symbol public misc Banana
symbol public misc Peach_B
symbol public misc Peach
symbol public misc marmorial -> marmorial
symbol public misc density
symbol public misc DEBUG
symbol public misc Badger
symbol public misc XA
symbol public misc XB
symbol public misc XC
symbol public misc XD
symbol public misc XE
symbol public misc XF
symbol public misc Bodger
symbol public misc Budger
symbol public misc assim_verb_1
symbol public misc Bodger_1
symbol public misc Bydger
symbol public misc nitwit
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
kind K_typeless_int int32
kind K_list_of_values list of K_unchecked
kind K_truth_state int2
constant VERB_DIRECTIVE_DIVIDER K_unchecked = 1
constant VERB_DIRECTIVE_RESULT K_unchecked = 2
constant DEBUG K_unchecked = 0 __assimilated=1
constant Badger K_unchecked = 12 __assimilated=1
package Falsity_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"return false;"
.end
constant Falsity_1 K_unchecked_function = Falsity_B __assimilated=1
package Demo_B _code
symbol public misc x
symbol external misc K_unchecked == /main/resources/K_unchecked
symbol public misc y
symbol private label .begin
symbol private label .end
local x K_unchecked
local y K_unchecked
.begin
splat &"return x+y;"
.end
constant Demo K_unchecked_function = Demo_B __assimilated=1
constant XA K_list_of_values = { 2, 4, 56 } __assimilated=1
constant XB K_list_of_values = { &"(71 + 3)" } __assimilated=1
constant XC K_list_of_values = { 17, 91 } __assimilated=1 __byte_array=1
constant XD K_list_of_values = { 8, 6 } __assimilated=1 __byte_array=1
constant XE K_list_of_values = { 2, 3, 4, 5 } __assimilated=1 __table_array=1
constant XF K_list_of_values = { 6, 7, 8, 9 } __assimilated=1 __buffer_array=1
constant Bodger K_unchecked = 157 __assimilated=1
constant Budger K_unchecked = 32738 __assimilated=1
variable nitwit K_unchecked = 2 __assimilated=1
constant assim_verb_1 K_list_of_values = { dw'purloin', VERB_DIRECTIVE_DIVIDER, &"scope=testcommandnoun", VERB_DIRECTIVE_RESULT, &"##XPurloin" } __assimilated=1 __verb=1 __meta_verb=1
constant Bodger_1 K_unchecked = 77 __assimilated=1
constant Bydger K_unchecked = 777 __assimilated=1
package Banana_B _code
symbol public misc x1
symbol external misc K_unchecked == /main/resources/K_unchecked
symbol public misc x2
symbol private label .begin
symbol private label .end
local x1 K_unchecked
local x2 K_unchecked
.begin
splat &"rfalse;"
.end
constant Banana K_unchecked_function = Banana_B __assimilated=1
package Peach_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"rfalse;"
.end
constant Peach K_unchecked_function = Peach_B __assimilated=1
property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1
property density K_unchecked __assimilated=1

View file

@ -2,10 +2,11 @@ packagetype _plain
packagetype _code
package main _plain
kind K_unchecked unchecked
constant Bidger K_unchecked = 20
splat &"Constant Badger = 12;\n"
splat &"Constant Bodger $$10011101;\n"
splat &"Constant Budger $7fe2 ;\n"
constant Danza K_unchecked = sum{ 2, 34 }
constant Sahara K_unchecked = sum{ Danza, Bidger, 1 }
package resources _plain
kind K_unchecked unchecked
constant Bidger K_unchecked = 20
splat &"Constant Badger = 12;\n"
splat &"Constant Bodger $$10011101;\n"
splat &"Constant Budger $7fe2 ;\n"
constant Danza K_unchecked = sum{ 2, 34 }
constant Sahara K_unchecked = sum{ Danza, Bidger, 1 }

View file

@ -2,9 +2,10 @@ packagetype _plain
packagetype _code
package main _plain
kind K_object enum
kind K_fruit <= K_object
kind K_citrus_fruit <= K_fruit
kind K_stone <= K_object
kind K_feldspar <= K_stone
kind K_mica <= K_stone
package resources _plain
kind K_object enum
kind K_fruit <= K_object
kind K_citrus_fruit <= K_fruit
kind K_stone <= K_object
kind K_feldspar <= K_stone
kind K_mica <= K_stone

View file

@ -2,7 +2,8 @@ packagetype _plain
packagetype _code
package main _plain
kind K_number int32
symbol public misc Banana
constant Peach K_number = Banana
constant Banana K_number = 2
package resources _plain
kind K_number int32
symbol public misc Banana
constant Peach K_number = Banana
constant Banana K_number = 2

View file

@ -7,30 +7,31 @@ primitive !plus val val -> val
primitive !minus val val -> val
package main _plain
kind K_number int32
kind K_phrase_number____nothing function K_number -> void
package MyRoutine_B _code
symbol private misc x
symbol private misc y
symbol private label .begin
symbol private label .end
symbol external misc K_number
local x K_number
local y K_number
.begin
inv !return
val K_number x
inv !return
inv !plus
package resources _plain
kind K_number int32
kind K_phrase_number____nothing function K_number -> void
package MyRoutine_B _code
symbol private misc x
symbol private misc y
symbol private label .begin
symbol private label .end
symbol external misc K_number
local x K_number
local y K_number
.begin
inv !return
val K_number x
val K_number y
inv !return
inv !minus
val K_number x
val K_number y
inv !return
inv !modulo
val K_number x
val K_number y
.end
constant MyRoutine K_phrase_number____nothing = MyRoutine_B
inv !return
inv !plus
val K_number x
val K_number y
inv !return
inv !minus
val K_number x
val K_number y
inv !return
inv !modulo
val K_number x
val K_number y
.end
constant MyRoutine K_phrase_number____nothing = MyRoutine_B

View file

@ -2,36 +2,37 @@ packagetype _plain
packagetype _code
package main _plain
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
package Falsity_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"return false;"
.end
constant Falsity K_unchecked_function = Falsity_B
package Demo_B _code
symbol private misc x
symbol private misc y
symbol private label .begin
symbol private label .end
symbol external misc K_unchecked
local x K_unchecked
local y K_unchecked
.begin
splat &"return x+y;"
.end
constant Demo K_unchecked_function = Demo_B
package Prop_Falsity_B _code
symbol private misc reason
symbol private misc obj
symbol private label .begin
symbol private label .end
symbol external misc K_unchecked
local reason K_unchecked
local obj K_unchecked
.begin
splat &"return 0;"
.end
constant Prop_Falsity K_unchecked_function = Prop_Falsity_B
package resources _plain
kind K_unchecked unchecked
kind K_unchecked_function function K_unchecked -> K_unchecked
package Falsity_B _code
symbol private label .begin
symbol private label .end
.begin
splat &"return false;"
.end
constant Falsity K_unchecked_function = Falsity_B
package Demo_B _code
symbol private misc x
symbol private misc y
symbol private label .begin
symbol private label .end
symbol external misc K_unchecked
local x K_unchecked
local y K_unchecked
.begin
splat &"return x+y;"
.end
constant Demo K_unchecked_function = Demo_B
package Prop_Falsity_B _code
symbol private misc reason
symbol private misc obj
symbol private label .begin
symbol private label .end
symbol external misc K_unchecked
local reason K_unchecked
local obj K_unchecked
.begin
splat &"return 0;"
.end
constant Prop_Falsity K_unchecked_function = Prop_Falsity_B

View file

@ -13,6 +13,7 @@ We need to itemise the structures we'll want to allocate:
@e stage_set_MT
@e stage_step_MT
@e uniqueness_count_MT
@e text_literal_holder_MT
@ With allocation functions:
@ -21,6 +22,7 @@ ALLOCATE_INDIVIDUALLY(I6T_intervention)
ALLOCATE_INDIVIDUALLY(stage_set)
ALLOCATE_INDIVIDUALLY(stage_step)
ALLOCATE_INDIVIDUALLY(uniqueness_count)
ALLOCATE_INDIVIDUALLY(text_literal_holder)
@h The beginning.
(The client doesn't need to call the start and end routines, because the

View file

@ -145,29 +145,29 @@ void CodeGen::Stage::follow(pathname *P, stage_set *S, inter_repository *I, int
if (S == NULL) return;
clock_t start = clock();
unchecked_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K_unchecked");
unchecked_function_symbol = Inter::Packages::search_main_exhaustively(I, I"K_unchecked_function");
typeless_int_symbol = Inter::Packages::search_main_exhaustively(I, I"K_typeless_int");
list_of_unchecked_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K_list_of_values");
object_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K_object");
action_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K_action_name");
truth_state_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K_truth_state");
direction_kind_symbol = Inter::Packages::search_main_exhaustively(I, I"K3_direction");
unchecked_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_unchecked");
unchecked_function_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_unchecked_function");
typeless_int_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_typeless_int");
list_of_unchecked_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_list_of_values");
object_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_object");
action_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_action_name");
truth_state_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K_truth_state");
direction_kind_symbol = Inter::Packages::search_resources_exhaustively(I, I"K3_direction");
verb_directive_reverse_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_REVERSE");
verb_directive_slash_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_SLASH");
verb_directive_divider_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_DIVIDER");
verb_directive_result_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_RESULT");
verb_directive_special_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_SPECIAL");
verb_directive_number_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_NUMBER");
verb_directive_noun_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_NOUN");
verb_directive_multi_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_MULTI");
verb_directive_multiinside_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_MULTIINSIDE");
verb_directive_multiheld_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_MULTIHELD");
verb_directive_held_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_HELD");
verb_directive_creature_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_CREATURE");
verb_directive_topic_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_TOPIC");
verb_directive_multiexcept_symbol = Inter::Packages::search_main_exhaustively(I, I"VERB_DIRECTIVE_MULTIEXCEPT");
verb_directive_reverse_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_REVERSE");
verb_directive_slash_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_SLASH");
verb_directive_divider_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_DIVIDER");
verb_directive_result_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_RESULT");
verb_directive_special_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_SPECIAL");
verb_directive_number_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_NUMBER");
verb_directive_noun_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_NOUN");
verb_directive_multi_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_MULTI");
verb_directive_multiinside_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_MULTIINSIDE");
verb_directive_multiheld_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_MULTIHELD");
verb_directive_held_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_HELD");
verb_directive_creature_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_CREATURE");
verb_directive_topic_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_TOPIC");
verb_directive_multiexcept_symbol = Inter::Packages::search_resources_exhaustively(I, I"VERB_DIRECTIVE_MULTIEXCEPT");
int step_count = 0, step_total = 0;
for (stage_step *step = S->first_step; step; step = step->next_step) step_total++;

View file

@ -7,6 +7,12 @@ To generate I6 code from intermediate code.
@d MAX_REPOS_AT_ONCE 8
=
typedef struct text_literal_holder {
struct text_stream *definition_code;
struct text_stream *literal_content;
MEMORY_MANAGEMENT
} text_literal_holder;
void CodeGen::to_I6(inter_repository *I, OUTPUT_STREAM) {
if (I == NULL) internal_error("no inter to generate from");
@ -64,7 +70,18 @@ void CodeGen::to_I6(inter_repository *I, OUTPUT_STREAM) {
case CONSTANT_IST: {
inter_symbol *con_name =
Inter::SymbolsTables::symbol_from_frame_data(P, DEFN_CONST_IFLD);
if (Inter::Packages::container(P) == Inter::Packages::main(I)) {
WRITE_TO(STDERR, "Bad constant: %S\n", con_name->symbol_name);
internal_error("constant defined in main");
}
TO = early_matter;
if (Inter::Symbols::read_annotation(con_name, TEXT_LITERAL_IANN) == 1) {
text_literal_holder *tlh = CREATE(text_literal_holder);
tlh->definition_code = Str::new();
inter_t ID = P.data[DATA_CONST_IFLD];
tlh->literal_content = Inter::get_text(P.repo_segment->owning_repo, ID);
TO = tlh->definition_code;
}
if (Inter::Symbols::read_annotation(con_name, LATE_IANN) == 1) TO = code_at_eof;
if (Inter::Symbols::read_annotation(con_name, BUFFERARRAY_IANN) == 1) TO = arrays_at_eof;
if (Inter::Symbols::read_annotation(con_name, BYTEARRAY_IANN) == 1) TO = arrays_at_eof;
@ -140,6 +157,22 @@ void CodeGen::to_I6(inter_repository *I, OUTPUT_STREAM) {
if (properties_written == FALSE) { text_stream *TO = main_matter; @<Property knowledge@>; }
WRITE("%S", early_matter);
int no_tlh = NUMBER_CREATED(text_literal_holder);
text_literal_holder **sorted = (text_literal_holder **)
(Memory::I7_calloc(no_tlh, sizeof(text_literal_holder *), CODE_GENERATION_MREASON));
int i = 0;
text_literal_holder *tlh;
LOOP_OVER(tlh, text_literal_holder) sorted[i++] = tlh;
qsort(sorted, (size_t) no_tlh, sizeof(text_literal_holder *),
CodeGen::compare_tlh);
for (int i=0; i<no_tlh; i++) {
text_literal_holder *tlh = sorted[i];
WRITE("! TLH %d <%S>\n", tlh->allocation_id, tlh->literal_content);
WRITE("%S", tlh->definition_code);
}
WRITE("%S", summations_at_eof);
WRITE("%S", attributes_at_eof);
WRITE("%S", arrays_at_eof);
@ -1581,6 +1614,16 @@ then the result.
WRITE(")");
@ =
int CodeGen::compare_tlh(const void *elem1, const void *elem2) {
const text_literal_holder **e1 = (const text_literal_holder **) elem1;
const text_literal_holder **e2 = (const text_literal_holder **) elem2;
if ((*e1 == NULL) || (*e2 == NULL))
internal_error("Disaster while sorting text literals");
text_stream *s1 = (*e1)->literal_content;
text_stream *s2 = (*e2)->literal_content;
return Str::cmp(s1, s2);
}
int CodeGen::compare_kind_symbols(const void *elem1, const void *elem2) {
const inter_symbol **e1 = (const inter_symbol **) elem1;
const inter_symbol **e2 = (const inter_symbol **) elem2;
@ -1665,14 +1708,25 @@ inter_t CodeGen::kind_of_object_count(inter_symbol *kind_name) {
return 0;
}
void CodeGen::append(OUTPUT_STREAM, inter_symbol *symb) {
void CodeGen::append(OUTPUT_STREAM, inter_repository *I, inter_symbol *symb) {
text_stream *S = Inter::Symbols::get_append(symb);
if (Str::len(S) == 0) return;
WRITE(" ");
LOOP_THROUGH_TEXT(P, S) {
wchar_t c = Str::get(P);
PUT(c);
if ((c == '\n') && (P.index != Str::len(S)-1)) WRITE(" ");
int L = Str::len(S);
for (int i=0; i<L; i++) {
wchar_t c = Str::get_at(S, i);
if (c == URL_SYMBOL_CHAR) {
TEMPORARY_TEXT(T);
for (i++; i<L; i++) {
wchar_t c = Str::get_at(S, i);
if (c == URL_SYMBOL_CHAR) break;
PUT_TO(T, c);
}
inter_symbol *symb = Inter::SymbolsTables::url_name_to_symbol(I, NULL, T);
WRITE("%S", CodeGen::name(symb));
DISCARD_TEXT(T);
} else PUT(c);
if ((c == '\n') && (i != Str::len(S)-1)) WRITE(" ");
}
}

View file

@ -619,7 +619,7 @@ because I6 doesn't allow function calls in a constant context.
WRITE("Class %S\n", CodeGen::name(kind_name));
inter_symbol *super_name = Inter::Kind::super(kind_name);
if (super_name) WRITE(" class %S\n", CodeGen::name(super_name));
CodeGen::append(OUT, kind_name);
CodeGen::append(OUT, I, kind_name);
inter_frame_list *FL =
Inter::find_frame_list(I, Inter::Kind::properties_list(kind_name));
CodeGen::IP::plist(OUT, I, FL);
@ -834,7 +834,7 @@ void CodeGen::IP::object_instance(OUTPUT_STREAM, inter_repository *I, inter_fram
WRITE("%S \"\"", CodeGen::name(inst_name));
if (Inter::Kind::is_a(inst_kind, direction_kind_symbol)) { WRITE(" Compass"); }
WRITE("\n class %S\n", CodeGen::name(inst_kind));
CodeGen::append(OUT, inst_name);
CodeGen::append(OUT, I, inst_name);
inter_frame_list *FL =
Inter::find_frame_list(
P.repo_segment->owning_repo,

View file

@ -87,6 +87,12 @@ inter_symbol *Inter::Packages::search_main_exhaustively(inter_repository *I, tex
return Inter::Packages::search_exhaustively(Inter::Packages::main(I), S);
}
inter_symbol *Inter::Packages::search_resources_exhaustively(inter_repository *I, text_stream *S) {
inter_symbol *res = Inter::Packages::search_main_exhaustively(I, I"resources");
if (res) return Inter::Packages::search_exhaustively(Inter::Package::which(res), S);
return NULL;
}
inter_t Inter::Packages::to_PID(inter_package *P) {
if (P == NULL) return 0;
return P->index_n;

View file

@ -9,6 +9,7 @@ inter_error_message *Inter::Verify::defn(inter_frame P, int index) {
if (S->equated_to) {
LOG("This is $6 but %S equates to a symbol in $6\n",
Inter::Packages::container(P), S->symbol_name, Inter::Packages::container(S->equated_to->definition));
internal_error("zap");
return Inter::Frame::error(&P, I"symbol defined outside its native scope", S->symbol_name);
}
inter_frame D = Inter::Symbols::defining_frame(S);

View file

@ -38,6 +38,7 @@ Defining the one true set of Inter annotation codes.
@e WEAK_ID_IANN
@e EXPLICIT_ATTRIBUTE_IANN
@e EXPLICIT_VARIABLE_IANN
@e TEXT_LITERAL_IANN
@ And also the canonical set of bits to use in the flags word for an Inter
symbol.
@ -88,4 +89,5 @@ void Inter::Canon::declare(void) {
Inter::Defn::create_annotation(WEAK_ID_IANN, I"__weak_ID", FALSE);
Inter::Defn::create_annotation(EXPLICIT_ATTRIBUTE_IANN, I"__explicit_attribute", FALSE);
Inter::Defn::create_annotation(EXPLICIT_VARIABLE_IANN, I"__explicit_variable", FALSE);
Inter::Defn::create_annotation(TEXT_LITERAL_IANN, I"__text_literal", FALSE);
}

View file

@ -389,7 +389,7 @@ object, rather inventing something like |O12_north| as it otherwise would.
=
Include (-
has scenery, ! class CompassDirection,
has scenery,
-) when defining a direction.
@ The Standard Rules define only thirteen I7 objects, and here we go with