1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-16 22:14:23 +03:00
inform7/inter/pipeline-module/Chapter 5/Verbs.w

51 lines
2.1 KiB
OpenEdge ABL
Raw Normal View History

2021-05-02 13:01:12 +03:00
[SynopticVerbs::] Verbs.
To compile the main/synoptic/verbs submodule.
2021-05-02 13:01:12 +03:00
@ Our inventory |inv| already contains a list |inv->verb_form_nodes| of all packages
in the tree with type |_verb_form|.
2021-05-02 13:01:12 +03:00
=
2021-11-15 01:40:33 +02:00
void SynopticVerbs::compile(inter_tree *I, pipeline_step *step, tree_inventory *inv) {
2022-02-03 01:35:38 +02:00
if (InterNodeList::array_len(inv->verb_form_nodes) > 0)
InterNodeList::array_sort(inv->verb_form_nodes, SynopticVerbs::form_order);
@<Define TABLEOFVERBS array@>;
2021-05-02 13:01:12 +03:00
}
@ Note that we sort these in a special order: by source category first (i.e., source
text, then built-in extensions, then other extensions) and then in order of creation
within the compiler. This doesn't vastly matter, though.
=
2021-05-02 13:01:12 +03:00
int SynopticVerbs::form_order(const void *ent1, const void *ent2) {
2022-02-03 01:35:38 +02:00
ina_entry *E1 = (ina_entry *) ent1;
ina_entry *E2 = (ina_entry *) ent2;
2021-05-02 13:01:12 +03:00
if (E1 == E2) return 0;
inter_tree_node *P1 = E1->node;
inter_tree_node *P2 = E2->node;
2022-01-05 01:10:34 +02:00
inter_package *mod1 = MakeSynopticModuleStage::module_containing(P1);
inter_package *mod2 = MakeSynopticModuleStage::module_containing(P2);
2021-05-02 13:01:12 +03:00
inter_ti C1 = Metadata::read_optional_numeric(mod1, I"^category");
inter_ti C2 = Metadata::read_optional_numeric(mod2, I"^category");
int d = ((int) C2) - ((int) C1); /* larger values sort earlier */
if (d != 0) return d;
2022-01-31 01:49:12 +02:00
inter_ti S1 = Metadata::read_optional_numeric(InterPackage::container(P1), I"^verb_sorting");
inter_ti S2 = Metadata::read_optional_numeric(InterPackage::container(P2), I"^verb_sorting");
2021-05-02 13:01:12 +03:00
d = ((int) S1) - ((int) S2); /* smaller values sort earlier */
if (d != 0) return d;
return E1->sort_key - E2->sort_key; /* smaller values sort earlier */
}
@<Define TABLEOFVERBS array@> =
2022-01-16 01:49:25 +02:00
inter_name *iname = HierarchyLocations::iname(I, TABLEOFVERBS_HL);
2021-11-15 01:40:33 +02:00
Synoptic::begin_array(I, step, iname);
2022-02-03 01:35:38 +02:00
for (int i=0; i<InterNodeList::array_len(inv->verb_form_nodes); i++) {
2022-03-01 02:41:22 +02:00
inter_package *pack = PackageInstruction::at_this_head(inv->verb_form_nodes->list[i].node);
inter_symbol *vc_s = Metadata::required_symbol(pack, I"^verb_value");
Synoptic::symbol_entry(vc_s);
2021-05-02 13:01:12 +03:00
}
Synoptic::numeric_entry(0);
Synoptic::end_array(I);