mirror of
https://github.com/ganelson/inform.git
synced 2024-07-05 16:44:21 +03:00
Simplfied inter name generation
This commit is contained in:
parent
ab5e7fb349
commit
4f267ab64c
|
@ -98,10 +98,8 @@ We need to itemise the structures we'll want to allocate:
|
|||
@e dval_written_MT
|
||||
@e nascent_array_MT
|
||||
@e value_holster_array_MT
|
||||
@e inter_namespace_MT
|
||||
@e inter_name_MT
|
||||
@e inter_name_family_MT
|
||||
@e inter_name_consumption_token_MT
|
||||
@e adjective_iname_holder_MT
|
||||
@e compilation_module_MT
|
||||
@e inter_schema_MT
|
||||
|
@ -143,10 +141,8 @@ ALLOCATE_INDIVIDUALLY(i6_memory_setting)
|
|||
ALLOCATE_INDIVIDUALLY(implication)
|
||||
ALLOCATE_INDIVIDUALLY(inference_subject)
|
||||
ALLOCATE_INDIVIDUALLY(instance)
|
||||
ALLOCATE_INDIVIDUALLY(inter_namespace)
|
||||
ALLOCATE_INDIVIDUALLY(inter_name)
|
||||
ALLOCATE_INDIVIDUALLY(inter_name_family)
|
||||
ALLOCATE_INDIVIDUALLY(inter_name_consumption_token)
|
||||
ALLOCATE_INDIVIDUALLY(internal_test_case)
|
||||
ALLOCATE_INDIVIDUALLY(inv_token_problem_token)
|
||||
ALLOCATE_INDIVIDUALLY(kind_interaction)
|
||||
|
|
|
@ -158,12 +158,22 @@ since Inform always compiles code which knows which kind it's looping over.
|
|||
|
||||
=
|
||||
inter_name *PL::Counting::first_instance(kind *K) {
|
||||
inter_name *iname = Hierarchy::derive_iname_in(FIRST_INSTANCE_HL, Kinds::RunTime::iname(K), Kinds::Behaviour::package(K));
|
||||
kind_constructor *con = Kinds::get_construct(K);
|
||||
inter_name *iname = Kinds::Constructors::first_instance_iname(con);
|
||||
if (iname == NULL) {
|
||||
iname = Hierarchy::derive_iname_in(FIRST_INSTANCE_HL, Kinds::RunTime::iname(K), Kinds::Behaviour::package(K));
|
||||
Kinds::Constructors::set_first_instance_iname(con, iname);
|
||||
}
|
||||
return iname;
|
||||
}
|
||||
|
||||
inter_name *PL::Counting::next_instance(kind *K) {
|
||||
inter_name *iname = Hierarchy::derive_iname_in(NEXT_INSTANCE_HL, Kinds::RunTime::iname(K), Kinds::Behaviour::package(K));
|
||||
kind_constructor *con = Kinds::get_construct(K);
|
||||
inter_name *iname = Kinds::Constructors::next_instance_iname(con);
|
||||
if (iname == NULL) {
|
||||
iname = Hierarchy::derive_iname_in(NEXT_INSTANCE_HL, Kinds::RunTime::iname(K), Kinds::Behaviour::package(K));
|
||||
Kinds::Constructors::set_next_instance_iname(con, iname);
|
||||
}
|
||||
return iname;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ generates labels |L_0|, |L_1|, ...
|
|||
|
||||
=
|
||||
typedef struct label_namespace {
|
||||
struct text_stream *base_prefix;
|
||||
struct text_stream *label_prefix;
|
||||
int label_counter; /* next free ID number for this label namespace */
|
||||
int allocate_storage; /* number of words of memory to reserve for each label */
|
||||
|
@ -42,9 +41,7 @@ label_namespace *JumpLabels::new_namespace(text_stream *name, compilation_module
|
|||
"a label namespace prefix is too long",
|
||||
"and should be shortened to a few alphabetic characters.");
|
||||
label_namespace *lns = CREATE(label_namespace);
|
||||
lns->base_prefix = Str::duplicate(name);
|
||||
lns->label_prefix = Str::new();
|
||||
WRITE_TO(lns->label_prefix, "%S%S", cm->namespace->namespace_prefix, name);
|
||||
lns->label_prefix = Str::duplicate(name);
|
||||
package_request *PR2 = Hierarchy::synoptic_package(LABEL_STORAGES_HAP);
|
||||
lns->label_storage_iname = Hierarchy::make_iname_in(LABEL_ASSOCIATED_STORAGE_HL, PR2);
|
||||
|
||||
|
@ -63,7 +60,7 @@ optimising.
|
|||
label_namespace *JumpLabels::namespace_by_prefix(text_stream *name, compilation_module *cm) {
|
||||
label_namespace *lns;
|
||||
LOOP_OVER(lns, label_namespace)
|
||||
if ((lns->module == cm) && (Str::eq(name, lns->base_prefix)))
|
||||
if ((lns->module == cm) && (Str::eq(name, lns->label_prefix)))
|
||||
return lns;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -127,6 +124,3 @@ void JumpLabels::compile_necessary_storage(void) {
|
|||
Packaging::exit(save);
|
||||
}
|
||||
}
|
||||
|
||||
void JumpLabels::reset(void) {
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ void Routines::begin_framed(inter_name *iname, ph_stack_frame *phsf) {
|
|||
internal_error("routine outside of package");
|
||||
}
|
||||
currently_compiling_iname = iname;
|
||||
JumpLabels::reset();
|
||||
|
||||
@<Prepare a suitable stack frame@>;
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
@ =
|
||||
typedef struct compilation_module {
|
||||
struct inter_namespace *namespace;
|
||||
struct package_request *resources;
|
||||
struct submodule_requests subpackages;
|
||||
struct parse_node *hanging_from;
|
||||
struct text_stream *abbreviation;
|
||||
MEMORY_MANAGEMENT
|
||||
} compilation_module;
|
||||
|
||||
|
@ -41,18 +41,14 @@ compilation_module *Modules::new(parse_node *from) {
|
|||
compilation_module *C = CREATE(compilation_module);
|
||||
C->hanging_from = from;
|
||||
C->resources = NULL;
|
||||
if (C->allocation_id == 0) C->namespace = InterNames::root();
|
||||
if (C->allocation_id == 0) C->abbreviation = I"root";
|
||||
else {
|
||||
C->abbreviation = Str::new();
|
||||
if (from == NULL) internal_error("unlocated CM");
|
||||
if (Modules::markable(from) == FALSE) internal_error("inappropriate CM");
|
||||
TEMPORARY_TEXT(pfx);
|
||||
char *x = "";
|
||||
if ((C->allocation_id == 1) && (export_mode)) x = "x";
|
||||
WRITE_TO(pfx, "m%s%d", x, C->allocation_id);
|
||||
C->namespace = InterNames::new_namespace(pfx);
|
||||
Str::clear(C->namespace->unmarked_prefix);
|
||||
WRITE_TO(C->namespace->unmarked_prefix, "m%d", C->allocation_id);
|
||||
DISCARD_TEXT(pfx);
|
||||
WRITE_TO(C->abbreviation, "m%s%d", x, C->allocation_id);
|
||||
ParseTree::set_module(from, C);
|
||||
Modules::propagate_downwards(from->down, C);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ inter_name *HierarchyLocations::find_by_name(text_stream *name) {
|
|||
}
|
||||
|
||||
inter_name *HierarchyLocations::function(package_request *R, text_stream *name, text_stream *trans) {
|
||||
inter_name *iname = Packaging::function(InterNames::one_off(name, R), R, NULL);
|
||||
inter_name *iname = Packaging::function(InterNames::make(name, R), R, NULL);
|
||||
if (trans) InterNames::change_translation(iname, trans);
|
||||
return iname;
|
||||
}
|
||||
|
@ -193,21 +193,21 @@ inter_name *HierarchyLocations::nrl_to_iname(named_resource_location *nrl) {
|
|||
}
|
||||
if (nrl->requirements.this_mundane_package == Hierarchy::template()) {
|
||||
packaging_state save = Packaging::enter(nrl->requirements.this_mundane_package);
|
||||
nrl->equates_to_iname = InterNames::one_off(nrl->access_name, Hierarchy::template());
|
||||
nrl->equates_to_iname = InterNames::make(nrl->access_name, Hierarchy::template());
|
||||
nrl->equates_to_iname->symbol = Emit::extern(nrl->access_name, K_value);
|
||||
Packaging::exit(save);
|
||||
} else if (Str::len(nrl->function_package_name) > 0) {
|
||||
nrl->equates_to_iname = Packaging::function_text(
|
||||
InterNames::one_off(nrl->function_package_name, nrl->requirements.this_mundane_package),
|
||||
InterNames::make(nrl->function_package_name, nrl->requirements.this_mundane_package),
|
||||
nrl->requirements.this_mundane_package,
|
||||
nrl->access_name);
|
||||
} else if (Str::len(nrl->datum_package_name) > 0) {
|
||||
nrl->equates_to_iname = Packaging::datum_text(
|
||||
InterNames::one_off(nrl->datum_package_name, nrl->requirements.this_mundane_package),
|
||||
InterNames::make(nrl->datum_package_name, nrl->requirements.this_mundane_package),
|
||||
nrl->requirements.this_mundane_package,
|
||||
nrl->access_name);
|
||||
} else if ((nrl->requirements.this_mundane_package) && (nrl->equates_to_iname == NULL)) {
|
||||
nrl->equates_to_iname = InterNames::one_off(nrl->access_name, nrl->requirements.this_mundane_package);
|
||||
nrl->equates_to_iname = InterNames::make(nrl->access_name, nrl->requirements.this_mundane_package);
|
||||
}
|
||||
|
||||
nrl->equates_to_iname = Hierarchy::post_process(nrl->access_number, nrl->equates_to_iname);
|
||||
|
@ -245,12 +245,7 @@ inter_name *HierarchyLocations::find_in_package(int id, package_request *P, word
|
|||
TEMPORARY_TEXT(T);
|
||||
inter_name *temp_iname = NULL;
|
||||
if (derive_from) {
|
||||
if (nrl->trans.faux_letter >= 0)
|
||||
temp_iname = InterNames::letter_parametrised_name_f(nrl->trans.name_generator, derive_from, nrl->trans.faux_letter, P);
|
||||
else
|
||||
temp_iname = InterNames::new_derived_f(nrl->trans.name_generator, derive_from);
|
||||
} else if (nrl->trans.localise) {
|
||||
temp_iname = InterNames::new_in_f(nrl->trans.name_generator, C, fix);
|
||||
temp_iname = InterNames::new_derived_f(nrl->trans.name_generator, derive_from);
|
||||
} else {
|
||||
temp_iname = InterNames::new_f(nrl->trans.name_generator, fix);
|
||||
}
|
||||
|
@ -259,8 +254,7 @@ inter_name *HierarchyLocations::find_in_package(int id, package_request *P, word
|
|||
W = EMPTY_WORDING;
|
||||
}
|
||||
WRITE_TO(T, "%n", temp_iname);
|
||||
if (nrl->trans.faux_letter >= 0) iname = temp_iname;
|
||||
else @<Make the actual iname@>;
|
||||
@<Make the actual iname@>;
|
||||
DISCARD_TEXT(T);
|
||||
} else {
|
||||
text_stream *T = NULL;
|
||||
|
@ -274,13 +268,13 @@ inter_name *HierarchyLocations::find_in_package(int id, package_request *P, word
|
|||
@<Make the actual iname@> =
|
||||
if (Str::len(nrl->function_package_name) > 0) {
|
||||
iname = Packaging::function_text(
|
||||
InterNames::one_off(nrl->function_package_name, P),
|
||||
InterNames::make(nrl->function_package_name, P),
|
||||
P,
|
||||
NULL);
|
||||
} else {
|
||||
if (nrl->trans.by_imposition) iname = InterNames::one_off(imposed_name, P);
|
||||
else if (Str::len(nrl->access_name) == 0) iname = InterNames::one_off(T, P);
|
||||
else iname = InterNames::one_off(nrl->access_name, P);
|
||||
if (nrl->trans.by_imposition) iname = InterNames::make(imposed_name, P);
|
||||
else if (Str::len(nrl->access_name) == 0) iname = InterNames::make(T, P);
|
||||
else iname = InterNames::make(nrl->access_name, P);
|
||||
}
|
||||
if (!Wordings::empty(W)) InterNames::attach_memo(iname, W);
|
||||
if ((Str::len(T) > 0) && (nrl->access_name)) InterNames::change_translation(iname, T);
|
||||
|
@ -302,7 +296,7 @@ package_request *HierarchyLocations::package_in_package(int id, package_request
|
|||
internal_error("subpackage not in enclosing superpackage");
|
||||
} else internal_error("NRL accessed inappropriately");
|
||||
|
||||
return Packaging::request(InterNames::one_off(nrl->access_name, P), P, nrl->package_type);
|
||||
return Packaging::request(InterNames::make(nrl->access_name, P), P, nrl->package_type);
|
||||
}
|
||||
|
||||
=
|
||||
|
|
|
@ -596,8 +596,8 @@ void Hierarchy::establish(void) {
|
|||
HierarchyLocations::func(DEFAULT_CLOSURE_FN_HL, I"default_closure_fn", Translation::uniqued(), in_kind);
|
||||
HierarchyLocations::func(GPR_FN_HL, I"gpr_fn", Translation::uniqued(), in_kind);
|
||||
HierarchyLocations::func(INSTANCE_GPR_FN_HL, I"instance_gpr_fn", Translation::uniqued(), in_kind);
|
||||
HierarchyLocations::con(FIRST_INSTANCE_HL, NULL, Translation::suffix_special(I"_First", FIRST_INSTANCE_INDERIV), in_kind);
|
||||
HierarchyLocations::con(NEXT_INSTANCE_HL, NULL, Translation::suffix_special(I"_Next", NEXT_INSTANCE_INDERIV), in_kind);
|
||||
HierarchyLocations::con(FIRST_INSTANCE_HL, NULL, Translation::suffix(I"_First"), in_kind);
|
||||
HierarchyLocations::con(NEXT_INSTANCE_HL, NULL, Translation::suffix(I"_Next"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_1_HL, NULL, Translation::to(I"IK1_Count"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_2_HL, NULL, Translation::to(I"IK2_Count"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_3_HL, NULL, Translation::to(I"IK3_Count"), in_kind);
|
||||
|
@ -608,7 +608,7 @@ void Hierarchy::establish(void) {
|
|||
HierarchyLocations::con(COUNT_INSTANCE_8_HL, NULL, Translation::to(I"IK8_Count"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_9_HL, NULL, Translation::to(I"IK9_Count"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_10_HL, NULL, Translation::to(I"IK10_Count"), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_HL, NULL, Translation::suffix_special(I"_Count", COUNT_INSTANCE_INDERIV), in_kind);
|
||||
HierarchyLocations::con(COUNT_INSTANCE_HL, NULL, Translation::suffix(I"_Count"), in_kind);
|
||||
HierarchyLocations::ap(KIND_INLINE_PROPERTIES_HAP, in_kind, I"inline_property", I"_inline_property");
|
||||
location_requirement in_kind_inline_property = HierarchyLocations::any_package_of_type(I"_inline_property");
|
||||
HierarchyLocations::con(KIND_INLINE_PROPERTY_HL, I"inline", Translation::uniqued(), in_kind_inline_property);
|
||||
|
@ -661,7 +661,7 @@ void Hierarchy::establish(void) {
|
|||
HierarchyLocations::con(CLOSURE_DATA_HL, I"closure_data", Translation::uniqued(), in_closure);
|
||||
HierarchyLocations::ap(REQUESTS_HAP, in_to_phrase, I"request", I"_request");
|
||||
location_requirement in_request = HierarchyLocations::any_package_of_type(I"_request");
|
||||
HierarchyLocations::func(PHRASE_FN_HL, I"phrase_fn", Translation::generate_in(I"REQ"), in_request);
|
||||
HierarchyLocations::func(PHRASE_FN_HL, I"phrase_fn", Translation::uniqued(), in_request);
|
||||
|
||||
location_requirement synoptic_phrases = HierarchyLocations::synoptic_submodule(phrases);
|
||||
HierarchyLocations::ap(LABEL_STORAGES_HAP, synoptic_phrases, I"label_storage", I"_label_storage");
|
||||
|
@ -830,8 +830,8 @@ void Hierarchy::establish(void) {
|
|||
location_requirement local_rules = HierarchyLocations::local_submodule(rules);
|
||||
HierarchyLocations::ap(RULES_HAP, local_rules, I"rule", I"_rule");
|
||||
location_requirement in_rule = HierarchyLocations::any_package_of_type(I"_rule");
|
||||
HierarchyLocations::func(SHELL_FN_HL, I"shell_fn", Translation::generate_in(I"I6_Rule_Shell"), in_rule);
|
||||
HierarchyLocations::func(RULE_FN_HL, I"rule_fn", Translation::generate_in(I"R"), in_rule);
|
||||
HierarchyLocations::func(SHELL_FN_HL, I"shell_fn", Translation::uniqued(), in_rule);
|
||||
HierarchyLocations::func(RULE_FN_HL, I"rule_fn", Translation::uniqued(), in_rule);
|
||||
HierarchyLocations::con(EXTERIOR_RULE_HL, I"exterior_rule", Translation::uniqued(), in_rule);
|
||||
HierarchyLocations::func(RESPONDER_FN_HL, I"responder_fn", Translation::suffix(I"M"), in_rule);
|
||||
HierarchyLocations::ap(RESPONSES_HAP, in_rule, I"response", I"_response");
|
||||
|
@ -1554,7 +1554,7 @@ inter_name *Hierarchy::find(int id) {
|
|||
}
|
||||
|
||||
void Hierarchy::make_available(inter_name *iname) {
|
||||
HierarchyLocations::make_as(-1, InterNames::to_symbol(iname)->symbol_name, iname);
|
||||
HierarchyLocations::make_as(-1, InterNames::to_text(iname), iname);
|
||||
}
|
||||
|
||||
inter_name *Hierarchy::find_by_name(text_stream *name) {
|
||||
|
@ -1570,7 +1570,7 @@ inter_name *Hierarchy::find_by_name(text_stream *name) {
|
|||
package_request *main_pr = NULL;
|
||||
package_request *Hierarchy::main(void) {
|
||||
if (main_pr == NULL)
|
||||
main_pr = Packaging::request(InterNames::one_off(I"main", NULL), NULL, plain_ptype);
|
||||
main_pr = Packaging::request(InterNames::make(I"main", NULL), NULL, plain_ptype);
|
||||
return main_pr;
|
||||
}
|
||||
|
||||
|
@ -1578,7 +1578,7 @@ package_request *resources_pr = NULL;
|
|||
package_request *Hierarchy::resources(void) {
|
||||
if (resources_pr == NULL)
|
||||
resources_pr = Packaging::request(
|
||||
InterNames::one_off(I"resources", Hierarchy::main()),
|
||||
InterNames::make(I"resources", Hierarchy::main()),
|
||||
Hierarchy::main(), plain_ptype);
|
||||
return resources_pr;
|
||||
}
|
||||
|
@ -1587,7 +1587,7 @@ package_request *template_pr = NULL;
|
|||
package_request *Hierarchy::template(void) {
|
||||
if (template_pr == NULL)
|
||||
template_pr = Packaging::request(
|
||||
InterNames::one_off(I"template", Hierarchy::resources()),
|
||||
InterNames::make(I"template", Hierarchy::resources()),
|
||||
Hierarchy::resources(), module_ptype);
|
||||
return template_pr;
|
||||
}
|
||||
|
|
|
@ -3,129 +3,74 @@
|
|||
@
|
||||
|
||||
@e UNIQUE_FUSAGE from 1
|
||||
@e UNIQUE_PER_NAMESPACE_FUSAGE
|
||||
@e MANY_PER_NAMESPACE_FUSAGE
|
||||
@e MULTIPLE_FUSAGE
|
||||
@e DERIVED_FUSAGE
|
||||
|
||||
=
|
||||
typedef struct inter_namespace {
|
||||
struct text_stream *namespace_prefix;
|
||||
struct text_stream *unmarked_prefix;
|
||||
int exporting;
|
||||
MEMORY_MANAGEMENT
|
||||
} inter_namespace;
|
||||
|
||||
inter_namespace *root_namespace = NULL;
|
||||
|
||||
typedef struct inter_name_family {
|
||||
int fusage;
|
||||
struct text_stream *family_name;
|
||||
struct inter_name_consumption_token *first_ict;
|
||||
int no_consumed;
|
||||
struct inter_name_family *derivative_of;
|
||||
struct text_stream *derived_prefix;
|
||||
struct text_stream *derived_suffix;
|
||||
int mark_exports;
|
||||
MEMORY_MANAGEMENT
|
||||
} inter_name_family;
|
||||
|
||||
typedef struct inter_name_consumption_token {
|
||||
struct inter_namespace *for_namespace;
|
||||
int no_consumed;
|
||||
struct inter_name_consumption_token *next_ict;
|
||||
MEMORY_MANAGEMENT
|
||||
} inter_name_consumption_token;
|
||||
|
||||
typedef struct inter_name {
|
||||
struct inter_namespace *namespace;
|
||||
struct inter_name_family *family;
|
||||
int unique_number;
|
||||
struct inter_symbol *symbol;
|
||||
struct package_request *eventual_owner;
|
||||
struct text_stream *memo;
|
||||
struct text_stream *override;
|
||||
struct inter_name *derived_from;
|
||||
struct inter_name **parametrised_derivatives;
|
||||
struct compilation_module *declared_in;
|
||||
int to_mark;
|
||||
MEMORY_MANAGEMENT
|
||||
} inter_name;
|
||||
|
||||
@ =
|
||||
inter_namespace *InterNames::new_namespace(text_stream *prefix) {
|
||||
inter_namespace *S = CREATE(inter_namespace);
|
||||
S->namespace_prefix = Str::duplicate(prefix);
|
||||
S->unmarked_prefix = Str::duplicate(prefix);
|
||||
S->exporting = FALSE;
|
||||
return S;
|
||||
}
|
||||
|
||||
inter_namespace *InterNames::root(void) {
|
||||
if (root_namespace == NULL) root_namespace = InterNames::new_namespace(NULL);
|
||||
return root_namespace;
|
||||
}
|
||||
|
||||
inter_name_family *InterNames::new_family(int fu, text_stream *name) {
|
||||
inter_name_family *F = CREATE(inter_name_family);
|
||||
F->fusage = fu;
|
||||
F->family_name = Str::duplicate(name);
|
||||
F->first_ict = NULL;
|
||||
F->derivative_of = NULL;
|
||||
F->derived_prefix = NULL;
|
||||
F->derived_suffix = NULL;
|
||||
F->mark_exports = TRUE;
|
||||
return F;
|
||||
}
|
||||
|
||||
inter_name_consumption_token *InterNames::new_ict(inter_namespace *S) {
|
||||
if (S == NULL) internal_error("no namespace");
|
||||
inter_name_consumption_token *T = CREATE(inter_name_consumption_token);
|
||||
T->for_namespace = S;
|
||||
T->no_consumed = 1;
|
||||
T->next_ict = NULL;
|
||||
return T;
|
||||
}
|
||||
|
||||
inter_name *InterNames::new_in_space(inter_namespace *S, inter_name_family *F, int suppress_count) {
|
||||
if (S == NULL) internal_error("no namespace");
|
||||
inter_name *InterNames::make_in_family(inter_name_family *F, int suppress_count) {
|
||||
if (F == NULL) internal_error("no family");
|
||||
inter_name *N = CREATE(inter_name);
|
||||
N->namespace = S;
|
||||
N->family = F;
|
||||
N->unique_number = 0;
|
||||
if (F->fusage == UNIQUE_FUSAGE) internal_error("not a family name");
|
||||
if ((F->fusage != DERIVED_FUSAGE) && (suppress_count == FALSE)) {
|
||||
inter_name_consumption_token *ict = F->first_ict;
|
||||
if (ict == NULL) {
|
||||
F->first_ict = InterNames::new_ict(S);
|
||||
N->unique_number = 1;
|
||||
} else {
|
||||
while (ict) {
|
||||
if (ict->for_namespace == S) {
|
||||
if (F->fusage == UNIQUE_PER_NAMESPACE_FUSAGE) internal_error("one per namespace, please");
|
||||
N->unique_number = ++ict->no_consumed;
|
||||
break;
|
||||
}
|
||||
if (ict->next_ict == NULL) {
|
||||
ict->next_ict = InterNames::new_ict(S);
|
||||
N->unique_number = 1;
|
||||
break;
|
||||
}
|
||||
ict = ict->next_ict;
|
||||
}
|
||||
}
|
||||
N->unique_number = ++F->no_consumed;
|
||||
}
|
||||
N->symbol = NULL;
|
||||
N->memo = NULL;
|
||||
N->derived_from = NULL;
|
||||
N->parametrised_derivatives = NULL;
|
||||
N->declared_in = NULL;
|
||||
N->to_mark = 0;
|
||||
N->eventual_owner = Hierarchy::main();
|
||||
return N;
|
||||
}
|
||||
|
||||
inter_name *InterNames::make(text_stream *name, package_request *R) {
|
||||
inter_name_family *F = InterNames::new_family(UNIQUE_FUSAGE, name);
|
||||
inter_name *N = CREATE(inter_name);
|
||||
N->family = F;
|
||||
N->unique_number = 1;
|
||||
N->symbol = NULL;
|
||||
N->memo = NULL;
|
||||
N->derived_from = NULL;
|
||||
N->parametrised_derivatives = NULL;
|
||||
N->eventual_owner = R;
|
||||
return N;
|
||||
}
|
||||
|
||||
inter_name_family *InterNames::name_generator(text_stream *prefix, text_stream *stem, text_stream *suffix) {
|
||||
int fusage = MANY_PER_NAMESPACE_FUSAGE;
|
||||
int fusage = MULTIPLE_FUSAGE;
|
||||
if ((Str::len(prefix) > 0) || (Str::len(suffix) > 0)) fusage = DERIVED_FUSAGE;
|
||||
inter_name_family *family = InterNames::new_family(fusage, stem);
|
||||
if (Str::len(prefix) > 0) family->derived_prefix = Str::duplicate(prefix);
|
||||
|
@ -133,23 +78,6 @@ inter_name_family *InterNames::name_generator(text_stream *prefix, text_stream *
|
|||
return family;
|
||||
}
|
||||
|
||||
inter_name *InterNames::one_off(text_stream *name, package_request *R) {
|
||||
inter_name_family *F = InterNames::new_family(UNIQUE_FUSAGE, name);
|
||||
inter_name *N = CREATE(inter_name);
|
||||
N->namespace = InterNames::root();
|
||||
N->family = F;
|
||||
N->unique_number = 1;
|
||||
N->symbol = NULL;
|
||||
N->memo = NULL;
|
||||
N->override = NULL;
|
||||
N->derived_from = NULL;
|
||||
N->parametrised_derivatives = NULL;
|
||||
N->declared_in = NULL;
|
||||
N->to_mark = 0;
|
||||
N->eventual_owner = R;
|
||||
return N;
|
||||
}
|
||||
|
||||
void InterNames::attach_memo(inter_name *N, wording W) {
|
||||
if (N->symbol) internal_error("too late to attach memo");
|
||||
N->memo = Str::new();
|
||||
|
@ -180,16 +108,13 @@ text_stream *InterNames::get_translation(inter_name *N) {
|
|||
}
|
||||
|
||||
inter_symbol *InterNames::to_symbol(inter_name *N) {
|
||||
if (N->symbol) {
|
||||
if (N->to_mark) Inter::Symbols::set_flag(N->symbol, N->to_mark);
|
||||
return N->symbol;
|
||||
if (N->symbol == NULL) {
|
||||
TEMPORARY_TEXT(NBUFF);
|
||||
WRITE_TO(NBUFF, "%n", N);
|
||||
inter_symbols_table *T = Packaging::scope(Emit::repository(), N);
|
||||
N->symbol = Emit::new_symbol(T, NBUFF);
|
||||
DISCARD_TEXT(NBUFF);
|
||||
}
|
||||
TEMPORARY_TEXT(NBUFF);
|
||||
WRITE_TO(NBUFF, "%n", N);
|
||||
inter_symbols_table *T = Packaging::scope(Emit::repository(), N);
|
||||
N->symbol = Emit::new_symbol(T, NBUFF);
|
||||
DISCARD_TEXT(NBUFF);
|
||||
if (N->to_mark) Inter::Symbols::set_flag(N->symbol, N->to_mark);
|
||||
return N->symbol;
|
||||
}
|
||||
|
||||
|
@ -236,9 +161,7 @@ void InterNames::writer(OUTPUT_STREAM, char *format_string, void *vI) {
|
|||
inter_name *N = (inter_name *) vI;
|
||||
if (N == NULL) WRITE("<no-inter-name>");
|
||||
else {
|
||||
if ((N->family == NULL) || (N->namespace == NULL)) internal_error("bad inter_name");
|
||||
text_stream *NP = N->namespace->namespace_prefix;
|
||||
if (N->family->mark_exports == FALSE) NP = N->namespace->unmarked_prefix;
|
||||
if (N->family == NULL) internal_error("bad inter_name");
|
||||
switch (N->family->fusage) {
|
||||
case DERIVED_FUSAGE:
|
||||
WRITE("%S", N->family->derived_prefix);
|
||||
|
@ -248,12 +171,7 @@ void InterNames::writer(OUTPUT_STREAM, char *format_string, void *vI) {
|
|||
case UNIQUE_FUSAGE:
|
||||
WRITE("%S", N->family->family_name);
|
||||
break;
|
||||
case UNIQUE_PER_NAMESPACE_FUSAGE:
|
||||
if (Str::len(NP) > 0) WRITE("%S_", NP);
|
||||
WRITE("%S", N->family->family_name);
|
||||
break;
|
||||
case MANY_PER_NAMESPACE_FUSAGE:
|
||||
if (Str::len(NP) > 0) WRITE("%S_", NP);
|
||||
case MULTIPLE_FUSAGE:
|
||||
WRITE("%S", N->family->family_name);
|
||||
if (N->unique_number >= 0) WRITE("%d", N->unique_number);
|
||||
break;
|
||||
|
@ -310,63 +228,19 @@ int InterNames::defined(inter_name *iname) {
|
|||
}
|
||||
|
||||
inter_name *InterNames::new_f(inter_name_family *F, int fix) {
|
||||
inter_name *iname = InterNames::new_in_space(InterNames::root(), F, FALSE);
|
||||
inter_name *iname = InterNames::make_in_family(F, FALSE);
|
||||
if (fix != -1) iname->unique_number = fix;
|
||||
return iname;
|
||||
}
|
||||
|
||||
inter_name *InterNames::new_in_f(inter_name_family *F, compilation_module *C, int fix) {
|
||||
if (C == NULL) return InterNames::new_f(F, fix);
|
||||
inter_name *iname = InterNames::new_in_space(C->namespace, F, FALSE);
|
||||
if (fix != -1) iname->unique_number = fix;
|
||||
InterNames::mark(F, iname, C);
|
||||
return iname;
|
||||
}
|
||||
|
||||
void InterNames::mark(inter_name_family *F, inter_name *iname, compilation_module *C) {
|
||||
iname->declared_in = C;
|
||||
}
|
||||
|
||||
compilation_module *InterNames::to_module(inter_name *iname) {
|
||||
if (iname == NULL) return NULL;
|
||||
return iname->declared_in;
|
||||
}
|
||||
|
||||
inter_name *InterNames::new_derived_f(inter_name_family *F, inter_name *from) {
|
||||
if (F->fusage != DERIVED_FUSAGE) internal_error("not a derived family");
|
||||
inter_name *N = InterNames::new_in_space(InterNames::root(), F, TRUE);
|
||||
inter_name *N = InterNames::make_in_family(F, TRUE);
|
||||
Packaging::house_with(N, from);
|
||||
N->derived_from = from;
|
||||
compilation_module *C = InterNames::to_module(from);
|
||||
InterNames::mark(F, N, C);
|
||||
return N;
|
||||
}
|
||||
|
||||
@
|
||||
|
||||
@e FIRST_INSTANCE_INDERIV from 26
|
||||
@e COUNT_INSTANCE_INDERIV
|
||||
@e NEXT_INSTANCE_INDERIV
|
||||
|
||||
@e FINAL_INDERIV
|
||||
|
||||
inter_name *InterNames::letter_parametrised_name_f(inter_name_family *family, inter_name *rname, int marker, package_request *R) {
|
||||
if (rname == NULL) internal_error("can't parametrise null name");
|
||||
if (rname->parametrised_derivatives == NULL) {
|
||||
rname->parametrised_derivatives =
|
||||
Memory::I7_calloc(FINAL_INDERIV, sizeof(inter_name *), INTER_SYMBOLS_MREASON);
|
||||
for (int i=0; i<FINAL_INDERIV; i++) rname->parametrised_derivatives[i] = NULL;
|
||||
}
|
||||
if ((marker < 0) || (marker >= FINAL_INDERIV)) internal_error("respomse parameter out of range");
|
||||
if (rname->parametrised_derivatives[marker] == NULL) {
|
||||
rname->parametrised_derivatives[marker] = InterNames::new_f(family, -1);
|
||||
if (R) Packaging::house(rname->parametrised_derivatives[marker], R);
|
||||
rname->parametrised_derivatives[marker]->derived_from = rname;
|
||||
}
|
||||
|
||||
return rname->parametrised_derivatives[marker];
|
||||
}
|
||||
|
||||
void InterNames::override_action_base_iname(inter_name *ab_iname, text_stream *to) {
|
||||
ab_iname->family->family_name = Str::duplicate(to);
|
||||
Str::clear(ab_iname->memo);
|
||||
|
|
|
@ -176,7 +176,7 @@ package_request *generic_pr = NULL;
|
|||
package_request *Packaging::request_generic(void) {
|
||||
if (generic_pr == NULL)
|
||||
generic_pr = Packaging::request(
|
||||
InterNames::one_off(I"generic", Hierarchy::resources()),
|
||||
InterNames::make(I"generic", Hierarchy::resources()),
|
||||
Hierarchy::resources(), module_ptype);
|
||||
return generic_pr;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ package_request *synoptic_pr = NULL;
|
|||
package_request *Packaging::request_synoptic(void) {
|
||||
if (synoptic_pr == NULL)
|
||||
synoptic_pr = Packaging::request(
|
||||
InterNames::one_off(I"synoptic", Hierarchy::resources()),
|
||||
InterNames::make(I"synoptic", Hierarchy::resources()),
|
||||
Hierarchy::resources(), module_ptype);
|
||||
return synoptic_pr;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ typedef struct submodule_requests {
|
|||
} submodule_requests;
|
||||
|
||||
package_request *Packaging::resources_for_new_submodule(text_stream *name, submodule_requests *SR) {
|
||||
inter_name *package_iname = InterNames::one_off(name, Hierarchy::resources());
|
||||
inter_name *package_iname = InterNames::make(name, Hierarchy::resources());
|
||||
package_request *P = Packaging::request(package_iname, Hierarchy::resources(), module_ptype);
|
||||
Packaging::initialise_submodules(SR);
|
||||
return P;
|
||||
|
@ -274,7 +274,7 @@ package_request *Packaging::synoptic_resource(submodule_identity *sid) {
|
|||
LOOP_OVER_LINKED_LIST(sr, submodule_request, SR->submodules)
|
||||
if (sid == sr->which_submodule)
|
||||
return sr->where_found;
|
||||
inter_name *iname = InterNames::one_off(sid->submodule_name, parent);
|
||||
inter_name *iname = InterNames::make(sid->submodule_name, parent);
|
||||
sr = CREATE(submodule_request);
|
||||
sr->which_submodule = sid;
|
||||
sr->where_found = Packaging::request(iname, parent, plain_ptype);
|
||||
|
@ -315,14 +315,14 @@ inter_name *Packaging::supply_iname(package_request *R, int what_for) {
|
|||
}
|
||||
TEMPORARY_TEXT(P);
|
||||
WRITE_TO(P, "%S_%d", pr_counter_names[what_for], N);
|
||||
inter_name *iname = InterNames::one_off(P, R);
|
||||
inter_name *iname = InterNames::make(P, R);
|
||||
DISCARD_TEXT(P);
|
||||
return iname;
|
||||
}
|
||||
|
||||
inter_name *Packaging::function(inter_name *function_iname, package_request *R2, inter_name *temp_iname) {
|
||||
package_request *R3 = Packaging::request(function_iname, R2, function_ptype);
|
||||
inter_name *iname = InterNames::one_off(I"call", R3);
|
||||
inter_name *iname = InterNames::make(I"call", R3);
|
||||
Packaging::house(iname, R3);
|
||||
if (temp_iname) {
|
||||
TEMPORARY_TEXT(T);
|
||||
|
@ -335,7 +335,7 @@ inter_name *Packaging::function(inter_name *function_iname, package_request *R2,
|
|||
|
||||
inter_name *Packaging::function_text(inter_name *function_iname, package_request *R2, text_stream *translation) {
|
||||
package_request *R3 = Packaging::request(function_iname, R2, function_ptype);
|
||||
inter_name *iname = InterNames::one_off(I"call", R3);
|
||||
inter_name *iname = InterNames::make(I"call", R3);
|
||||
Packaging::house(iname, R3);
|
||||
if (translation)
|
||||
InterNames::change_translation(iname, translation);
|
||||
|
@ -344,7 +344,7 @@ inter_name *Packaging::function_text(inter_name *function_iname, package_request
|
|||
|
||||
inter_name *Packaging::datum_text(inter_name *function_iname, package_request *R2, text_stream *translation) {
|
||||
package_request *R3 = Packaging::request(function_iname, R2, data_ptype);
|
||||
inter_name *iname = InterNames::one_off(translation, R3);
|
||||
inter_name *iname = InterNames::make(translation, R3);
|
||||
Packaging::house(iname, R3);
|
||||
return iname;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@ typedef struct name_translation {
|
|||
struct text_stream *translate_to;
|
||||
int then_make_unique;
|
||||
struct inter_name_family *name_generator;
|
||||
int localise;
|
||||
int derive;
|
||||
int by_imposition;
|
||||
int faux_letter;
|
||||
} name_translation;
|
||||
|
||||
name_translation Translation::same(void) {
|
||||
|
@ -18,10 +16,8 @@ name_translation Translation::same(void) {
|
|||
nt.translate_to = NULL;
|
||||
nt.then_make_unique = FALSE;
|
||||
nt.name_generator = NULL;
|
||||
nt.localise = FALSE;
|
||||
nt.derive = FALSE;
|
||||
nt.by_imposition = FALSE;
|
||||
nt.faux_letter = -1;
|
||||
return nt;
|
||||
}
|
||||
|
||||
|
@ -64,23 +60,8 @@ name_translation Translation::suffix(text_stream *S) {
|
|||
return nt;
|
||||
}
|
||||
|
||||
name_translation Translation::suffix_special(text_stream *S, int faux_letter) {
|
||||
name_translation nt = Translation::same();
|
||||
nt.name_generator = InterNames::name_generator(NULL, NULL, S);
|
||||
nt.derive = TRUE;
|
||||
nt.faux_letter = faux_letter;
|
||||
return nt;
|
||||
}
|
||||
|
||||
name_translation Translation::generate(text_stream *S) {
|
||||
name_translation nt = Translation::same();
|
||||
nt.name_generator = InterNames::name_generator(NULL, S, NULL);
|
||||
return nt;
|
||||
}
|
||||
|
||||
name_translation Translation::generate_in(text_stream *S) {
|
||||
name_translation nt = Translation::same();
|
||||
nt.name_generator = InterNames::name_generator(NULL, S, NULL);
|
||||
nt.localise = TRUE;
|
||||
return nt;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,8 @@ typedef struct kind_constructor {
|
|||
#ifdef INTER_MODULE
|
||||
struct inter_name *kind_GPR_iname;
|
||||
struct inter_name *instance_GPR_iname;
|
||||
struct inter_name *first_instance_iname;
|
||||
struct inter_name *next_instance_iname;
|
||||
struct inter_name *pr_iname;
|
||||
struct inter_name *inc_iname;
|
||||
struct inter_name *dec_iname;
|
||||
|
@ -270,6 +272,8 @@ I6 template files.
|
|||
#ifdef INTER_MODULE
|
||||
con->kind_GPR_iname = NULL;
|
||||
con->instance_GPR_iname = NULL;
|
||||
con->first_instance_iname = NULL;
|
||||
con->next_instance_iname = NULL;
|
||||
con->pr_iname = NULL;
|
||||
con->inc_iname = NULL;
|
||||
con->dec_iname = NULL;
|
||||
|
@ -401,6 +405,18 @@ inter_name *Kinds::Constructors::iname(kind_constructor *con) {
|
|||
if (UNKNOWN_TY_iname == NULL) internal_error("no con symbols yet");
|
||||
return con->con_iname;
|
||||
}
|
||||
inter_name *Kinds::Constructors::first_instance_iname(kind_constructor *con) {
|
||||
return con->first_instance_iname;
|
||||
}
|
||||
void Kinds::Constructors::set_first_instance_iname(kind_constructor *con, inter_name *iname) {
|
||||
con->first_instance_iname = iname;
|
||||
}
|
||||
inter_name *Kinds::Constructors::next_instance_iname(kind_constructor *con) {
|
||||
return con->next_instance_iname;
|
||||
}
|
||||
void Kinds::Constructors::set_next_instance_iname(kind_constructor *con, inter_name *iname) {
|
||||
con->next_instance_iname = iname;
|
||||
}
|
||||
#endif
|
||||
|
||||
text_stream *Kinds::Constructors::name_in_template_code(kind_constructor *con) {
|
||||
|
|
Loading…
Reference in a new issue