Have std/json pops show parent container type

This commit is contained in:
Nigel Tao committed 2020-02-16 22:19:12 +11:00
1 parent 293e9a8928
commit 58a4aba4d4
2 files changed
+28 -12

No files matched your search

+8 -4
View File
@@ -250,7 +250,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
depth += 1
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0010, length: 1)
args.dst.write_fast_token!(value: 0x20_0011, length: 1)
expect = 0x13 // 0x13 is (EXPECT_CLOSE_BRACKET | EXPECT_VALUE).
expect_after_value = 0x14 // 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
continue.outer
@@ -260,18 +260,20 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
return "#bad input"
}
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0050, length: 1)
if depth <= 1 {
args.dst.write_fast_token!(value: 0x20_0012, length: 1)
break.outer
}
depth -= 1
stack_byte = (depth - 1) / 32
stack_bit = (depth - 1) & 31
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
args.dst.write_fast_token!(value: 0x20_1012, length: 1)
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
expect = 0x14
expect_after_value = 0x14
} else {
args.dst.write_fast_token!(value: 0x20_2012, length: 1)
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
expect = 0x24
expect_after_value = 0x24
@@ -291,7 +293,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
depth += 1
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0020, length: 1)
args.dst.write_fast_token!(value: 0x20_0021, length: 1)
expect = 0x22 // 0x22 is (EXPECT_CLOSE_BRACE | EXPECT_STRING_VALUE).
expect_after_value = 0x24 // 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
continue.outer
@@ -301,18 +303,20 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
return "#bad input"
}
args.src.skip32_fast!(actual: 1, worst_case: 1)
args.dst.write_fast_token!(value: 0x20_0060, length: 1)
if depth <= 1 {
args.dst.write_fast_token!(value: 0x20_0022, length: 1)
break.outer
}
depth -= 1
stack_byte = (depth - 1) / 32
stack_bit = (depth - 1) & 31
if 0 == (this.stack[stack_byte] & ((1 as base.u32) << stack_bit)) {
args.dst.write_fast_token!(value: 0x20_1022, length: 1)
// 0x14 is (EXPECT_CLOSE_BRACKET | EXPECT_COMMA).
expect = 0x14
expect_after_value = 0x14
} else {
args.dst.write_fast_token!(value: 0x20_2022, length: 1)
// 0x24 is (EXPECT_CLOSE_BRACE | EXPECT_COMMA).
expect = 0x24
expect_after_value = 0x24