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

Tidied the front door of the if module

This commit is contained in:
Graham Nelson 2021-02-24 11:13:27 +00:00
parent 6b8726060d
commit 7e10a73748
7 changed files with 160 additions and 153 deletions

View file

@ -224,6 +224,85 @@ DECLARE_CLASS(index_element)
DECLARE_CLASS(index_page) DECLARE_CLASS(index_page)
DECLARE_CLASS(index_lexicon_entry) DECLARE_CLASS(index_lexicon_entry)
@ //if// --
@e action_name_CLASS
@e auxiliary_file_CLASS
@e backdrop_found_in_notice_CLASS
@e cached_understanding_CLASS
@e command_index_entry_CLASS
@e connected_submap_CLASS
@e direction_inference_data_CLASS
@e door_dir_notice_CLASS
@e door_to_notice_CLASS
@e EPS_map_level_CLASS
@e found_in_inference_data_CLASS
@e grammar_line_CLASS
@e grammar_verb_CLASS
@e loop_over_scope_CLASS
@e map_data_CLASS
@e named_action_pattern_CLASS
@e noun_filter_token_CLASS
@e parentage_here_inference_data_CLASS
@e parentage_inference_data_CLASS
@e parse_name_notice_CLASS
@e parsing_data_CLASS
@e parsing_pp_data_CLASS
@e part_of_inference_data_CLASS
@e regions_data_CLASS
@e release_instructions_CLASS
@e reserved_command_verb_CLASS
@e rubric_holder_CLASS
@e scene_CLASS
@e slash_gpr_CLASS
@e spatial_data_CLASS
@e action_name_list_CLASS
@e action_pattern_CLASS
@e ap_optional_clause_CLASS
@e scene_connector_CLASS
@e understanding_item_CLASS
@e understanding_reference_CLASS
=
DECLARE_CLASS(action_name)
DECLARE_CLASS(auxiliary_file)
DECLARE_CLASS(backdrop_found_in_notice)
DECLARE_CLASS(cached_understanding)
DECLARE_CLASS(command_index_entry)
DECLARE_CLASS(connected_submap)
DECLARE_CLASS(direction_inference_data)
DECLARE_CLASS(door_dir_notice)
DECLARE_CLASS(door_to_notice)
DECLARE_CLASS(EPS_map_level)
DECLARE_CLASS(found_in_inference_data)
DECLARE_CLASS(grammar_line)
DECLARE_CLASS(grammar_verb)
DECLARE_CLASS(loop_over_scope)
DECLARE_CLASS(map_data)
DECLARE_CLASS(named_action_pattern)
DECLARE_CLASS(noun_filter_token)
DECLARE_CLASS(parentage_here_inference_data)
DECLARE_CLASS(parentage_inference_data)
DECLARE_CLASS(parse_name_notice)
DECLARE_CLASS(parsing_data)
DECLARE_CLASS(parsing_pp_data)
DECLARE_CLASS(part_of_inference_data)
DECLARE_CLASS(regions_data)
DECLARE_CLASS(release_instructions)
DECLARE_CLASS(reserved_command_verb)
DECLARE_CLASS(rubric_holder)
DECLARE_CLASS(scene)
DECLARE_CLASS(slash_gpr)
DECLARE_CLASS(spatial_data)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(action_name_list, 1000)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(action_pattern, 100)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(ap_optional_clause, 400)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(scene_connector, 1000)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(understanding_item, 100)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(understanding_reference, 100)
@ //multimedia// -- @ //multimedia// --
@e figures_data_CLASS @e figures_data_CLASS

View file

@ -153,7 +153,7 @@ so on. Those absolute basics are made here.
-1, debugging, sequence_timer); -1, debugging, sequence_timer);
BENCH(Measurements::validate_definitions) BENCH(Measurements::validate_definitions)
BENCH(BinaryPredicateFamilies::second_stock) BENCH(BinaryPredicateFamilies::second_stock)
BENCH(PL::Player::InitialSituation) // BENCH(PL::Player::InitialSituation)
BENCH(Tables::check_tables_for_kind_clashes) BENCH(Tables::check_tables_for_kind_clashes)
BENCH(RTTables::compile_print_table_names) BENCH(RTTables::compile_print_table_names)
BENCH(PL::Parsing::traverse) BENCH(PL::Parsing::traverse)
@ -249,7 +249,6 @@ so on. Those absolute basics are made here.
BENCH(RTKinds::compile_structures) BENCH(RTKinds::compile_structures)
BENCH(Rules::check_response_usages) BENCH(Rules::check_response_usages)
BENCH(Phrases::Timed::check_for_unused) BENCH(Phrases::Timed::check_for_unused)
BENCH(PL::Showme::compile_SHOWME_details)
BENCH(Phrases::Timed::TimedEventsTable) BENCH(Phrases::Timed::TimedEventsTable)
BENCH(Phrases::Timed::TimedEventTimesTable) BENCH(Phrases::Timed::TimedEventTimesTable)
BENCH(RTUseOptions::configure_template) BENCH(RTUseOptions::configure_template)

View file

@ -2,111 +2,11 @@
Setting up the use of this module. Setting up the use of this module.
@ This section simoly sets up the module in ways expected by //foundation//, and @ The following constant exists only in tools which use this module:
contains no code of interest. The following constant exists only in tools
which use this module:
@d IF_MODULE TRUE @d IF_MODULE TRUE
@ This module defines the following classes: @ Like all modules, this has a start and end function:
@e action_name_CLASS
@e auxiliary_file_CLASS
@e backdrop_found_in_notice_CLASS
@e cached_understanding_CLASS
@e command_index_entry_CLASS
@e connected_submap_CLASS
@e direction_inference_data_CLASS
@e door_dir_notice_CLASS
@e door_to_notice_CLASS
@e EPS_map_level_CLASS
@e found_in_inference_data_CLASS
@e grammar_line_CLASS
@e grammar_verb_CLASS
@e loop_over_scope_CLASS
@e map_data_CLASS
@e named_action_pattern_CLASS
@e noun_filter_token_CLASS
@e parentage_here_inference_data_CLASS
@e parentage_inference_data_CLASS
@e parse_name_notice_CLASS
@e parsing_data_CLASS
@e parsing_pp_data_CLASS
@e part_of_inference_data_CLASS
@e regions_data_CLASS
@e release_instructions_CLASS
@e reserved_command_verb_CLASS
@e rubric_holder_CLASS
@e scene_CLASS
@e slash_gpr_CLASS
@e spatial_data_CLASS
@e action_name_list_CLASS
@e action_pattern_CLASS
@e ap_optional_clause_CLASS
@e scene_connector_CLASS
@e understanding_item_CLASS
@e understanding_reference_CLASS
=
DECLARE_CLASS(action_name)
DECLARE_CLASS(auxiliary_file)
DECLARE_CLASS(backdrop_found_in_notice)
DECLARE_CLASS(cached_understanding)
DECLARE_CLASS(command_index_entry)
DECLARE_CLASS(connected_submap)
DECLARE_CLASS(direction_inference_data)
DECLARE_CLASS(door_dir_notice)
DECLARE_CLASS(door_to_notice)
DECLARE_CLASS(EPS_map_level)
DECLARE_CLASS(found_in_inference_data)
DECLARE_CLASS(grammar_line)
DECLARE_CLASS(grammar_verb)
DECLARE_CLASS(loop_over_scope)
DECLARE_CLASS(map_data)
DECLARE_CLASS(named_action_pattern)
DECLARE_CLASS(noun_filter_token)
DECLARE_CLASS(parentage_here_inference_data)
DECLARE_CLASS(parentage_inference_data)
DECLARE_CLASS(parse_name_notice)
DECLARE_CLASS(parsing_data)
DECLARE_CLASS(parsing_pp_data)
DECLARE_CLASS(part_of_inference_data)
DECLARE_CLASS(regions_data)
DECLARE_CLASS(release_instructions)
DECLARE_CLASS(reserved_command_verb)
DECLARE_CLASS(rubric_holder)
DECLARE_CLASS(scene)
DECLARE_CLASS(slash_gpr)
DECLARE_CLASS(spatial_data)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(action_name_list, 1000)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(action_pattern, 100)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(ap_optional_clause, 400)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(scene_connector, 1000)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(understanding_item, 100)
DECLARE_CLASS_ALLOCATED_IN_ARRAYS(understanding_reference, 100)
@h Plugins.
Note that the "if" plugin itself does nothihg except to be a parent
to all these others; it doesn't even have an activation function.
=
plugin *if_plugin,
*spatial_plugin, *map_plugin, *persons_plugin,
*player_plugin, *regions_plugin, *backdrops_plugin,
*devices_plugin, *showme_plugin,
*times_plugin, *scenes_plugin, *scoring_plugin,
*bibliographic_plugin;
@
= (early code)
plugin *parsing_plugin, *chronology_plugin, *actions_plugin;
@h The beginning.
(The client doesn't need to call the start and end routines, because the
foundation module does that automatically.)
= =
COMPILE_WRITER(action_pattern *, PL::Actions::Patterns::log) COMPILE_WRITER(action_pattern *, PL::Actions::Patterns::log)
@ -116,7 +16,7 @@ COMPILE_WRITER(action_name_list *, PL::Actions::ConstantLists::log)
COMPILE_WRITER(action_name *, PL::Actions::log) COMPILE_WRITER(action_name *, PL::Actions::log)
void IFModule::start(void) { void IFModule::start(void) {
@<Create this module's plugins@>; IFModule::create_plugins();
@<Register this module's debugging log aspects@>; @<Register this module's debugging log aspects@>;
@<Register this module's debugging log writers@>; @<Register this module's debugging log writers@>;
ReleaseInstructions::start(); ReleaseInstructions::start();
@ -124,29 +24,6 @@ void IFModule::start(void) {
PL::SpatialRelations::start(); PL::SpatialRelations::start();
PL::MapDirections::start(); PL::MapDirections::start();
} }
void IFModule::end(void) {
}
@<Create this module's plugins@> =
if_plugin = PluginManager::new(NULL, I"interactive fiction", NULL);
spatial_plugin = PluginManager::new(&PL::Spatial::start, I"spatial model", if_plugin);
map_plugin = PluginManager::new(&PL::Map::start, I"mapping", if_plugin);
persons_plugin = PluginManager::new(&PL::Persons::start, I"persons", if_plugin);
player_plugin = PluginManager::new(&PL::Player::start, I"player", if_plugin);
scoring_plugin = PluginManager::new(&PL::Score::start, I"scoring", if_plugin);
regions_plugin = PluginManager::new(&PL::Regions::start, I"regions", if_plugin);
backdrops_plugin = PluginManager::new(&PL::Backdrops::start, I"backdrops", if_plugin);
devices_plugin = PluginManager::new(&PL::Devices::start, I"devices", if_plugin);
showme_plugin = PluginManager::new(&PL::Showme::start, I"showme", if_plugin);
times_plugin = PluginManager::new(TimesOfDay::start, I"times of day", if_plugin);
scenes_plugin = PluginManager::new(&PL::Scenes::start, I"scenes", if_plugin);
bibliographic_plugin = PluginManager::new(&BibliographicData::start, I"bibliographic data", if_plugin);
chronology_plugin = PluginManager::new(&Chronology::start_plugin, I"chronology", if_plugin);
actions_plugin = PluginManager::new(&ActionsPlugin::start, I"actions", if_plugin);
parsing_plugin = PluginManager::new(&ParsingPlugin::start, I"command", if_plugin);
@ @
@ -161,7 +38,8 @@ void IFModule::end(void) {
@<Register this module's debugging log aspects@> = @<Register this module's debugging log aspects@> =
Log::declare_aspect(ACTION_CREATIONS_DA, L"action creations", FALSE, FALSE); Log::declare_aspect(ACTION_CREATIONS_DA, L"action creations", FALSE, FALSE);
Log::declare_aspect(ACTION_PATTERN_COMPILATION_DA, L"action pattern compilation", FALSE, FALSE); Log::declare_aspect(ACTION_PATTERN_COMPILATION_DA, L"action pattern compilation",
FALSE, FALSE);
Log::declare_aspect(ACTION_PATTERN_PARSING_DA, L"action pattern parsing", FALSE, FALSE); Log::declare_aspect(ACTION_PATTERN_PARSING_DA, L"action pattern parsing", FALSE, FALSE);
Log::declare_aspect(GRAMMAR_DA, L"grammar", FALSE, FALSE); Log::declare_aspect(GRAMMAR_DA, L"grammar", FALSE, FALSE);
Log::declare_aspect(GRAMMAR_CONSTRUCTION_DA, L"grammar construction", FALSE, FALSE); Log::declare_aspect(GRAMMAR_CONSTRUCTION_DA, L"grammar construction", FALSE, FALSE);
@ -175,3 +53,41 @@ void IFModule::end(void) {
REGISTER_WRITER('g', PL::Parsing::Lines::log); REGISTER_WRITER('g', PL::Parsing::Lines::log);
REGISTER_WRITER('L', PL::Actions::ConstantLists::log); REGISTER_WRITER('L', PL::Actions::ConstantLists::log);
REGISTER_WRITER('l', PL::Actions::log); REGISTER_WRITER('l', PL::Actions::log);
@ =
void IFModule::end(void) {
}
@h Plugins.
Except for the current minimal section of code, the //if// module is comprised
of the following plugins. They all belong to an "if" plugin, but that does
nothing except to be a parent to them; it has no activation function.
= (early code)
plugin *actions_plugin, *backdrops_plugin, *bibliographic_plugin, *chronology_plugin,
*devices_plugin, *map_plugin, *parsing_plugin, *persons_plugin, *player_plugin,
*regions_plugin, *scenes_plugin, *scoring_plugin, *showme_plugin, *spatial_plugin,
*times_plugin;
@ =
void IFModule::create_plugins(void) {
plugin *ifp = PluginManager::new(NULL, I"interactive fiction", NULL);
backdrops_plugin = PluginManager::new(&PL::Backdrops::start, I"backdrops", ifp);
bibliographic_plugin = PluginManager::new(&BibliographicData::start, I"bibliographic data", ifp);
chronology_plugin = PluginManager::new(&Chronology::start_plugin, I"chronology", ifp);
devices_plugin = PluginManager::new(&PL::Devices::start, I"devices", ifp);
map_plugin = PluginManager::new(&PL::Map::start, I"mapping", ifp);
persons_plugin = PluginManager::new(&PL::Persons::start, I"persons", ifp);
player_plugin = PluginManager::new(&PL::Player::start, I"player", ifp);
regions_plugin = PluginManager::new(&PL::Regions::start, I"regions", ifp);
scenes_plugin = PluginManager::new(&PL::Scenes::start, I"scenes", ifp);
scoring_plugin = PluginManager::new(&PL::Score::start, I"scoring", ifp);
showme_plugin = PluginManager::new(&PL::Showme::start, I"showme", ifp);
spatial_plugin = PluginManager::new(&PL::Spatial::start, I"spatial model", ifp);
times_plugin = PluginManager::new(TimesOfDay::start, I"times of day", ifp);
actions_plugin = PluginManager::new(&ActionsPlugin::start, I"actions", ifp);
parsing_plugin = PluginManager::new(&ParsingPlugin::start, I"command", ifp);
}

View file

@ -107,8 +107,7 @@ int PL::Backdrops::backdrops_new_base_kind_notify(kind *new_base, text_stream *n
@ = @ =
int PL::Backdrops::object_is_a_backdrop(instance *I) { int PL::Backdrops::object_is_a_backdrop(instance *I) {
if ((PluginManager::active(regions_plugin)) && (K_backdrop) && (I) && if ((K_backdrop) && (I) && (Instances::of_kind(I, K_backdrop))) return TRUE;
(Instances::of_kind(I, K_backdrop))) return TRUE;
return FALSE; return FALSE;
} }

View file

@ -116,8 +116,7 @@ int PL::Regions::regions_set_subkind_notify(kind *sub, kind *super) {
@ = @ =
int PL::Regions::object_is_a_region(instance *I) { int PL::Regions::object_is_a_region(instance *I) {
if ((PluginManager::active(regions_plugin)) && (K_region) && (I) && if ((K_region) && (I) && (Instances::of_kind(I, K_region))) return TRUE;
(Instances::of_kind(I, K_region))) return TRUE;
return FALSE; return FALSE;
} }

View file

@ -8,6 +8,15 @@ plugged in.
= =
void PL::Showme::start(void) { void PL::Showme::start(void) {
PluginManager::plug(PRODUCTION_LINE_PLUG, PL::Showme::production_line);
}
int PL::Showme::production_line(int stage, int debugging,
stopwatch_timer *sequence_timer) {
if (stage == INTER5_CSEQ) {
BENCH(PL::Showme::compile_SHOWME_details)
}
return FALSE;
} }
@h Support for the SHOWME command. @h Support for the SHOWME command.
@ -23,7 +32,6 @@ properties.
= =
void PL::Showme::compile_SHOWME_details(void) { void PL::Showme::compile_SHOWME_details(void) {
if (PluginManager::active(showme_plugin) == FALSE) return;
inter_name *iname = Hierarchy::find(SHOWMEDETAILS_HL); inter_name *iname = Hierarchy::find(SHOWMEDETAILS_HL);
packaging_state save = Routines::begin(iname); packaging_state save = Routines::begin(iname);
inter_symbol *t_0_s = LocalVariables::add_named_call_as_symbol(I"t_0"); inter_symbol *t_0_s = LocalVariables::add_named_call_as_symbol(I"t_0");

View file

@ -27,6 +27,7 @@ nonlocal_variable *score_VAR = NULL;
= =
void PL::Player::start(void) { void PL::Player::start(void) {
PluginManager::plug(PRODUCTION_LINE_PLUG, PL::Player::production_line);
PluginManager::plug(NEW_VARIABLE_NOTIFY_PLUG, PL::Player::player_new_quantity_notify); PluginManager::plug(NEW_VARIABLE_NOTIFY_PLUG, PL::Player::player_new_quantity_notify);
PluginManager::plug(VARIABLE_VALUE_NOTIFY_PLUG, PL::Player::player_variable_set_warning); PluginManager::plug(VARIABLE_VALUE_NOTIFY_PLUG, PL::Player::player_variable_set_warning);
PluginManager::plug(NEW_INSTANCE_NOTIFY_PLUG, PL::Player::player_new_instance_notify); PluginManager::plug(NEW_INSTANCE_NOTIFY_PLUG, PL::Player::player_new_instance_notify);
@ -37,6 +38,14 @@ void PL::Player::start(void) {
PluginManager::plug(ANNOTATE_IN_WORLD_INDEX_PLUG, PL::Player::player_annotate_in_World_index); PluginManager::plug(ANNOTATE_IN_WORLD_INDEX_PLUG, PL::Player::player_annotate_in_World_index);
} }
int PL::Player::production_line(int stage, int debugging,
stopwatch_timer *sequence_timer) {
if (stage == TABLES_CSEQ) {
BENCH(PL::Player::InitialSituation);
}
return FALSE;
}
@h Special objects. @h Special objects.
The "yourself" object is special in being tied, or "aliased", to the The "yourself" object is special in being tied, or "aliased", to the
"player" variable, so Inform needs to recognise it. (No need to translate; it "player" variable, so Inform needs to recognise it. (No need to translate; it
@ -342,25 +351,23 @@ void PL::Player::InitialSituation_define(int id, int val) {
} }
void PL::Player::InitialSituation(void) { void PL::Player::InitialSituation(void) {
if (PluginManager::active(player_plugin)) { PL::Player::InitialSituation_define(PLAYER_OBJECT_INIS_HL, 0);
PL::Player::InitialSituation_define(PLAYER_OBJECT_INIS_HL, 0); PL::Player::InitialSituation_define(START_OBJECT_INIS_HL, 1);
PL::Player::InitialSituation_define(START_OBJECT_INIS_HL, 1); PL::Player::InitialSituation_define(START_ROOM_INIS_HL, 2);
PL::Player::InitialSituation_define(START_ROOM_INIS_HL, 2); PL::Player::InitialSituation_define(START_TIME_INIS_HL, 3);
PL::Player::InitialSituation_define(START_TIME_INIS_HL, 3); PL::Player::InitialSituation_define(DONE_INIS_HL, 4);
PL::Player::InitialSituation_define(DONE_INIS_HL, 4);
inter_name *iname = Hierarchy::find(INITIALSITUATION_HL);
inter_name *iname = Hierarchy::find(INITIALSITUATION_HL); packaging_state save = Emit::named_array_begin(iname, K_value);
packaging_state save = Emit::named_array_begin(iname, K_value); RTVariables::emit_initial_value(player_VAR);
RTVariables::emit_initial_value(player_VAR); if (start_object == NULL) Emit::array_numeric_entry(0);
if (start_object == NULL) Emit::array_numeric_entry(0); else Emit::array_iname_entry(RTInstances::iname(start_object));
else Emit::array_iname_entry(RTInstances::iname(start_object)); if (start_room == NULL) Emit::array_numeric_entry(0);
if (start_room == NULL) Emit::array_numeric_entry(0); else Emit::array_iname_entry(RTInstances::iname(start_room));
else Emit::array_iname_entry(RTInstances::iname(start_room)); RTVariables::emit_initial_value(time_of_day_VAR);
RTVariables::emit_initial_value(time_of_day_VAR); Emit::array_numeric_entry(0);
Emit::array_numeric_entry(0); Emit::array_end(save);
Emit::array_end(save); Hierarchy::make_available(Emit::tree(), iname);
Hierarchy::make_available(Emit::tree(), iname);
}
} }
@h World Index details. @h World Index details.