mirror of
https://github.com/ganelson/inform.git
synced 2024-07-02 23:14:57 +03:00
Inter packaging of grammar-related functions improved
This commit is contained in:
parent
fe4c6ec41b
commit
12c21dd494
|
@ -281,6 +281,7 @@ package_request *Packaging::request_synoptic(void) {
|
|||
@e RULEBOOKS_SUBPACKAGE
|
||||
@e ACTIVITIES_SUBPACKAGE
|
||||
@e RELATIONS_SUBPACKAGE
|
||||
@e GRAMMAR_SUBPACKAGE
|
||||
|
||||
@e MAX_SUBPACKAGE
|
||||
|
||||
|
@ -350,6 +351,7 @@ package_request *Packaging::synoptic_resource(int ix) {
|
|||
case RULEBOOKS_SUBPACKAGE: N = I"rulebooks"; break;
|
||||
case ACTIVITIES_SUBPACKAGE: N = I"activities"; break;
|
||||
case RELATIONS_SUBPACKAGE: N = I"relations"; break;
|
||||
case GRAMMAR_SUBPACKAGE: N = I"grammar"; break;
|
||||
default: internal_error("nameless resource");
|
||||
}
|
||||
inter_name *iname = InterNames::one_off(N, parent);
|
||||
|
|
|
@ -24,7 +24,14 @@ properties.
|
|||
=
|
||||
void PL::Showme::compile_SHOWME_details(void) {
|
||||
if (Plugins::Manage::plugged_in(showme_plugin) == FALSE) return;
|
||||
Routines::begin(InterNames::iname(ShowMeDetails_INAME));
|
||||
package_request *R = Packaging::synoptic_resource(KINDS_SUBPACKAGE);
|
||||
inter_name *ShowMeDetails_iname =
|
||||
Packaging::function(
|
||||
InterNames::one_off(I"ShowMeDetails_fn", R),
|
||||
R,
|
||||
InterNames::iname(ShowMeDetails_INAME));
|
||||
packaging_state save = Packaging::enter_home_of(ShowMeDetails_iname);
|
||||
Routines::begin(ShowMeDetails_iname);
|
||||
inter_symbol *t_0_s = LocalVariables::add_named_call_as_symbol(I"t_0");
|
||||
inter_symbol *na_s = LocalVariables::add_named_call_as_symbol(I"na");
|
||||
Emit::inv_primitive(ifdebug_interp);
|
||||
|
@ -36,6 +43,7 @@ void PL::Showme::compile_SHOWME_details(void) {
|
|||
Emit::up();
|
||||
Emit::up();
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
}
|
||||
|
||||
void PL::Showme::compile_SHOWME_type(int val, inter_symbol *t_0_s, inter_symbol *na_s) {
|
||||
|
|
|
@ -1186,7 +1186,14 @@ void PL::Actions::ActionData(void) {
|
|||
Emit::named_numeric_constant(InterNames::iname(AD_RECORDS_INAME), (inter_t) record_count);
|
||||
VirtualMachines::note_usage("action", EMPTY_WORDING, NULL, 12, 0, TRUE);
|
||||
|
||||
Routines::begin(InterNames::iname(DB_Action_Details_INAME));
|
||||
package_request *R = Packaging::synoptic_resource(ACTIONS_SUBPACKAGE);
|
||||
inter_name *DB_Action_Details_iname =
|
||||
Packaging::function(
|
||||
InterNames::one_off(I"DB_Action_Details_fn", R),
|
||||
R,
|
||||
InterNames::iname(DB_Action_Details_INAME));
|
||||
packaging_state save = Packaging::enter_home_of(DB_Action_Details_iname);
|
||||
Routines::begin(DB_Action_Details_iname);
|
||||
inter_symbol *act_s = LocalVariables::add_named_call_as_symbol(I"act");
|
||||
inter_symbol *n_s = LocalVariables::add_named_call_as_symbol(I"n");
|
||||
inter_symbol *s_s = LocalVariables::add_named_call_as_symbol(I"s");
|
||||
|
@ -1279,6 +1286,7 @@ void PL::Actions::ActionData(void) {
|
|||
Emit::up();
|
||||
Emit::up();
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
}
|
||||
|
||||
@<Insert a space here if needed to break up the action name@> =
|
||||
|
|
|
@ -55,8 +55,13 @@ inter_name *PL::Parsing::Tokens::General::print_consultation_gv_name(void) {
|
|||
|
||||
inter_name *PL::Parsing::Tokens::General::consult_iname(grammar_verb *gv) {
|
||||
if (gv->gv_consult_iname == NULL) {
|
||||
gv->gv_consult_iname =
|
||||
InterNames::new_in(CONSULT_GRAMMAR_INAMEF, Modules::current());
|
||||
inter_name *c_iname = InterNames::new(CONSULT_GRAMMAR_INAMEF);
|
||||
compilation_module *C = Modules::find(current_sentence);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
gv->gv_consult_iname = Packaging::function(
|
||||
InterNames::one_off(I"consult_fn", PR),
|
||||
PR,
|
||||
c_iname);
|
||||
}
|
||||
return gv->gv_consult_iname;
|
||||
}
|
||||
|
@ -84,7 +89,13 @@ will simply compile a |parse_name| routine inline, in the usual I6 way.
|
|||
=
|
||||
inter_name *PL::Parsing::Tokens::General::get_gv_parse_name(grammar_verb *gv) {
|
||||
if (gv->gv_parse_name_iname == NULL) {
|
||||
gv->gv_parse_name_iname = InterNames::new(GRAMMAR_PARSE_NAME_ROUTINE_INAMEF);
|
||||
inter_name *r_iname = InterNames::new(GRAMMAR_PARSE_NAME_ROUTINE_INAMEF);
|
||||
compilation_module *C = Modules::find(gv->where_gv_created);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
gv->gv_parse_name_iname = Packaging::function(
|
||||
InterNames::one_off(I"parse_name_fn", PR),
|
||||
PR,
|
||||
r_iname);
|
||||
InterNames::to_symbol(gv->gv_parse_name_iname);
|
||||
}
|
||||
return gv->gv_parse_name_iname;
|
||||
|
@ -98,7 +109,13 @@ inter_name *PL::Parsing::Tokens::General::compile_parse_name_property(inference_
|
|||
} else {
|
||||
if (PL::Parsing::Visibility::any_property_visible_to_subject(subj, FALSE)) {
|
||||
parse_name_notice *notice = CREATE(parse_name_notice);
|
||||
notice->pnn_iname = InterNames::new(PARSE_NAME_ROUTINE_INAMEF);
|
||||
inter_name *r_iname = InterNames::new(PARSE_NAME_ROUTINE_INAMEF);
|
||||
compilation_module *C = Modules::find(subj->infs_created_at);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
notice->pnn_iname = Packaging::function(
|
||||
InterNames::one_off(I"parse_name_fn", PR),
|
||||
PR,
|
||||
r_iname);
|
||||
InterNames::to_symbol(notice->pnn_iname);
|
||||
notice->parse_subject = subj;
|
||||
symb = notice->pnn_iname;
|
||||
|
@ -111,11 +128,13 @@ void PL::Parsing::Tokens::General::write_parse_name_routines(void) {
|
|||
parse_name_notice *notice;
|
||||
LOOP_OVER(notice, parse_name_notice) {
|
||||
gpr_kit gprk = PL::Parsing::Tokens::Values::new_kit();
|
||||
packaging_state save = Packaging::enter_home_of(notice->pnn_iname);
|
||||
if (PL::Parsing::Tokens::General::compile_parse_name_head(&gprk,
|
||||
notice->parse_subject, NULL, notice->pnn_iname)) {
|
||||
PL::Parsing::Tokens::General::compile_parse_name_tail(&gprk);
|
||||
Routines::end();
|
||||
}
|
||||
Packaging::exit(save);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,14 @@ grammar_line *PL::Parsing::Lines::new(int wn, action_name *ac,
|
|||
gl->understanding_sort_bonus = UNCALCULATED_BONUS;
|
||||
|
||||
gl->cond_token_iname = NULL;
|
||||
gl->mistake_iname = InterNames::new(GRAMMAR_LINE_MISTAKE_TOKEN_INAMEF);
|
||||
|
||||
inter_name *m_iname = InterNames::new(GRAMMAR_LINE_MISTAKE_TOKEN_INAMEF);
|
||||
compilation_module *C = Modules::find(current_sentence);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
gl->mistake_iname = Packaging::function(
|
||||
InterNames::one_off(I"mistake_fn", PR),
|
||||
PR,
|
||||
m_iname);
|
||||
InterNames::to_symbol(gl->mistake_iname);
|
||||
|
||||
return gl;
|
||||
|
@ -219,7 +226,17 @@ int PL::Parsing::Lines::conditional(grammar_line *gl) {
|
|||
void PL::Parsing::Lines::gl_compile_condition_token_as_needed(grammar_line *gl) {
|
||||
if (PL::Parsing::Lines::conditional(gl)) {
|
||||
current_sentence = gl->where_grammar_specified;
|
||||
gl->cond_token_iname = InterNames::new(GRAMMAR_LINE_COND_TOKEN_INAMEF);
|
||||
|
||||
inter_name *c_iname = InterNames::new(GRAMMAR_LINE_COND_TOKEN_INAMEF);
|
||||
compilation_module *C = Modules::find(current_sentence);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
gl->cond_token_iname = Packaging::function(
|
||||
InterNames::one_off(I"conditional_token_fn", PR),
|
||||
PR,
|
||||
c_iname);
|
||||
InterNames::to_symbol(gl->cond_token_iname);
|
||||
|
||||
packaging_state save = Packaging::enter_home_of(gl->cond_token_iname);
|
||||
Routines::begin(gl->cond_token_iname);
|
||||
|
||||
parse_node *spec = NULL;
|
||||
|
@ -262,6 +279,7 @@ void PL::Parsing::Lines::gl_compile_condition_token_as_needed(grammar_line *gl)
|
|||
Emit::up();
|
||||
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,6 +338,7 @@ void PL::Parsing::Lines::set_mistake(grammar_line *gl, int wn) {
|
|||
|
||||
void PL::Parsing::Lines::gl_compile_mistake_token_as_needed(grammar_line *gl) {
|
||||
if (gl->mistaken) {
|
||||
packaging_state save = Packaging::enter_home_of(gl->mistake_iname);
|
||||
Routines::begin(gl->mistake_iname);
|
||||
|
||||
Emit::inv_primitive(if_interp);
|
||||
|
@ -350,6 +369,7 @@ void PL::Parsing::Lines::gl_compile_mistake_token_as_needed(grammar_line *gl) {
|
|||
Emit::up();
|
||||
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +395,14 @@ int PL::Parsing::Lines::gl_compile_result_of_mistake(gpr_kit *gprk, grammar_line
|
|||
}
|
||||
|
||||
void PL::Parsing::Lines::MistakeActionSub_routine(void) {
|
||||
Routines::begin(InterNames::iname(MistakeActionSub_INAME));
|
||||
package_request *R = Packaging::synoptic_resource(ACTIONS_SUBPACKAGE);
|
||||
inter_name *MistakeActionSub_iname =
|
||||
Packaging::function(
|
||||
InterNames::one_off(I"MistakeActionSub_fn", R),
|
||||
R,
|
||||
InterNames::iname(MistakeActionSub_INAME));
|
||||
packaging_state save = Packaging::enter_home_of(MistakeActionSub_iname);
|
||||
Routines::begin(MistakeActionSub_iname);
|
||||
|
||||
Emit::inv_primitive(switch_interp);
|
||||
Emit::down();
|
||||
|
@ -426,6 +453,7 @@ void PL::Parsing::Lines::MistakeActionSub_routine(void) {
|
|||
Emit::up();
|
||||
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
MistakeAction_iname = InterNames::iname(MistakeAction_INAME);
|
||||
Emit::named_pseudo_numeric_constant(MistakeAction_iname, K_action_name, 10000);
|
||||
InterNames::annotate_i(MistakeAction_iname, ACTION_IANN, 1);
|
||||
|
|
|
@ -781,7 +781,9 @@ void PL::Parsing::Verbs::compile(grammar_verb *gv) {
|
|||
}
|
||||
case GV_IS_CONSULT: {
|
||||
gpr_kit gprk = PL::Parsing::Tokens::Values::new_kit();
|
||||
Routines::begin(PL::Parsing::Tokens::General::consult_iname(gv));
|
||||
inter_name *iname = PL::Parsing::Tokens::General::consult_iname(gv);
|
||||
packaging_state save = Packaging::enter_home_of(iname);
|
||||
Routines::begin(iname);
|
||||
PL::Parsing::Tokens::Values::add_range_calls(&gprk);
|
||||
PL::Parsing::Tokens::Values::add_original(&gprk);
|
||||
PL::Parsing::Tokens::Values::add_standard_set(&gprk);
|
||||
|
@ -806,15 +808,18 @@ void PL::Parsing::Verbs::compile(grammar_verb *gv) {
|
|||
Emit::val_iname(K_value, InterNames::extern(GPRFAIL_EXNAMEF));
|
||||
Emit::up();
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
break;
|
||||
}
|
||||
case GV_IS_OBJECT: {
|
||||
gpr_kit gprk = PL::Parsing::Tokens::Values::new_kit();
|
||||
packaging_state save = Packaging::enter_home_of(PL::Parsing::Tokens::General::get_gv_parse_name(gv));
|
||||
if (PL::Parsing::Tokens::General::compile_parse_name_head(&gprk, gv->subj_understood, gv, NULL)) {
|
||||
PL::Parsing::Verbs::gv_compile_parse_name_lines(&gprk, gv);
|
||||
PL::Parsing::Tokens::General::compile_parse_name_tail(&gprk);
|
||||
Routines::end();
|
||||
}
|
||||
Packaging::exit(save);
|
||||
break;
|
||||
}
|
||||
case GV_IS_VALUE:
|
||||
|
|
|
@ -41,10 +41,17 @@ noun_filter_token *PL::Parsing::Tokens::Filters::nft_new(parse_node *spec, int g
|
|||
nft->parse_using_gpr = FALSE;
|
||||
nft->nft_compiled = FALSE;
|
||||
|
||||
inter_name *filter_iname = NULL;
|
||||
if (global_scope)
|
||||
nft->nft_iname = InterNames::new(SCOPE_FILTER_INAMEF);
|
||||
filter_iname = InterNames::new(SCOPE_FILTER_INAMEF);
|
||||
else
|
||||
nft->nft_iname = InterNames::new(NOUN_FILTER_INAMEF);
|
||||
filter_iname = InterNames::new(NOUN_FILTER_INAMEF);
|
||||
compilation_module *C = Modules::find(current_sentence);
|
||||
package_request *PR = Packaging::request_resource(C, GRAMMAR_SUBPACKAGE);
|
||||
nft->nft_iname = Packaging::function(
|
||||
InterNames::one_off(I"filter_fn", PR),
|
||||
PR,
|
||||
filter_iname);
|
||||
InterNames::to_symbol(nft->nft_iname);
|
||||
return nft;
|
||||
}
|
||||
|
@ -59,6 +66,8 @@ void PL::Parsing::Tokens::Filters::nft_compile_routine(noun_filter_token *nft) {
|
|||
kind *K = NonlocalVariables::kind(I6_noun_VAR);
|
||||
NonlocalVariables::set_kind(I6_noun_VAR, R);
|
||||
if (Kinds::Compare::le(R, K_object) == FALSE) nft->parse_using_gpr = TRUE;
|
||||
|
||||
packaging_state save = Packaging::enter_home_of(nft->nft_iname);
|
||||
Routines::begin(nft->nft_iname);
|
||||
if (nft->parse_using_gpr) {
|
||||
inter_symbol *v_s = LocalVariables::add_internal_local_c_as_symbol(I"v", "value parsed");
|
||||
|
@ -239,6 +248,7 @@ void PL::Parsing::Tokens::Filters::nft_compile_routine(noun_filter_token *nft) {
|
|||
Emit::up();
|
||||
}
|
||||
Routines::end();
|
||||
Packaging::exit(save);
|
||||
NonlocalVariables::set_kind(I6_noun_VAR, K);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue