diff --git a/README.md b/README.md index 611f2fc4a..af36786ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -v10.1.0-alpha.1+6U59 'Krypton' (16 March 2022) +v10.1.0-alpha.1+6U60 'Krypton' (17 March 2022) ## About Inform 7 diff --git a/build.txt b/build.txt index 7e4429523..1d20339eb 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: alpha.1 -Build Date: 16 March 2022 -Build Number: 6U59 +Build Date: 17 March 2022 +Build Number: 6U60 diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb index 3cc257ab0..605cdec3b 100644 Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb differ diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb index 9ca8eb6a6..3782efbd0 100644 Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb differ diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb index 7afe9d466..0b388c18d 100644 Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb differ diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb index 5dd93c329..73706ea95 100644 Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb differ diff --git a/inform7/runtime-module/Chapter 2/Emit.w b/inform7/runtime-module/Chapter 2/Emit.w index 7b45f1a32..8a62384b5 100644 --- a/inform7/runtime-module/Chapter 2/Emit.w +++ b/inform7/runtime-module/Chapter 2/Emit.w @@ -134,32 +134,36 @@ it represents an actual number at run-time, the second if not: = inter_name *Emit::numeric_constant(inter_name *con_iname, inter_ti val) { - return Emit::numeric_constant_inner(con_iname, val, INT32_ITCONC, INVALID_IANN); + return Emit::numeric_constant_inner(con_iname, + InterValuePairs::number_in_base(val, 10), INT32_ITCONC); } inter_name *Emit::named_numeric_constant_hex(inter_name *con_iname, inter_ti val) { - return Emit::numeric_constant_inner(con_iname, val, INT32_ITCONC, HEX_IANN); + return Emit::numeric_constant_inner(con_iname, + InterValuePairs::number_in_base(val, 16), INT32_ITCONC); } inter_name *Emit::named_unchecked_constant_hex(inter_name *con_iname, inter_ti val) { - return Emit::numeric_constant_inner(con_iname, val, UNCHECKED_ITCONC, HEX_IANN); + return Emit::numeric_constant_inner(con_iname, + InterValuePairs::number_in_base(val, 16), UNCHECKED_ITCONC); } inter_name *Emit::named_numeric_constant_signed(inter_name *con_iname, int val) { - return Emit::numeric_constant_inner(con_iname, (inter_ti) val, INT32_ITCONC, SIGNED_IANN); + return Emit::numeric_constant_inner(con_iname, + InterValuePairs::signed_number(val), INT32_ITCONC); } inter_name *Emit::unchecked_numeric_constant(inter_name *con_iname, inter_ti val) { - return Emit::numeric_constant_inner(con_iname, val, UNCHECKED_ITCONC, INVALID_IANN); + return Emit::numeric_constant_inner(con_iname, + InterValuePairs::number_in_base(val, 10), UNCHECKED_ITCONC); } -inter_name *Emit::numeric_constant_inner(inter_name *con_iname, inter_ti val, - inter_ti constructor_code, inter_ti annotation) { +inter_name *Emit::numeric_constant_inner(inter_name *con_iname, inter_pair val, + inter_ti constructor_code) { packaging_state save = Packaging::enter_home_of(con_iname); inter_symbol *con_s = InterNames::to_symbol(con_iname); - if (annotation != INVALID_IANN) SymbolAnnotation::set_b(con_s, annotation, 0); Produce::guard(ConstantInstruction::new(Emit::at(), con_s, - InterTypes::from_constructor_code(constructor_code), InterValuePairs::number(val), + InterTypes::from_constructor_code(constructor_code), val, Emit::baseline(), NULL)); Packaging::exit(Emit::tree(), save); return con_iname; diff --git a/inter/Manual/Data Packages in Textual Inter.w b/inter/Manual/Data Packages in Textual Inter.w index 4a973dce9..e9add5022 100644 --- a/inter/Manual/Data Packages in Textual Inter.w +++ b/inter/Manual/Data Packages in Textual Inter.w @@ -162,23 +162,18 @@ we see that the two variables have different URLs, |/main/one/V_speed| and |/main/two/V_speed|. @h Annotations. -A few of the defined names in Inter can be "annotated": to be exact, those -created by |constant|, |property|, |variable| and |local|. +A few of the defined names in Inter can be "annotated". Many annotations are simply markers temporarily given to these names during the compilation process, and they usually do not change the meaning of the -program. For example, a constant given the annotation |_hex| has its value -printed out in textual Inter in hexadecimal not decimal. So: +program. For example, the final C code generator annotates the names of arrays +with their addresses in (virtual) memory, with the |__array_address| annotation. +In textual format: = (text as Inter) - constant SPEED_LIMIT = 0x1ff __hex + constant my_array = { 1, 2, 4, 8 } __array_address=7718 = -This tells the code generator that it is more natural to express this value -as |1ff| hexadecimal rather than 511 decimal. - -Most annotations are either there or not there, like |__hex|. (All annotation -names begin with a double underscore, |__|.) But some supply a value: for -example, |__priority=17| would be the syntax to specify this, though |__priority| -is not in the standard set, as it happens. +All annotation names begin with a double underscore, |__|. They do not all +express a value: some are boolean flags, where no |=...| part is written. For the list of standard annotation names in use, see //Inform Annotations//. diff --git a/inter/Manual/Inform Annotations.w b/inter/Manual/Inform Annotations.w index ec9f11649..871669b40 100644 --- a/inter/Manual/Inform Annotations.w +++ b/inter/Manual/Inform Annotations.w @@ -15,17 +15,6 @@ generated by I7. @h Miscellaneous constants. -@ |__hex|. Applies to |constant|. Marks that the value of this constant -is most legible in hexadecimal rather than decimal. Inter itself uses -this when writing a textual inter fomr of the constant's declaration, -and the Inform back end uses it when compiling Inform 6, in that it will -compile to a hexadecimal literal like |$4F02| rather than a decimal one -like |20226|. There is no effect on the final program. - -@ |__signed|. Applies to |constant|. Marks that the value of this constant -is most legible if printed as a signed decimal literal than as an -unsigned one. - @ |__late|. Applies to |constant|. Suggests that this should be placed late on the final compiled code, rather than at its current place. (This clue helps the I6 code generator to avoid not-yet-declared errors; I6 is quite diff --git a/inter/Tests/Duplex/_Pairs/BinOut+B.intert b/inter/Tests/Duplex/_Pairs/BinOut+B.intert index acdc6a833..d115e74b4 100644 --- a/inter/Tests/Duplex/_Pairs/BinOut+B.intert +++ b/inter/Tests/Duplex/_Pairs/BinOut+B.intert @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Pairs/BinOutRes+B.intert b/inter/Tests/Duplex/_Pairs/BinOutRes+B.intert index bf3e96dc2..ebb21e6ff 100644 --- a/inter/Tests/Duplex/_Pairs/BinOutRes+B.intert +++ b/inter/Tests/Duplex/_Pairs/BinOutRes+B.intert @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Pairs/InOut+B.intert b/inter/Tests/Duplex/_Pairs/InOut+B.intert index acdc6a833..d115e74b4 100644 --- a/inter/Tests/Duplex/_Pairs/InOut+B.intert +++ b/inter/Tests/Duplex/_Pairs/InOut+B.intert @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Pairs/PluggedInOut+B.intert b/inter/Tests/Duplex/_Pairs/PluggedInOut+B.intert index b6354fda8..4d11c6813 100644 --- a/inter/Tests/Duplex/_Pairs/PluggedInOut+B.intert +++ b/inter/Tests/Duplex/_Pairs/PluggedInOut+B.intert @@ -17,7 +17,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Pairs/TransposeInOut+B.intert b/inter/Tests/Duplex/_Pairs/TransposeInOut+B.intert index 758c6d2c0..3482e491b 100644 --- a/inter/Tests/Duplex/_Pairs/TransposeInOut+B.intert +++ b/inter/Tests/Duplex/_Pairs/TransposeInOut+B.intert @@ -17,7 +17,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Results_Ideal/BinOut+B.txt b/inter/Tests/Duplex/_Results_Ideal/BinOut+B.txt index 500b65504..230198420 100644 --- a/inter/Tests/Duplex/_Results_Ideal/BinOut+B.txt +++ b/inter/Tests/Duplex/_Results_Ideal/BinOut+B.txt @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Results_Ideal/BinOutRes+B.txt b/inter/Tests/Duplex/_Results_Ideal/BinOutRes+B.txt index 2fe029810..e18dda2f3 100644 --- a/inter/Tests/Duplex/_Results_Ideal/BinOutRes+B.txt +++ b/inter/Tests/Duplex/_Results_Ideal/BinOutRes+B.txt @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Results_Ideal/InOut+B.txt b/inter/Tests/Duplex/_Results_Ideal/InOut+B.txt index 500b65504..230198420 100644 --- a/inter/Tests/Duplex/_Results_Ideal/InOut+B.txt +++ b/inter/Tests/Duplex/_Results_Ideal/InOut+B.txt @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt b/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt index 2d1dc509c..2f2c7e24a 100644 --- a/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt +++ b/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt @@ -19,7 +19,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/Duplex/_Results_Ideal/TransposeInOut+B.txt b/inter/Tests/Duplex/_Results_Ideal/TransposeInOut+B.txt index 380ee8a0a..dcda3154e 100644 --- a/inter/Tests/Duplex/_Results_Ideal/TransposeInOut+B.txt +++ b/inter/Tests/Duplex/_Results_Ideal/TransposeInOut+B.txt @@ -19,7 +19,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/Tests/General/_Results_Ideal/New.txt b/inter/Tests/General/_Results_Ideal/New.txt index 86b976302..68f6225cc 100644 --- a/inter/Tests/General/_Results_Ideal/New.txt +++ b/inter/Tests/General/_Results_Ideal/New.txt @@ -110,12 +110,12 @@ primitive !externalcall val val -> val package main _plain package architectural _linkage constant WORDSIZE = 2 __architectural - constant NULL = 0xffff __architectural __hex - constant WORD_HIGHBIT = 0x8000 __architectural __hex - constant WORD_NEXTTOHIGHBIT = 0x4000 __architectural __hex - constant IMPROBABLE_VALUE = 0x7fe3 __architectural __hex + constant NULL = 0xffff __architectural + constant WORD_HIGHBIT = 0x8000 __architectural + constant WORD_NEXTTOHIGHBIT = 0x4000 __architectural + constant IMPROBABLE_VALUE = 0x7fe3 __architectural constant MAX_POSITIVE_NUMBER = 32767 __architectural - constant MIN_NEGATIVE_NUMBER = -32768 __architectural __signed + constant MIN_NEGATIVE_NUMBER = -32768 __architectural constant TARGET_ZCODE = 1 __architectural constant DEBUG = 1 __architectural package generic _module diff --git a/inter/Tests/General/_Results_Ideal/Prepare.txt b/inter/Tests/General/_Results_Ideal/Prepare.txt index 86b976302..68f6225cc 100644 --- a/inter/Tests/General/_Results_Ideal/Prepare.txt +++ b/inter/Tests/General/_Results_Ideal/Prepare.txt @@ -110,12 +110,12 @@ primitive !externalcall val val -> val package main _plain package architectural _linkage constant WORDSIZE = 2 __architectural - constant NULL = 0xffff __architectural __hex - constant WORD_HIGHBIT = 0x8000 __architectural __hex - constant WORD_NEXTTOHIGHBIT = 0x4000 __architectural __hex - constant IMPROBABLE_VALUE = 0x7fe3 __architectural __hex + constant NULL = 0xffff __architectural + constant WORD_HIGHBIT = 0x8000 __architectural + constant WORD_NEXTTOHIGHBIT = 0x4000 __architectural + constant IMPROBABLE_VALUE = 0x7fe3 __architectural constant MAX_POSITIVE_NUMBER = 32767 __architectural - constant MIN_NEGATIVE_NUMBER = -32768 __architectural __signed + constant MIN_NEGATIVE_NUMBER = -32768 __architectural constant TARGET_ZCODE = 1 __architectural constant DEBUG = 1 __architectural package generic _module diff --git a/inter/Tests/Valid/misc.intert b/inter/Tests/Valid/misc.intert index 500b65504..230198420 100644 --- a/inter/Tests/Valid/misc.intert +++ b/inter/Tests/Valid/misc.intert @@ -16,7 +16,7 @@ package main _plain constant (K_number) C_death = -5 constant (K_number) C_taxes = 14 variable (K_number) V_anxiety = C_death - constant (K_number) C_x = 0x7f2a __hex + constant (K_number) C_x = 0x7f2a constant (K_number) cornelius = dw"frogs" constant (K_number) gaius = dw"toads" splat "Sing a song of \"six splats\"...\nand don't wait up" diff --git a/inter/building-module/Chapter 1/Large-Scale Structure.w b/inter/building-module/Chapter 1/Large-Scale Structure.w index 1d69fca2a..4891cff68 100644 --- a/inter/building-module/Chapter 1/Large-Scale Structure.w +++ b/inter/building-module/Chapter 1/Large-Scale Structure.w @@ -206,7 +206,7 @@ inter_symbol *LargeScale::find_architectural_symbol(inter_tree *I, text_stream * Dictionaries::create(create_these_architectural_symbols_on_demand, I"Object"); } if (Dictionaries::find(create_these_architectural_symbols_on_demand, N)) { - S = LargeScale::arch_constant(I, N, InterTypes::unchecked(), 0); + S = LargeScale::arch_constant_dec(I, N, InterTypes::unchecked(), 0); SymbolAnnotation::set_b(S, VENEER_IANN, TRUE); } } @@ -244,55 +244,62 @@ void LargeScale::make_architectural_definitions(inter_tree *I, if (current_architecture == NULL) internal_error("no architecture set"); inter_type type = InterTypes::unchecked(); if (Architectures::is_16_bit(current_architecture)) { - LargeScale::arch_constant(I, I"WORDSIZE", type, 2); + LargeScale::arch_constant_dec(I, I"WORDSIZE", type, 2); LargeScale::arch_constant_hex(I, I"NULL", type, 0xffff); LargeScale::arch_constant_hex(I, I"WORD_HIGHBIT", type, 0x8000); LargeScale::arch_constant_hex(I, I"WORD_NEXTTOHIGHBIT", type, 0x4000); LargeScale::arch_constant_hex(I, I"IMPROBABLE_VALUE", type, 0x7fe3); - LargeScale::arch_constant(I, I"MAX_POSITIVE_NUMBER", type, 32767); + LargeScale::arch_constant_dec(I, I"MAX_POSITIVE_NUMBER", type, 32767); LargeScale::arch_constant_signed(I, I"MIN_NEGATIVE_NUMBER", type, -32768); - LargeScale::arch_constant(I, I"TARGET_ZCODE", type, 1); + LargeScale::arch_constant_dec(I, I"TARGET_ZCODE", type, 1); } else { - LargeScale::arch_constant(I, I"WORDSIZE", type, 4); + LargeScale::arch_constant_dec(I, I"WORDSIZE", type, 4); LargeScale::arch_constant_hex(I, I"NULL", type, 0xffffffff); LargeScale::arch_constant_hex(I, I"WORD_HIGHBIT", type, 0x80000000); LargeScale::arch_constant_hex(I, I"WORD_NEXTTOHIGHBIT", type, 0x40000000); LargeScale::arch_constant_hex(I, I"IMPROBABLE_VALUE", type, 0xdeadce11); - LargeScale::arch_constant(I, I"MAX_POSITIVE_NUMBER", type, 2147483647); + LargeScale::arch_constant_dec(I, I"MAX_POSITIVE_NUMBER", type, 2147483647); LargeScale::arch_constant_signed(I, I"MIN_NEGATIVE_NUMBER", type, -2147483648); - LargeScale::arch_constant(I, I"TARGET_GLULX", type, 1); + LargeScale::arch_constant_dec(I, I"TARGET_GLULX", type, 1); } if (Architectures::debug_enabled(current_architecture)) - LargeScale::arch_constant(I, I"DEBUG", type, 1); + LargeScale::arch_constant_dec(I, I"DEBUG", type, 1); } @ The functions above use the following tiny API to create architectural constants: = inter_symbol *LargeScale::arch_constant(inter_tree *I, text_stream *N, - inter_type type, inter_ti val) { + inter_type type, inter_pair val) { inter_package *arch = LargeScale::architecture_package(I); inter_symbols_table *tab = InterPackage::scope(arch); inter_symbol *S = InterSymbolsTable::symbol_from_name_creating(tab, N); SymbolAnnotation::set_b(S, ARCHITECTURAL_IANN, TRUE); inter_bookmark *IBM = &(I->site.strdata.architecture_bookmark); - Produce::guard(ConstantInstruction::new(IBM, S, type, InterValuePairs::number(val), + Produce::guard(ConstantInstruction::new(IBM, S, type, val, (inter_ti) InterBookmark::baseline(IBM) + 1, NULL)); return S; } +inter_symbol *LargeScale::arch_constant_dec(inter_tree *I, text_stream *N, + inter_type type, inter_ti val) { + inter_symbol *S = LargeScale::arch_constant(I, N, type, + InterValuePairs::number_in_base(val, 10)); + return S; +} + inter_symbol *LargeScale::arch_constant_hex(inter_tree *I, text_stream *N, inter_type type, inter_ti val) { - inter_symbol *S = LargeScale::arch_constant(I, N, type, val); - SymbolAnnotation::set_b(S, HEX_IANN, 1); + inter_symbol *S = LargeScale::arch_constant(I, N, type, + InterValuePairs::number_in_base(val, 16)); return S; } inter_symbol *LargeScale::arch_constant_signed(inter_tree *I, text_stream *N, inter_type type, int val) { - inter_symbol *S = LargeScale::arch_constant(I, N, type, (inter_ti) val); - SymbolAnnotation::set_b(S, SIGNED_IANN, 1); + inter_symbol *S = LargeScale::arch_constant(I, N, type, + InterValuePairs::signed_number(val)); return S; } diff --git a/inter/bytecode-module/Chapter 2/Annotations.w b/inter/bytecode-module/Chapter 2/Annotations.w index 8b40155ae..f7755438c 100644 --- a/inter/bytecode-module/Chapter 2/Annotations.w +++ b/inter/bytecode-module/Chapter 2/Annotations.w @@ -70,14 +70,12 @@ The set of annotations used by the Inform tool suite is as follows. @e EITHER_OR_IANN @e EXTENT_IANN @e FAKE_ACTION_IANN -@e HEX_IANN @e IMPLIED_ARGUMENT_IANN @e INLINE_ARRAY_IANN @e METAVERB_IANN @e NOUN_FILTER_IANN @e OBJECT_IANN @e SCOPE_FILTER_IANN -@e SIGNED_IANN @e TABLEARRAY_IANN @e TEXT_LITERAL_IANN @e VENEER_IANN @@ -111,14 +109,12 @@ void SymbolAnnotation::declare_canonical_annotations(void) { SymbolAnnotation::declare(EITHER_OR_IANN, I"__either_or", BOOLEAN_IATYPE); SymbolAnnotation::declare(EXTENT_IANN, I"__extent", BOOLEAN_IATYPE); SymbolAnnotation::declare(FAKE_ACTION_IANN, I"__fake_action", BOOLEAN_IATYPE); - SymbolAnnotation::declare(HEX_IANN, I"__hex", BOOLEAN_IATYPE); SymbolAnnotation::declare(IMPLIED_ARGUMENT_IANN, I"__implied_argument", BOOLEAN_IATYPE); SymbolAnnotation::declare(INLINE_ARRAY_IANN, I"__inline_array", BOOLEAN_IATYPE); SymbolAnnotation::declare(METAVERB_IANN, I"__meta_verb", BOOLEAN_IATYPE); SymbolAnnotation::declare(NOUN_FILTER_IANN, I"__noun_filter", BOOLEAN_IATYPE); SymbolAnnotation::declare(OBJECT_IANN, I"__object", BOOLEAN_IATYPE); SymbolAnnotation::declare(SCOPE_FILTER_IANN, I"__scope_filter", BOOLEAN_IATYPE); - SymbolAnnotation::declare(SIGNED_IANN, I"__signed", BOOLEAN_IATYPE); SymbolAnnotation::declare(TABLEARRAY_IANN, I"__table_array", BOOLEAN_IATYPE); SymbolAnnotation::declare(TEXT_LITERAL_IANN, I"__text_literal", BOOLEAN_IATYPE); SymbolAnnotation::declare(VENEER_IANN, I"__veneer", BOOLEAN_IATYPE); diff --git a/inter/bytecode-module/Chapter 3/Inter Value Pairs.w b/inter/bytecode-module/Chapter 3/Inter Value Pairs.w index fb40ef325..7899fb4ae 100644 --- a/inter/bytecode-module/Chapter 3/Inter Value Pairs.w +++ b/inter/bytecode-module/Chapter 3/Inter Value Pairs.w @@ -22,7 +22,10 @@ typedef struct inter_pair { @ These are the formats. Note that changing any of these values would invalidate existing Inter binary files, necessitating a bump of //The Inter Version//. -@e NUMERIC_IVAL from 0x10000 +@e DECIMAL_IVAL from 0x10000 +@e HEX_IVAL +@e BINARY_IVAL +@e SIGNED_IVAL @e TEXTUAL_IVAL @e REAL_IVAL @e DWORD_IVAL @@ -33,16 +36,38 @@ existing Inter binary files, necessitating a bump of //The Inter Version//. @h Numeric pairs. These can represent any |inter_ti| value, and are used when the data is a -literal integer. +literal integer. Note that they express both an integer and also a preferred +way to print it out -- as decimal, hexadecimal, binary, or signed decimal. +But these are all numerically equal. They affect only the way in which the +Inter program is printed to text files, not the meaning of the program. = inter_pair InterValuePairs::number(inter_ti N) { inter_pair pair; - pair.data_format = NUMERIC_IVAL; + pair.data_format = DECIMAL_IVAL; pair.data_content = N; return pair; } +inter_pair InterValuePairs::number_in_base(inter_ti N, int b) { + inter_pair pair; + switch (b) { + case 2: pair.data_format = BINARY_IVAL; break; + case 10: pair.data_format = DECIMAL_IVAL; break; + case 16: pair.data_format = HEX_IVAL; break; + default: internal_error("only bases 2, 10, 16 are supported"); + } + pair.data_content = N; + return pair; +} + +inter_pair InterValuePairs::signed_number(int N) { + inter_pair pair; + pair.data_format = SIGNED_IVAL; + pair.data_content = (inter_ti) N; + return pair; +} + inter_pair InterValuePairs::number_from_I6_notation(text_stream *S) { int sign = 1, base = 10, from = 0; if (Str::prefix_eq(S, I"-", 1)) { sign = -1; from = 1; } @@ -64,7 +89,17 @@ inter_pair InterValuePairs::number_from_I6_notation(text_stream *S) { } inter_ti InterValuePairs::to_number(inter_pair pair) { - if (pair.data_format == NUMERIC_IVAL) return pair.data_content; + if (InterValuePairs::is_number(pair)) return pair.data_content; + return 0; +} + +inter_ti InterValuePairs::to_base(inter_pair pair) { + switch (pair.data_format) { + case DECIMAL_IVAL: return 10; + case SIGNED_IVAL: return 10; + case HEX_IVAL: return 16; + case BINARY_IVAL: return 2; + } return 0; } @@ -72,18 +107,22 @@ inter_ti InterValuePairs::to_number(inter_pair pair) { = int InterValuePairs::is_number(inter_pair pair) { - if (pair.data_format == NUMERIC_IVAL) return TRUE; + if ((pair.data_format == DECIMAL_IVAL) || + (pair.data_format == HEX_IVAL) || + (pair.data_format == BINARY_IVAL) || + (pair.data_format == SIGNED_IVAL)) + return TRUE; return FALSE; } int InterValuePairs::is_one(inter_pair pair) { - if ((pair.data_format == NUMERIC_IVAL) && + if ((InterValuePairs::is_number(pair)) && (pair.data_content == 1)) return TRUE; return FALSE; } int InterValuePairs::is_zero(inter_pair pair) { - if ((pair.data_format == NUMERIC_IVAL) && + if ((InterValuePairs::is_number(pair)) && (pair.data_content == 0)) return TRUE; return FALSE; } @@ -400,8 +439,8 @@ inter_error_message *InterValuePairs::verify(inter_package *owner, inter_tree_no inter_pair pair, inter_type type) { inter_symbols_table *scope = InterPackage::scope(owner); if (scope == NULL) scope = Inode::globals(P); + if (InterValuePairs::is_number(pair)) @ switch (pair.data_format) { - case NUMERIC_IVAL: @; case SYMBOLIC_IVAL: @; case DWORD_IVAL: case PDWORD_IVAL: diff --git a/inter/bytecode-module/Chapter 3/Inter in Text Files.w b/inter/bytecode-module/Chapter 3/Inter in Text Files.w index 0a7b9b543..8c842f619 100644 --- a/inter/bytecode-module/Chapter 3/Inter in Text Files.w +++ b/inter/bytecode-module/Chapter 3/Inter in Text Files.w @@ -422,7 +422,7 @@ in an interleaved form, to keep each notation together. Both have a simple outer structure: = -void TextualInter::write_pair(OUTPUT_STREAM, inter_tree_node *P, inter_pair pair, int hex) { +void TextualInter::write_pair(OUTPUT_STREAM, inter_tree_node *P, inter_pair pair) { inter_tree *I = Inode::tree(P); if (InterValuePairs::is_number(pair)) @ @@ -480,8 +480,12 @@ inter_error_message *TextualInter::parse_pair(text_stream *line, inter_error_loc or (unsigned) binary, but cannot be printed back in binary. @ = - if (hex) WRITE("0x%x", InterValuePairs::to_number(pair)); - else WRITE("%d", InterValuePairs::to_number(pair)); + switch (InterValuePairs::to_base(pair)) { + case 10: WRITE("%d", InterValuePairs::to_number(pair)); break; + case 2: + case 16: WRITE("0x%x", InterValuePairs::to_number(pair)); break; + default: WRITE("???"); break; + } @ = wchar_t c = first_char; @@ -506,7 +510,8 @@ or (unsigned) binary, but cannot be printed back in binary. N = sign*N; if (InterTypes::literal_is_in_range(N, type_wanted) == FALSE) return InterErrors::quoted(I"value out of range", S, eloc); - *pair = InterValuePairs::number((inter_ti) N); + if (sign == -1) *pair = InterValuePairs::signed_number((int) N); + else *pair = InterValuePairs::number_in_base((inter_ti) N, base); return NULL; } diff --git a/inter/bytecode-module/Chapter 4/The Constant Construct.w b/inter/bytecode-module/Chapter 4/The Constant Construct.w index e9820b57b..75b074783 100644 --- a/inter/bytecode-module/Chapter 4/The Constant Construct.w +++ b/inter/bytecode-module/Chapter 4/The Constant Construct.w @@ -245,8 +245,6 @@ void ConstantInstruction::read(inter_construct *IC, inter_bookmark *IBM, = void ConstantInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) { inter_symbol *con_name = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_CONST_IFLD); - int hex = FALSE; - if (SymbolAnnotation::get_b(con_name, HEX_IANN)) hex = TRUE; WRITE("constant "); TextualInter::write_optional_type_marker(OUT, P, TYPE_CONST_IFLD); WRITE("%S = ", InterSymbol::identifier(con_name)); @@ -262,10 +260,9 @@ void ConstantInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) { if (i > DATA_CONST_IFLD) WRITE(","); if (fmt != CONST_LIST_FORMAT_NONE) WRITE(" "); - TextualInter::write_pair(OUT, P, InterValuePairs::get(P, i), hex); + TextualInter::write_pair(OUT, P, InterValuePairs::get(P, i)); } if (fmt != CONST_LIST_FORMAT_NONE) WRITE(" }"); -// SymbolAnnotation::write_annotations(OUT, P, con_name); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 4/The Instance Construct.w b/inter/bytecode-module/Chapter 4/The Instance Construct.w index 77d34dad4..a08c1b603 100644 --- a/inter/bytecode-module/Chapter 4/The Instance Construct.w +++ b/inter/bytecode-module/Chapter 4/The Instance Construct.w @@ -137,8 +137,7 @@ void InstanceInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n inter_symbol *typename_s = InterSymbolsTable::symbol_from_ID_at_node(P, TYPE_INST_IFLD); WRITE("instance (%S) %S = ", InterSymbol::identifier(typename_s), InterSymbol::identifier(instance_s)); - TextualInter::write_pair(OUT, P, InterValuePairs::get(P, VAL1_INST_IFLD), FALSE); -// SymbolAnnotation::write_annotations(OUT, P, instance_s); + TextualInter::write_pair(OUT, P, InterValuePairs::get(P, VAL1_INST_IFLD)); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 4/The Property Construct.w b/inter/bytecode-module/Chapter 4/The Property Construct.w index b34ba3bed..4324bbfce 100644 --- a/inter/bytecode-module/Chapter 4/The Property Construct.w +++ b/inter/bytecode-module/Chapter 4/The Property Construct.w @@ -88,7 +88,6 @@ void PropertyInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n WRITE("property "); TextualInter::write_optional_type_marker(OUT, P, TYPE_PROP_IFLD); WRITE("%S", InterSymbol::identifier(prop_name)); -// SymbolAnnotation::write_annotations(OUT, P, prop_name); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w b/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w index 62e96bcdf..034bae751 100644 --- a/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w +++ b/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w @@ -160,7 +160,7 @@ void PropertyValueInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_t inter_symbol *owner_s = PropertyValueInstruction::owner(P); WRITE("propertyvalue %S of %S = ", InterSymbol::identifier(prop_s), InterSymbol::identifier(owner_s)); - TextualInter::write_pair(OUT, P, PropertyValueInstruction::value(P), FALSE); + TextualInter::write_pair(OUT, P, PropertyValueInstruction::value(P)); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 4/The Typename Construct.w b/inter/bytecode-module/Chapter 4/The Typename Construct.w index de740116d..38f718771 100644 --- a/inter/bytecode-module/Chapter 4/The Typename Construct.w +++ b/inter/bytecode-module/Chapter 4/The Typename Construct.w @@ -160,7 +160,6 @@ void TypenameInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n WRITE("= "); InterTypes::write_typename_definition(OUT, typename_s); } -// SymbolAnnotation::write_annotations(OUT, P, typename_s); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 4/The Variable Construct.w b/inter/bytecode-module/Chapter 4/The Variable Construct.w index d64941e1c..4c9ae8c2d 100644 --- a/inter/bytecode-module/Chapter 4/The Variable Construct.w +++ b/inter/bytecode-module/Chapter 4/The Variable Construct.w @@ -96,8 +96,7 @@ void VariableInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n WRITE("variable "); TextualInter::write_optional_type_marker(OUT, P, TYPE_VAR_IFLD); WRITE("%S = ", InterSymbol::identifier(var_s)); - TextualInter::write_pair(OUT, P, VariableInstruction::value(P), FALSE); -// SymbolAnnotation::write_annotations(OUT, P, var_s); + TextualInter::write_pair(OUT, P, VariableInstruction::value(P)); } @h Access functions. diff --git a/inter/bytecode-module/Chapter 5/The Local Construct.w b/inter/bytecode-module/Chapter 5/The Local Construct.w index 1f969623e..01ab1bfeb 100644 --- a/inter/bytecode-module/Chapter 5/The Local Construct.w +++ b/inter/bytecode-module/Chapter 5/The Local Construct.w @@ -76,7 +76,6 @@ void LocalInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node TextualInter::write_optional_type_marker(OUT, P, TYPE_LOCAL_IFLD); inter_symbol *variable_s = LocalInstruction::variable(P); WRITE("%S", InterSymbol::identifier(variable_s)); -// SymbolAnnotation::write_annotations(OUT, P, variable_s); } @h Access function. diff --git a/inter/bytecode-module/Chapter 5/The Ref Construct.w b/inter/bytecode-module/Chapter 5/The Ref Construct.w index b29a7a18c..dec09e401 100644 --- a/inter/bytecode-module/Chapter 5/The Ref Construct.w +++ b/inter/bytecode-module/Chapter 5/The Ref Construct.w @@ -78,7 +78,7 @@ void RefInstruction::read(inter_construct *IC, inter_bookmark *IBM, inter_line_p void RefInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) { WRITE("ref "); TextualInter::write_optional_type_marker(OUT, P, TYPE_REF_IFLD); - TextualInter::write_pair(OUT, P, RefInstruction::value(P), FALSE); + TextualInter::write_pair(OUT, P, RefInstruction::value(P)); } @h Access function. diff --git a/inter/bytecode-module/Chapter 5/The Val Construct.w b/inter/bytecode-module/Chapter 5/The Val Construct.w index 53767c22d..2880e6714 100644 --- a/inter/bytecode-module/Chapter 5/The Val Construct.w +++ b/inter/bytecode-module/Chapter 5/The Val Construct.w @@ -96,7 +96,7 @@ void ValInstruction::read(inter_construct *IC, inter_bookmark *IBM, inter_line_p void ValInstruction::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P) { WRITE("val "); TextualInter::write_optional_type_marker(OUT, P, TYPE_VAL_IFLD); - TextualInter::write_pair(OUT, P, ValInstruction::value(P), FALSE); + TextualInter::write_pair(OUT, P, ValInstruction::value(P)); } @h Access function. diff --git a/inter/final-module/Chapter 2/Vanilla Constants.w b/inter/final-module/Chapter 2/Vanilla Constants.w index b63b66744..25074e953 100644 --- a/inter/final-module/Chapter 2/Vanilla Constants.w +++ b/inter/final-module/Chapter 2/Vanilla Constants.w @@ -163,17 +163,9 @@ void VanillaConstants::definition_value(code_generation *gen, int form, Generators::compile_literal_number(gen, 1, FALSE); } break; - case DATA_GDCFORM: { - inter_pair val = ConstantInstruction::constant(P); - if ((InterValuePairs::is_number(val)) && - (SymbolAnnotation::get_b(con_name, HEX_IANN))) { - inter_ti N = InterValuePairs::to_number(val); - Generators::compile_literal_number(gen, N, TRUE); - } else { - CodeGen::pair(gen, P, val); - } + case DATA_GDCFORM: + CodeGen::pair(gen, P, ConstantInstruction::constant(P)); break; - } case COMPUTED_GDCFORM: { WRITE("("); for (int i=0; i