1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-26 04:00:43 +03:00

Divided code generation as a new skill

This commit is contained in:
Graham Nelson 2020-02-24 09:48:40 +00:00
parent 1e730e6d63
commit 6d37e9db46
6 changed files with 60 additions and 36 deletions

View file

@ -65,8 +65,7 @@ int BuildSteps::execute(build_vertex *V, build_step *S, build_methodology *meth)
int rv = TRUE;
TEMPORARY_TEXT(command);
VMETHOD_CALL(S->what_to_do, BUILD_SKILL_COMMAND_MTID, S, command, meth);
if (Str::len(command) == 0) rv = FALSE;
if (rv) rv = BuildSteps::shell(command, meth);
if ((rv) && (Str::len(command) > 0)) rv = BuildSteps::shell(command, meth);
if ((rv) && (meth->methodology == INTERNAL_METHODOLOGY)) {
int returned = 0;
IMETHOD_CALL(returned, S->what_to_do, BUILD_SKILL_INTERNAL_MTID, S, meth);

View file

@ -43,7 +43,8 @@ int Inform7Skill::inform7_via_shell(build_skill *skill, build_step *S, text_stre
int Inform7Skill::inform7_internally(build_skill *skill, build_step *S, build_methodology *meth) {
#ifdef CORE_MODULE
return CoreMain::task(S);
int rv = CoreMain::task(S);
return rv;
#endif
return FALSE;
}

View file

@ -4,11 +4,14 @@ A build step is a task such as running inform7 or inblorb on some file.
@ =
build_skill *assimilate_using_inter_skill = NULL;
build_skill *code_generate_using_inter_skill = NULL;
void InterSkill::create(void) {
assimilate_using_inter_skill = BuildSteps::new_skill(I"assimilate using inter");
METHOD_ADD(assimilate_using_inter_skill, BUILD_SKILL_COMMAND_MTID, InterSkill::assimilate_via_shell);
METHOD_ADD(assimilate_using_inter_skill, BUILD_SKILL_INTERNAL_MTID, InterSkill::assimilate_internally);
code_generate_using_inter_skill = BuildSteps::new_skill(I"code generate using inter");
METHOD_ADD(code_generate_using_inter_skill, BUILD_SKILL_INTERNAL_MTID, InterSkill::code_generate_internally);
}
int InterSkill::assimilate_via_shell(build_skill *skill, build_step *S, text_stream *command, build_methodology *meth) {
@ -70,3 +73,11 @@ int InterSkill::assimilate_internally(build_skill *skill, build_step *S, build_m
#endif
return FALSE;
}
int InterSkill::code_generate_internally(build_skill *skill, build_step *S, build_methodology *meth) {
#ifdef CORE_MODULE
int rv = CoreMain::task2(S);
return rv;
#endif
return FALSE;
}

View file

@ -254,10 +254,16 @@ void Projects::construct_build_target(inform_project *project, target_vm *VM,
pathname *build_folder = NULL;
if (proj) build_folder = Pathnames::subfolder(proj, I"Build");
filename *memory_F = Filenames::in_folder(build_folder, I"memory.interb");
build_vertex *inter_V = Graphs::file_vertex(memory_F);
Graphs::need_this_to_build(inter_V, project->as_copy->vertex);
BuildSteps::attach(inter_V, compile_using_inform7_skill,
Inbuild::nest_list(), releasing, VM, NULL, project->as_copy);
filename *inf_F = Filenames::in_folder(build_folder, I"auto.inf");
build_vertex *inf_V = Graphs::file_vertex(inf_F);
Graphs::need_this_to_build(inf_V, project->as_copy->vertex);
BuildSteps::attach(inf_V, compile_using_inform7_skill,
Graphs::need_this_to_build(inf_V, inter_V);
BuildSteps::attach(inf_V, code_generate_using_inter_skill,
Inbuild::nest_list(), releasing, VM, NULL, project->as_copy);
TEMPORARY_TEXT(story_file_leafname);

View file

@ -28,15 +28,10 @@ it compiles the phrases and grammar to go with it.
|model_world_constructed| records which of these halves we are
currently in: |FALSE| in the first half, |TRUE| in the second.
If there were a third stage, it would be indexing, and during that
period |indexing_stage| is |TRUE|. But by that time the compilation of
Inform 6 code is complete.
=
int text_loaded_from_source = FALSE; /* Lexical scanning is done */
int model_world_under_construction = FALSE; /* World model is being constructed */
int model_world_constructed = FALSE; /* World model is now constructed */
int indexing_stage = FALSE; /* Everything is done except indexing */
@ =
time_t right_now;
@ -61,6 +56,7 @@ int CoreMain::main(int argc, char *argv[]) {
BuildMethodology::new(NULL, FALSE, INTERNAL_METHODOLOGY));
}
}
@<Post mortem logging@>;
@<Shutdown and rennab@>;
if (problem_count > 0) Problems::Fatal::exit(1);
return 0;
@ -136,6 +132,26 @@ list is not exhaustive.
CommandLine::play_back_log();
Problems::Issue::start_problems_report();
@<Post mortem logging@> =
if (problem_count == 0) {
TemplateReader::report_unacted_upon_interventions();
// ParseTreeUsage::write_main_source_to_log();
// Memory::log_statistics();
// Preform::log_language();
// Index::DocReferences::log_statistics();
// NewVerbs::log_all();
}
@<Shutdown and rennab@> =
if (proceed) {
Problems::write_reports(FALSE);
LOG("Total of %d files written as streams.\n", total_file_writes);
Writers::log_escape_usage();
WRITE_TO(STDOUT, "%s has finished.\n", HUMAN_READABLE_INTOOL_NAME);
}
@ =
int CoreMain::task(build_step *S) {
inform_project *project = ProjectBundleManager::from_copy(S->associated_copy);
@ -150,12 +166,24 @@ int CoreMain::task(build_step *S) {
@<Tables and grammar@>;
@<Phrases and rules@>;
@<Generate inter@>;
@<Convert inter to Inform 6@>;
@<Generate metadata@>;
@<Post mortem logging@>;
@<Generate index and bibliographic file@>;
clock_t end = clock();
int cpu_time_used = ((int) (end - start)) / (CLOCKS_PER_SEC/100);
LOG("CPU time: %d centiseconds\n", cpu_time_used);
LOG("Compile CPU time: %d centiseconds\n", cpu_time_used);
if (problem_count > 0) return FALSE;
return TRUE;
}
int CoreMain::task2(build_step *S) {
inform_project *project = ProjectBundleManager::from_copy(S->associated_copy);
if (project == NULL) project = ProjectFileManager::from_copy(S->associated_copy);
if (project == NULL) internal_error("no project");
clock_t start = clock();
@<Convert inter to Inform 6@>;
clock_t end = clock();
int cpu_time_used = ((int) (end - start)) / (CLOCKS_PER_SEC/100);
LOG("Code generation CPU time: %d centiseconds\n", cpu_time_used);
if (problem_count > 0) return FALSE;
return TRUE;
}
@ -429,32 +457,12 @@ with "Output.i6t".
@ Metadata.
@<Generate metadata@> =
@<Generate index and bibliographic file@> =
if (Plugins::Manage::plugged_in(bibliographic_plugin))
PL::Bibliographic::Release::write_ifiction_and_blurb();
if (problem_count == 0)
NaturalLanguages::produce_index();
@<Post mortem logging@> =
if (problem_count == 0) {
TemplateReader::report_unacted_upon_interventions();
// ParseTreeUsage::write_main_source_to_log();
// Memory::log_statistics();
// Preform::log_language();
// Index::DocReferences::log_statistics();
// NewVerbs::log_all();
}
@<Shutdown and rennab@> =
if (proceed) {
Problems::write_reports(FALSE);
LOG("Total of %d files written as streams.\n", total_file_writes);
Writers::log_escape_usage();
WRITE_TO(STDOUT, "%s has finished.\n", HUMAN_READABLE_INTOOL_NAME);
}
@ =
int no_log_phases = 0;

View file

@ -85,7 +85,6 @@ text_stream *Index::open_file(text_stream *index_leaf, text_stream *title, int s
"../Actions.html");
HTML_TAG("hr");
} else @<Write the periodic table@>;
indexing_stage = TRUE;
if ((Str::get_first_char(title) != '<') && (Str::eq_wide_string(index_leaf, L"Welcome.html") == FALSE))
@<Write the index elements@>;
return OUT;