2021-04-28 11:14:20 +03:00
|
|
|
[SynopticActivities::] Activities.
|
|
|
|
|
2021-05-06 11:59:32 +03:00
|
|
|
To compile the main/synoptic/activities submodule.
|
2021-04-28 11:14:20 +03:00
|
|
|
|
2022-01-07 01:10:15 +02:00
|
|
|
@ Our inventory |inv| already contains a list |inv->activity_nodes| of all packages
|
|
|
|
in the tree with type |_activity|.
|
2021-04-28 11:14:20 +03:00
|
|
|
|
|
|
|
=
|
2021-11-15 01:40:33 +02:00
|
|
|
void SynopticActivities::compile(inter_tree *I, pipeline_step *step, tree_inventory *inv) {
|
2022-02-03 01:35:38 +02:00
|
|
|
if (InterNodeList::array_len(inv->activity_nodes) > 0) @<Assign unique activity ID numbers@>;
|
2021-05-05 14:24:08 +03:00
|
|
|
@<Define ACTIVITY_AFTER_RULEBOOKS array@>;
|
|
|
|
@<Define ACTIVITY_BEFORE_RULEBOOKS array@>;
|
|
|
|
@<Define ACTIVITY_FOR_RULEBOOKS array@>;
|
|
|
|
@<Define ACTIVITY_VAR_CREATORS array@>;
|
2023-06-11 01:52:27 +03:00
|
|
|
@<Define ACTIVITY_FLAGS array@>;
|
2021-04-28 11:14:20 +03:00
|
|
|
}
|
|
|
|
|
2022-01-07 01:10:15 +02:00
|
|
|
@ Each activity package contains a numeric constant with the symbol name |activity_id|.
|
|
|
|
We want to ensure that these ID numbers are contiguous from 0 and never duplicated,
|
|
|
|
so we change the values of these constants accordingly.
|
|
|
|
|
|
|
|
In addition, each activity has an ID used to identify itself as the owner of a slate
|
|
|
|
of variables, and we set this to the activity ID plus 10000. (This scheme assumes
|
|
|
|
there are never more than 10000 rules, or 10000 activities, or 10000 actions.)
|
|
|
|
|
|
|
|
@<Assign unique activity ID numbers@> =
|
2022-02-03 01:35:38 +02:00
|
|
|
InterNodeList::array_sort(inv->activity_nodes, MakeSynopticModuleStage::module_order);
|
|
|
|
for (int i=0; i<InterNodeList::array_len(inv->activity_nodes); i++) {
|
2022-03-01 02:41:22 +02:00
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
2022-01-07 01:10:15 +02:00
|
|
|
inter_tree_node *D = Synoptic::get_definition(pack, I"activity_id");
|
2022-03-13 23:18:06 +02:00
|
|
|
ConstantInstruction::set_constant(D, InterValuePairs::number((inter_ti) i));
|
2022-01-07 01:10:15 +02:00
|
|
|
D = Synoptic::get_optional_definition(pack, I"var_id");
|
2022-03-13 23:18:06 +02:00
|
|
|
if (D) ConstantInstruction::set_constant(D,
|
2022-02-27 20:14:05 +02:00
|
|
|
InterValuePairs::number((inter_ti) i+10000));
|
2022-01-07 01:10:15 +02:00
|
|
|
}
|
|
|
|
|
2021-05-05 14:24:08 +03:00
|
|
|
@<Define ACTIVITY_AFTER_RULEBOOKS array@> =
|
2022-01-16 01:49:25 +02:00
|
|
|
inter_name *iname = HierarchyLocations::iname(I, ACTIVITY_AFTER_RULEBOOKS_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->activity_nodes); i++) {
|
2022-03-01 02:41:22 +02:00
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
2022-03-01 00:24:58 +02:00
|
|
|
inter_symbol *vc_s = Metadata::required_symbol(pack, I"^after_rulebook");
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::symbol_entry(vc_s);
|
2021-04-28 11:14:20 +03:00
|
|
|
}
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::end_array(I);
|
2021-04-28 11:14:20 +03:00
|
|
|
|
2021-05-05 14:24:08 +03:00
|
|
|
@<Define ACTIVITY_BEFORE_RULEBOOKS array@> =
|
2022-01-16 01:49:25 +02:00
|
|
|
inter_name *iname = HierarchyLocations::iname(I, ACTIVITY_BEFORE_RULEBOOKS_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->activity_nodes); i++) {
|
2022-03-01 02:41:22 +02:00
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
2022-03-01 00:24:58 +02:00
|
|
|
inter_symbol *vc_s = Metadata::required_symbol(pack, I"^before_rulebook");
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::symbol_entry(vc_s);
|
2021-04-28 11:14:20 +03:00
|
|
|
}
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::end_array(I);
|
2021-04-28 11:14:20 +03:00
|
|
|
|
2021-05-05 14:24:08 +03:00
|
|
|
@<Define ACTIVITY_FOR_RULEBOOKS array@> =
|
2022-01-16 01:49:25 +02:00
|
|
|
inter_name *iname = HierarchyLocations::iname(I, ACTIVITY_FOR_RULEBOOKS_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->activity_nodes); i++) {
|
2022-03-01 02:41:22 +02:00
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
2022-03-01 00:24:58 +02:00
|
|
|
inter_symbol *vc_s = Metadata::required_symbol(pack, I"^for_rulebook");
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::symbol_entry(vc_s);
|
2021-04-28 11:14:20 +03:00
|
|
|
}
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::end_array(I);
|
2021-04-28 11:14:20 +03:00
|
|
|
|
2021-05-05 14:24:08 +03:00
|
|
|
@<Define ACTIVITY_VAR_CREATORS array@> =
|
2022-01-16 01:49:25 +02:00
|
|
|
inter_name *iname = HierarchyLocations::iname(I, ACTIVITY_VAR_CREATORS_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->activity_nodes); i++) {
|
2022-03-01 02:41:22 +02:00
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
2022-03-01 00:24:58 +02:00
|
|
|
inter_symbol *vc_s = Metadata::optional_symbol(pack, I"^var_creator");
|
2021-05-05 14:24:08 +03:00
|
|
|
if (vc_s) Synoptic::symbol_entry(vc_s);
|
|
|
|
else Synoptic::numeric_entry(0);
|
2021-04-28 11:14:20 +03:00
|
|
|
}
|
2021-05-05 14:24:08 +03:00
|
|
|
Synoptic::end_array(I);
|
2023-06-11 01:52:27 +03:00
|
|
|
|
|
|
|
@<Define ACTIVITY_FLAGS array@> =
|
|
|
|
inter_name *iname = HierarchyLocations::iname(I, ACTIVITY_FLAGS_HL);
|
|
|
|
Synoptic::begin_byte_array(I, step, iname);
|
|
|
|
for (int i=0; i<InterNodeList::array_len(inv->activity_nodes); i++) {
|
|
|
|
inter_package *pack = PackageInstruction::at_this_head(inv->activity_nodes->list[i].node);
|
|
|
|
inter_ti flags = 0;
|
|
|
|
if (Metadata::read_numeric(pack, I"^used_by_future")) flags += 1;
|
|
|
|
if (Metadata::read_numeric(pack, I"^hide_in_debugging")) flags += 2;
|
|
|
|
Synoptic::numeric_entry(flags);
|
|
|
|
}
|
|
|
|
Synoptic::end_array(I);
|