diff --git a/inform7/Internal/I6T/Load-Core.i6t b/inform7/Internal/I6T/Load-Core.i6t index b937fe555..08469ae94 100644 --- a/inform7/Internal/I6T/Load-Core.i6t +++ b/inform7/Internal/I6T/Load-Core.i6t @@ -300,7 +300,7 @@ plural:verbs instance-of:WORD_VALUE_TY instance-of:SAYABLE_VALUE_TY -default-value:ConjugateVerb_0 +default-value:0 loop-domain-schema:for (*2=0, *1=TableOfVerbs-->*2: *1: *2++, *1=TableOfVerbs-->*2) i6-printing-routine:PrintVerbAsValue diff --git a/inform7/core-module/Chapter 13/Knowledge about Kinds.w b/inform7/core-module/Chapter 13/Knowledge about Kinds.w index 21f5a0af6..2ee83f3a9 100644 --- a/inform7/core-module/Chapter 13/Knowledge about Kinds.w +++ b/inform7/core-module/Chapter 13/Knowledge about Kinds.w @@ -89,7 +89,12 @@ particular order. = int Kinds::Knowledge::emit_all(void) { - Emit::named_numeric_constant(InterNames::iname(MAX_WEAK_ID_INAME), (inter_t) next_free_data_type_ID); + package_request *PR = Packaging::request_resource(NULL, BASICS_SUBPACKAGE); + inter_name *iname = InterNames::iname(MAX_WEAK_ID_INAME); + Packaging::house(iname, PR); + packaging_state save = Packaging::enter_home_of(iname); + Emit::named_numeric_constant(iname, (inter_t) next_free_data_type_ID); + Packaging::exit(save); Kinds::Knowledge::emit_recursive(Kinds::Knowledge::as_subject(K_object)); return FALSE; } diff --git a/inform7/core-module/Chapter 26/Plugins.w b/inform7/core-module/Chapter 26/Plugins.w index bb03d6465..aadfef9c7 100644 --- a/inform7/core-module/Chapter 26/Plugins.w +++ b/inform7/core-module/Chapter 26/Plugins.w @@ -185,7 +185,9 @@ void Plugins::Manage::start(void) { CREATE_PLUGIN(files_plugin, PL::Files::start, FALSE, GLULX_EXTERNAL_FILES_PLUGIN_NAME, MULTIMEDIA_PLUGIN_NAME); files_plugin->has_template_file = "Files"; + package_request *PR = Packaging::request_resource(NULL, BASICS_SUBPACKAGE); files_plugin->IFDEF_iname = InterNames::iname(PLUGIN_FILES_INAME); + Packaging::house(files_plugin->IFDEF_iname, PR); #endif #ifndef MULTIMEDIA_MODULE @@ -316,8 +318,11 @@ void Plugins::Manage::show(OUTPUT_STREAM, char *label, int state) { void Plugins::Manage::define_IFDEF_symbols(void) { plugin *P; LOOP_OVER(P, plugin) - if ((P->now_plugged_in) && (P->IFDEF_iname)) + if ((P->now_plugged_in) && (P->IFDEF_iname)) { + packaging_state save = Packaging::enter_home_of(P->IFDEF_iname); Emit::named_numeric_constant(P->IFDEF_iname, 0); + Packaging::exit(save); + } } @ = diff --git a/inform7/core-module/Chapter 26/Test Scripts.w b/inform7/core-module/Chapter 26/Test Scripts.w index 25a910678..46927f3d9 100644 --- a/inform7/core-module/Chapter 26/Test Scripts.w +++ b/inform7/core-module/Chapter 26/Test Scripts.w @@ -237,8 +237,12 @@ void PL::Parsing::TestScripts::new_test_text(parse_node *PN) { test->no_possessions = 0; test->text_of_script = Str::new(); - test->text_iname = InterNames::new(TEST_TEXTS_INAMEF); - test->req_iname = InterNames::new(TEST_REQS_INAMEF); + package_request *PR = Packaging::request_resource(Modules::find(current_sentence), GRAMMAR_SUBPACKAGE); + package_request *PR2 = Packaging::request(Packaging::supply_iname(PR, TEST_PR_COUNTER), PR, test_ptype); + test->text_iname = InterNames::one_off(I"script", PR2); + test->req_iname = InterNames::one_off(I"requirements", PR2); + Inter::Symbols::set_flag(InterNames::to_symbol(test->text_iname), MAKE_NAME_UNIQUE); + Inter::Symbols::set_flag(InterNames::to_symbol(test->req_iname), MAKE_NAME_UNIQUE); ts_being_parsed = test; (ParseTree::get_text(PN->next->next)); @@ -267,6 +271,7 @@ void PL::Parsing::TestScripts::check_test_command(text_stream *p) { void PL::Parsing::TestScripts::write_text(void) { test_scenario *test; LOOP_OVER(test, test_scenario) { + packaging_state save = Packaging::enter_home_of(test->text_iname); Emit::named_byte_array_begin(test->text_iname, K_text); TEMPORARY_TEXT(tttext); CompiledText::from_stream(tttext, test->text_of_script, @@ -285,12 +290,19 @@ void PL::Parsing::TestScripts::write_text(void) { } Emit::array_numeric_entry(0); Emit::array_end(); + Packaging::exit(save); } } void PL::Parsing::TestScripts::NO_TEST_SCENARIOS_constant(void) { - if (NUMBER_CREATED(test_scenario) > 0) - Emit::named_numeric_constant(InterNames::iname(NO_TEST_SCENARIOS_INAME), (inter_t) NUMBER_CREATED(test_scenario)); + if (NUMBER_CREATED(test_scenario) > 0) { + package_request *PR = Packaging::request_resource(NULL, BASICS_SUBPACKAGE); + inter_name *iname = InterNames::iname(NO_TEST_SCENARIOS_INAME); + Packaging::house(iname, PR); + packaging_state save = Packaging::enter_home_of(iname); + Emit::named_numeric_constant(iname, (inter_t) NUMBER_CREATED(test_scenario)); + Packaging::exit(save); + } } void PL::Parsing::TestScripts::TestScriptSub_routine(void) { diff --git a/inform7/core-module/Chapter 26/Virtual Machines.w b/inform7/core-module/Chapter 26/Virtual Machines.w index dc79386fb..6a8c6866d 100644 --- a/inform7/core-module/Chapter 26/Virtual Machines.w +++ b/inform7/core-module/Chapter 26/Virtual Machines.w @@ -196,41 +196,43 @@ inter_name *VirtualMachines::emit_unchecked_hex_fundamental_constant(int id, int inter_name *VirtualMachines::emit_fundamental_constants(void) { if (target_VM == -1) internal_error("target VM not set yet"); + package_request *basics = Packaging::request_resource(NULL, BASICS_SUBPACKAGE); + if ((this_is_a_release_compile == FALSE) || (this_is_a_debug_compile)) - Emit::named_numeric_constant(InterNames::iname(DEBUG_INAME), 1); + VirtualMachines::emit_fundamental_constant(DEBUG_INAME, 1, basics); if (table_of_VM_data[target_VM].VM_code == Z_VM) { - Emit::named_numeric_constant(InterNames::iname(TARGET_ZCODE_INAME), 1); - Emit::named_numeric_constant(InterNames::iname(DICT_WORD_SIZE_INAME), 6); + VirtualMachines::emit_fundamental_constant(TARGET_ZCODE_INAME, 1, basics); + VirtualMachines::emit_fundamental_constant(DICT_WORD_SIZE_INAME, 6, basics); } else if (table_of_VM_data[target_VM].VM_code == GLULX_VM) { - Emit::named_numeric_constant(InterNames::iname(TARGET_GLULX_INAME), 1); - Emit::named_numeric_constant(InterNames::iname(DICT_WORD_SIZE_INAME), 9); + VirtualMachines::emit_fundamental_constant(TARGET_GLULX_INAME, 1, basics); + VirtualMachines::emit_fundamental_constant(DICT_WORD_SIZE_INAME, 9, basics); } inter_name *NULL_iname = NULL; if (table_of_VM_data[target_VM].VM_is_32_bit) { - VirtualMachines::emit_fundamental_constant(WORDSIZE_INAME, 4, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - NULL_iname = VirtualMachines::emit_unchecked_hex_fundamental_constant(NULL_INAME, 0xffffffff, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(WORD_HIGHBIT_INAME, 0x80000000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(WORD_NEXTTOHIGHBIT_INAME, 0x40000000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(IMPROBABLE_VALUE_INAME, 0xdeadce11, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(REPARSE_CODE_INAME, 0x40000000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - MPN_iname = VirtualMachines::emit_fundamental_constant(MAX_POSITIVE_NUMBER_INAME, 2147483647, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_signed_fundamental_constant(MIN_NEGATIVE_NUMBER_INAME, -2147483648, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); + VirtualMachines::emit_fundamental_constant(WORDSIZE_INAME, 4, basics); + NULL_iname = VirtualMachines::emit_unchecked_hex_fundamental_constant(NULL_INAME, 0xffffffff, basics); + VirtualMachines::emit_hex_fundamental_constant(WORD_HIGHBIT_INAME, 0x80000000, basics); + VirtualMachines::emit_hex_fundamental_constant(WORD_NEXTTOHIGHBIT_INAME, 0x40000000, basics); + VirtualMachines::emit_hex_fundamental_constant(IMPROBABLE_VALUE_INAME, 0xdeadce11, basics); + VirtualMachines::emit_hex_fundamental_constant(REPARSE_CODE_INAME, 0x40000000, basics); + MPN_iname = VirtualMachines::emit_fundamental_constant(MAX_POSITIVE_NUMBER_INAME, 2147483647, basics); + VirtualMachines::emit_signed_fundamental_constant(MIN_NEGATIVE_NUMBER_INAME, -2147483648, basics); InterNames::cache(InterNames::iname(MAX_POSITIVE_NUMBER_INAME)); InterNames::cache(InterNames::iname(MIN_NEGATIVE_NUMBER_INAME)); InterNames::to_symbol(InterNames::iname(MAX_POSITIVE_NUMBER_INAME)); InterNames::to_symbol(InterNames::iname(MIN_NEGATIVE_NUMBER_INAME)); } else { - VirtualMachines::emit_fundamental_constant(WORDSIZE_INAME, 2, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - NULL_iname = VirtualMachines::emit_unchecked_hex_fundamental_constant(NULL_INAME, 0xffff, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(WORD_HIGHBIT_INAME, 0x8000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(WORD_NEXTTOHIGHBIT_INAME, 0x4000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(IMPROBABLE_VALUE_INAME, 0x7fe3, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_hex_fundamental_constant(REPARSE_CODE_INAME, 10000, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - MPN_iname = VirtualMachines::emit_fundamental_constant(MAX_POSITIVE_NUMBER_INAME, 32767, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); - VirtualMachines::emit_signed_fundamental_constant(MIN_NEGATIVE_NUMBER_INAME, -32768, Packaging::request_resource(NULL, BASICS_SUBPACKAGE)); + VirtualMachines::emit_fundamental_constant(WORDSIZE_INAME, 2, basics); + NULL_iname = VirtualMachines::emit_unchecked_hex_fundamental_constant(NULL_INAME, 0xffff, basics); + VirtualMachines::emit_hex_fundamental_constant(WORD_HIGHBIT_INAME, 0x8000, basics); + VirtualMachines::emit_hex_fundamental_constant(WORD_NEXTTOHIGHBIT_INAME, 0x4000, basics); + VirtualMachines::emit_hex_fundamental_constant(IMPROBABLE_VALUE_INAME, 0x7fe3, basics); + VirtualMachines::emit_hex_fundamental_constant(REPARSE_CODE_INAME, 10000, basics); + MPN_iname = VirtualMachines::emit_fundamental_constant(MAX_POSITIVE_NUMBER_INAME, 32767, basics); + VirtualMachines::emit_signed_fundamental_constant(MIN_NEGATIVE_NUMBER_INAME, -32768, basics); InterNames::cache(InterNames::iname(MAX_POSITIVE_NUMBER_INAME)); InterNames::cache(InterNames::iname(MIN_NEGATIVE_NUMBER_INAME)); InterNames::to_symbol(InterNames::iname(MAX_POSITIVE_NUMBER_INAME)); diff --git a/inform7/core-module/Chapter 27/Packaging.w b/inform7/core-module/Chapter 27/Packaging.w index 183e114bd..80ef4c876 100644 --- a/inform7/core-module/Chapter 27/Packaging.w +++ b/inform7/core-module/Chapter 27/Packaging.w @@ -25,6 +25,7 @@ inter_symbol *rulebook_ptype = NULL; inter_symbol *table_ptype = NULL; inter_symbol *table_column_ptype = NULL; inter_symbol *relation_ptype = NULL; +inter_symbol *test_ptype = NULL; inter_symbol *data_ptype = NULL; @ = @@ -73,6 +74,8 @@ void Packaging::emit_types(void) { Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), table_column_ptype, Emit::baseline(Emit::IRS()), NULL)); relation_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_relation"); Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), relation_ptype, Emit::baseline(Emit::IRS()), NULL)); + test_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_test"); + Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), test_ptype, Emit::baseline(Emit::IRS()), NULL)); data_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_data"); Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), data_ptype, Emit::baseline(Emit::IRS()), NULL)); } @@ -108,6 +111,7 @@ void Packaging::emit_types(void) { @e SUBSTITUTIONF_PR_COUNTER @e MISC_PR_COUNTER @e DATA_PR_COUNTER +@e TEST_PR_COUNTER @e MAX_PR_COUNTER @@ -207,6 +211,7 @@ packaging_state Packaging::enter(package_request *R) { (S->eventual_type == table_ptype) || (S->eventual_type == table_column_ptype) || (S->eventual_type == data_ptype) || + (S->eventual_type == test_ptype) || (S->parent_request == NULL)) { current_enclosure = S; break; @@ -426,6 +431,7 @@ inter_name *Packaging::supply_iname(package_request *R, int what_for) { case SUBSTITUTION_PR_COUNTER: WRITE_TO(P, "ts"); break; case SUBSTITUTIONF_PR_COUNTER: WRITE_TO(P, "ts_fn"); break; case MISC_PR_COUNTER: WRITE_TO(P, "misc_const"); break; + case TEST_PR_COUNTER: WRITE_TO(P, "test"); break; case DATA_PR_COUNTER: WRITE_TO(P, "data"); break; default: internal_error("unimplemented"); } diff --git a/inform7/if-module/Chapter 3/The Naming Thicket.w b/inform7/if-module/Chapter 3/The Naming Thicket.w index f04e65b01..ec3213afa 100644 --- a/inform7/if-module/Chapter 3/The Naming Thicket.w +++ b/inform7/if-module/Chapter 3/The Naming Thicket.w @@ -278,7 +278,12 @@ actually means it's rarely needed.) if (P_cap_short_name == NULL) { P_cap_short_name = Properties::Valued::new_nameless( I"cap_short_name", K_text); - Emit::named_numeric_constant(InterNames::iname(CAP_SHORT_NAME_EXISTS_INAME), 1); + package_request *PR = Packaging::request_resource(NULL, BASICS_SUBPACKAGE); + inter_name *iname = InterNames::iname(CAP_SHORT_NAME_EXISTS_INAME); + Packaging::house(iname, PR); + packaging_state save = Packaging::enter_home_of(iname); + Emit::named_numeric_constant(iname, 1); + Packaging::exit(save); } if (faux) Properties::Valued::assert(P_cap_short_name, subj, diff --git a/inform7/if-module/Chapter 3/The Score.w b/inform7/if-module/Chapter 3/The Score.w index 8eccbe682..b7469cfcb 100644 --- a/inform7/if-module/Chapter 3/The Score.w +++ b/inform7/if-module/Chapter 3/The Score.w @@ -51,11 +51,16 @@ void PL::Score::compile_max_score(void) { break; } } + package_request *PR = Packaging::synoptic_resource(IF_SUBPACKAGE); + inter_name *iname = InterNames::iname(INITIAL_MAX_SCORE_INAME); + Packaging::house(iname, PR); + packaging_state save = Packaging::enter_home_of(iname); if (NonlocalVariables::has_initial_value_set(max_score_VAR)) { inter_t v1 = 0, v2 = 0; NonlocalVariables::seek_initial_value(&v1, &v2, max_score_VAR); - Emit::named_generic_constant(InterNames::iname(INITIAL_MAX_SCORE_INAME), v1, v2); + Emit::named_generic_constant(iname, v1, v2); } else { - Emit::named_numeric_constant(InterNames::iname(INITIAL_MAX_SCORE_INAME), 0); + Emit::named_numeric_constant(iname, 0); } + Packaging::exit(save); } diff --git a/inform7/if-module/Chapter 4/Actions.w b/inform7/if-module/Chapter 4/Actions.w index bf7334772..c4a0b2815 100644 --- a/inform7/if-module/Chapter 4/Actions.w +++ b/inform7/if-module/Chapter 4/Actions.w @@ -987,6 +987,7 @@ int PL::Actions::can_be_compiled_in_past_tense(action_name *an) { inter_name *PL::Actions::compile_action_bitmap_property(instance *I) { package_request *R = Packaging::request_main(); if (I) R = Instances::package(I); + else R = Kinds::Behaviour::package(K_object); packaging_state save = Packaging::enter(R); inter_name *N = Packaging::supply_iname(R, INLINE_PR_COUNTER); Emit::named_array_begin(N, K_number); diff --git a/inform7/if-module/Chapter 5/Grammar Lines.w b/inform7/if-module/Chapter 5/Grammar Lines.w index c24325c1b..a40004d4c 100644 --- a/inform7/if-module/Chapter 5/Grammar Lines.w +++ b/inform7/if-module/Chapter 5/Grammar Lines.w @@ -448,9 +448,13 @@ void PL::Parsing::Lines::MistakeActionSub_routine(void) { Emit::up(); Routines::end(save); + package_request *PR = Packaging::request_resource(NULL, ACTIONS_SUBPACKAGE); MistakeAction_iname = InterNames::iname(MistakeAction_INAME); + Packaging::house(MistakeAction_iname, PR); + save = Packaging::enter_home_of(MistakeAction_iname); Emit::named_pseudo_numeric_constant(MistakeAction_iname, K_action_name, 10000); InterNames::annotate_i(MistakeAction_iname, ACTION_IANN, 1); + Packaging::exit(save); } @h Single word optimisation.