Skip to content

Commit df7ba6c

Browse files
authored
Restacks the 1.1 system symbol and macro tables (#879)
1 parent fd97f5d commit df7ba6c

File tree

9 files changed

+186
-189
lines changed

9 files changed

+186
-189
lines changed

src/constants.rs

Lines changed: 107 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -69,55 +69,53 @@ pub(crate) mod v1_1 {
6969
"macro_table", // $14
7070
"symbol_table", // $15
7171
"module", // $16
72-
"<REMOVE>", // $17 (see: ion-docs#345)
73-
"export", // $18
74-
"<REMOVE>", // $19 (see: ion-docs#345)
75-
"import", // $20
76-
"", // $21 (empty text)
77-
"literal", // $22
78-
"if_none", // $23
79-
"if_some", // $24
80-
"if_single", // $25
81-
"if_multi", // $26
82-
"for", // $27
83-
"default", // $28
84-
"values", // $29
85-
"annotate", // $30
86-
"make_string", // $31
87-
"make_symbol", // $32
88-
"make_blob", // $33
89-
"make_decimal", // $34
90-
"make_timestamp", // $35
91-
"make_list", // $36
92-
"make_sexp", // $37
93-
"make_struct", // $38
94-
"parse_ion", // $39
95-
"repeat", // $40
96-
"delta", // $41
97-
"flatten", // $42
98-
"sum", // $43
99-
"set_symbols", // $44
100-
"add_symbols", // $45
101-
"set_macros", // $46
102-
"add_macros", // $47
103-
"use", // $48
104-
"meta", // $49
105-
"flex_symbol", // $50
106-
"flex_int", // $51
107-
"flex_uint", // $52
108-
"uint8", // $53
109-
"uint16", // $54
110-
"uint32", // $55
111-
"uint64", // $56
112-
"int8", // $57
113-
"int16", // $58
114-
"int32", // $59
115-
"int64", // $60
116-
"float16", // $61
117-
"float32", // $62
118-
"float64", // $63
119-
"none", // $64
120-
"make_field", // $65
72+
"export", // $17
73+
"import", // $18
74+
"flex_symbol", // $19
75+
"flex_int", // $20
76+
"flex_uint", // $21
77+
"uint8", // $22
78+
"uint16", // $23
79+
"uint32", // $24
80+
"uint64", // $25
81+
"int8", // $26
82+
"int16", // $27
83+
"int32", // $28
84+
"int64", // $29
85+
"float16", // $30
86+
"float32", // $31
87+
"float64", // $32
88+
"", // $33 (empty text)
89+
"for", // $34
90+
"literal", // $35
91+
"if_none", // $36
92+
"if_some", // $37
93+
"if_single", // $38
94+
"if_multi", // $39
95+
"none", // $40
96+
"values", // $41
97+
"default", // $42
98+
"meta", // $43
99+
"repeat", // $44
100+
"flatten", // $45
101+
"delta", // $46
102+
"sum", // $47
103+
"annotate", // $48
104+
"make_string", // $49
105+
"make_symbol", // $50
106+
"make_decimal", // $51
107+
"make_timestamp", // $52
108+
"make_blob", // $53
109+
"make_list", // $54
110+
"make_sexp", // $55
111+
"make_field", // $56
112+
"make_struct", // $57
113+
"parse_ion", // $58
114+
"set_symbols", // $59
115+
"add_symbols", // $60
116+
"set_macros", // $61
117+
"add_macros", // $62
118+
"use", // $63
121119
];
122120

123121
pub mod system_symbols {
@@ -127,80 +125,78 @@ pub(crate) mod v1_1 {
127125
pub const ENCODING: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(10);
128126
pub const SYMBOL_TABLE: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(15);
129127
pub const MODULE: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(16);
130-
pub const EMPTY_TEXT: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(21);
131-
pub const ADD_SYMBOLS: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(45);
132-
pub const ADD_MACROS: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(47);
128+
pub const EMPTY_TEXT: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(33);
129+
pub const ADD_SYMBOLS: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(60);
130+
pub const ADD_MACROS: SystemSymbol_1_1 = SystemSymbol_1_1::new_unchecked(62);
133131
}
134132

135133
/// A static, read-only map of text to Ion v1.1 system symbol addresses.
136134
/// Because the set of string keys is known at compile time, this map is able to use a
137135
/// perfect hashing function (PHF) to optimize lookup operations for those keys.
138136
pub(crate) static SYSTEM_SYMBOL_TEXT_TO_ID: phf::Map<&str, usize> = phf_map! {
139-
"$ion" => 1,
140-
"$ion_1_0" => 2,
141-
"$ion_symbol_table" => 3,
142-
"name" => 4,
143-
"version" => 5,
144-
"imports" => 6,
145-
"symbols" => 7,
146-
"max_id" => 8,
147-
"$ion_shared_symbol_table" => 9,
148-
"$ion_encoding" => 10,
137+
"$ion" => 1,
138+
"$ion_1_0" => 2,
139+
"$ion_symbol_table" => 3,
140+
"name" => 4,
141+
"version" => 5,
142+
"imports" => 6,
143+
"symbols" => 7,
144+
"max_id" => 8,
145+
"$ion_shared_symbol_table" => 9,
146+
"encoding" => 10,
149147
"$ion_literal" => 11,
150148
"$ion_shared_module" => 12,
151149
"macro" => 13,
152150
"macro_table" => 14,
153151
"symbol_table" => 15,
154152
"module" => 16,
155-
// ion-docs#345 => 17,
156-
"export" => 18,
157-
// ion-docs#345 => 19,
158-
"import" => 20,
159-
"" => 21,
160-
"literal" => 22,
161-
"if_none" => 23,
162-
"if_some" => 24,
163-
"if_single" => 25,
164-
"if_multi" => 26,
165-
"for" => 27,
166-
"default" => 28,
167-
"values" => 29,
168-
"annotate" => 30,
169-
"make_string" => 31,
170-
"make_symbol" => 32,
171-
"make_blob" => 33,
172-
"make_decimal" => 34,
173-
"make_timestamp" => 35,
174-
"make_list" => 36,
175-
"make_sexp" => 37,
176-
"make_struct" => 38,
177-
"parse_ion" => 39,
178-
"repeat" => 40,
179-
"delta" => 41,
180-
"flatten" => 42,
181-
"sum" => 43,
182-
"set_symbols" => 44,
183-
"add_symbols" => 45,
184-
"set_macros" => 46,
185-
"add_macros" => 47,
186-
"use" => 48,
187-
"meta" => 49,
188-
"flex_symbol" => 50,
189-
"flex_int" => 51,
190-
"flex_uint" => 52,
191-
"uint8" => 53,
192-
"uint16" => 54,
193-
"uint32" => 55,
194-
"uint64" => 56,
195-
"int8" => 57,
196-
"int16" => 58,
197-
"int32" => 59,
198-
"int64" => 60,
199-
"float16" => 61,
200-
"float32" => 62,
201-
"float64" => 63,
202-
"none" => 64,
203-
"make_field" => 65,
153+
"export" => 17,
154+
"import" => 18,
155+
"flex_symbol" => 19,
156+
"flex_int" => 20,
157+
"flex_uint" => 21,
158+
"uint8" => 22,
159+
"uint16" => 23,
160+
"uint32" => 24,
161+
"uint64" => 25,
162+
"int8" => 26,
163+
"int16" => 27,
164+
"int32" => 28,
165+
"int64" => 29,
166+
"float16" => 30,
167+
"float32" => 31,
168+
"float64" => 32,
169+
"" => 33,
170+
"for" => 34,
171+
"literal" => 35,
172+
"if_none" => 36,
173+
"if_some" => 37,
174+
"if_single" => 38,
175+
"if_multi" => 39,
176+
"none" => 40,
177+
"values" => 41,
178+
"default" => 42,
179+
"meta" => 43,
180+
"repeat" => 44,
181+
"flatten" => 45,
182+
"delta" => 46,
183+
"sum" => 47,
184+
"annotate" => 48,
185+
"make_string" => 49,
186+
"make_symbol" => 50,
187+
"make_decimal" => 51,
188+
"make_timestamp" => 52,
189+
"make_blob" => 53,
190+
"make_list" => 54,
191+
"make_sexp" => 55,
192+
"make_field" => 56,
193+
"make_struct" => 57,
194+
"parse_ion" => 58,
195+
"set_symbols" => 59,
196+
"add_symbols" => 60,
197+
"set_macros" => 61,
198+
"add_macros" => 62,
199+
"use" => 63,
204200
};
205201

206202
pub fn address_for_text(text: &str) -> Option<usize> {

src/lazy/binary/raw/v1_1/immutable_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ mod tests {
12751275
RawSymbolRef::SymbolId(0),
12761276
RawSymbolRef::Text("encoding"),
12771277
])]
1278-
#[case::three_flex_syms_with_system_symbols(AnnotationsEncoding::FlexSym, &[0xE9, 0x0D, 0x01, 0x60, 0x01, 0x6A, 0x01, 0xA1], 2, 6, &[
1278+
#[case::three_flex_syms_with_system_symbols(AnnotationsEncoding::FlexSym, &[0xE9, 0x0D, 0x01, 0x60, 0x01, 0x6A, 0x01, 0x98], 2, 6, &[
12791279
RawSymbolRef::SymbolId(0),
12801280
RawSymbolRef::Text("encoding"),
12811281
RawSymbolRef::Text("make_field"),

src/lazy/binary/raw/v1_1/reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ mod tests {
349349
// System symbols
350350
0xEE, 0x0A, // encoding
351351
0xEE, 0x0E, // macro_table
352-
0xEE, 0x15, // empty text
353-
0xEE, 0x41, // make_field
352+
0xEE, 0x21, // empty text
353+
0xEE, 0x38, // make_field
354354
];
355355
let empty_context = EncodingContext::empty();
356356
let context = empty_context.get_ref();

src/lazy/encoder/binary/v1_1/value_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2931,7 +2931,7 @@ mod tests {
29312931
args.close()
29322932
},
29332933
&[
2934-
0xEF, 0x03, // Invoke system macro address 3
2934+
0xEF, 0x09, // Invoke system macro address 3
29352935
0xA3, 0x66, 0x6f, 0x6f, // foo
29362936
0xA3, 0x62, 0x61, 0x72, // bar
29372937
0xA3, 0x62, 0x61, 0x7a, // baz

src/lazy/encoder/writer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ mod tests {
833833
(Text("$ion_symbol_table"), &[0xE1, 0x03]),
834834
(Text("name"), &[0xE1, 0x04]),
835835
(SymbolId(6), &[0xE1, 0x06]), // SIDs are written as-is
836-
(Text("foo"), &[0xE1, 0x42]), // Text is added to the symbol table and encoded as a SID
836+
(Text("foo"), &[0xE1, 0x40]), // Text is added to the symbol table and encoded as a SID
837837
],
838838
)
839839
}
@@ -916,7 +916,7 @@ mod tests {
916916
0x07, // FlexSym SID $3
917917
0x09, // FlexSym SID $4
918918
0x0D, // FlexSym SID $6
919-
0x0A, 0x01, // FlexSym SID $66
919+
0x02, 0x01, // FlexSym SID $64
920920
],
921921
)
922922
}
@@ -1010,12 +1010,12 @@ mod tests {
10101010
FieldNameEncoding::WriteAsSymbolIds,
10111011
&[
10121012
// New symbols
1013-
(RawSymbolRef::Text("foo"), &[0x85]), // FlexUInt SID $66,
1014-
(RawSymbolRef::Text("bar"), &[0x87]), // FlexUInt SID $67,
1015-
(RawSymbolRef::Text("baz"), &[0x89]), // FlexUInt SID $68,
1013+
(RawSymbolRef::Text("foo"), &[0x81]), // FlexUInt SID $64,
1014+
(RawSymbolRef::Text("bar"), &[0x83]), // FlexUInt SID $65,
1015+
(RawSymbolRef::Text("baz"), &[0x85]), // FlexUInt SID $66,
10161016
// Symbols that are already in the symbol table
10171017
(RawSymbolRef::Text("name"), &[0x09]), // FlexUInt SID $4,
1018-
(RawSymbolRef::Text("foo"), &[0x85]), // FlexUInt SID $66,
1018+
(RawSymbolRef::Text("foo"), &[0x81]), // FlexUInt SID $64,
10191019
],
10201020
)
10211021
}

src/lazy/expanded/macro_evaluator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ mod tests {
16061606
bin_stream_eq(
16071607
&[
16081608
0xEF, // System macro, address follows as 1-byte FixedUInt
1609-
0x03, // make_string
1609+
0x09, // make_string
16101610
0x02, // Argument group
16111611
0x11, // FlexUInt 8: 8-byte group
16121612
0x93, // Opcode: 3-byte string follows
@@ -1624,7 +1624,7 @@ mod tests {
16241624
bin_stream_eq(
16251625
&[
16261626
0xEF, // System macro, address follows as 1-byte FixedUInt
1627-
0x03, // make_string
1627+
0x09, // make_string
16281628
0x02, // Argument group
16291629
0x01, // FlexUInt 0: delimited group
16301630
0xF0, // Delimited END
@@ -1635,7 +1635,7 @@ mod tests {
16351635
bin_stream_eq(
16361636
&[
16371637
0xEF, // System macro, address follows as 1-byte FixedUInt
1638-
0x03, // make_string
1638+
0x09, // make_string
16391639
0x02, // Argument group
16401640
0x01, // FlexUInt 0: delimited group
16411641
0x93, // Opcode: 3-byte string follows

0 commit comments

Comments
 (0)