mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Have std/json pushes be (from, to) not just (to)
This commit is contained in:
1 parent
b2dd7d952c
commit
01bab82970
3 files changed
+51
-21
No files matched your search
@@ -377,8 +377,8 @@ continue_loop:
|
||||
}
|
||||
}
|
||||
|
||||
TRY(write_dst((vbd & 0x10) ? "]" : "}", 1));
|
||||
ctx = (vbd & 0x1000) ? context::in_list_after_value
|
||||
TRY(write_dst((vbd & 0x20) ? "]" : "}", 1));
|
||||
ctx = (vbd & 0x2000) ? context::in_list_after_value
|
||||
: context::in_dict_after_key;
|
||||
goto after_value;
|
||||
}
|
||||
@@ -401,10 +401,10 @@ continue_loop:
|
||||
// value (number, string or literal).
|
||||
switch (vbc) {
|
||||
case 1:
|
||||
TRY(write_dst((vbd & 0x10) ? "[" : "{", 1));
|
||||
TRY(write_dst((vbd & 0x2000) ? "[" : "{", 1));
|
||||
depth++;
|
||||
ctx = (vbd & 0x10) ? context::in_list_after_bracket
|
||||
: context::in_dict_after_brace;
|
||||
ctx = (vbd & 0x2000) ? context::in_list_after_bracket
|
||||
: context::in_dict_after_brace;
|
||||
goto continue_loop;
|
||||
|
||||
case 2:
|
||||
|
||||
@@ -18971,6 +18971,13 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
label_6_break:;
|
||||
goto label_5_break;
|
||||
} else if (v_class == 5) {
|
||||
v_token_value = 2113553;
|
||||
if (v_depth == 0) {
|
||||
} else if (0 != (v_expect_after_value & 64)) {
|
||||
v_token_value = 2113601;
|
||||
} else {
|
||||
v_token_value = 2113569;
|
||||
}
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
@@ -18983,7 +18990,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
v_depth += 1;
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2097185)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(v_token_value)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 66;
|
||||
v_expect_after_value = 68;
|
||||
@@ -18992,7 +18999,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_depth <= 1) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2097186)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2101314)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
@@ -19002,19 +19009,26 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
if (0 == (self->private_data.f_stack[v_stack_byte] &
|
||||
(((uint32_t)(1)) << v_stack_bit))) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2101282)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2105410)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 260;
|
||||
v_expect_after_value = 260;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105378)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2113602)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 68;
|
||||
v_expect_after_value = 68;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else if (v_class == 7) {
|
||||
v_token_value = 2105361;
|
||||
if (v_depth == 0) {
|
||||
} else if (0 != (v_expect_after_value & 64)) {
|
||||
v_token_value = 2105409;
|
||||
} else {
|
||||
v_token_value = 2105377;
|
||||
}
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
@@ -19027,7 +19041,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
v_depth += 1;
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2097169)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(v_token_value)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 4018;
|
||||
v_expect_after_value = 260;
|
||||
@@ -19036,7 +19050,7 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_depth <= 1) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2097170)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2101282)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
@@ -19046,13 +19060,13 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
if (0 == (self->private_data.f_stack[v_stack_byte] &
|
||||
(((uint32_t)(1)) << v_stack_bit))) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2101266)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2105378)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 260;
|
||||
v_expect_after_value = 260;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105362)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(2113570)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 68;
|
||||
v_expect_after_value = 68;
|
||||
|
||||
@@ -384,6 +384,14 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
// -------- END parse numbers.
|
||||
|
||||
} else if class == 0x05 { // 0x05 is CLASS_OPEN_CURLY_BRACE.
|
||||
token_value = 0x20_4011
|
||||
if depth == 0 {
|
||||
// No-op.
|
||||
} else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is EXPECT_CLOSE_CURLY_BRACE.
|
||||
token_value = 0x20_4041
|
||||
} else {
|
||||
token_value = 0x20_4021
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
@@ -394,7 +402,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_0021,
|
||||
value: token_value,
|
||||
length: 1)
|
||||
expect = 0x0042 // 0x0042 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_STRING).
|
||||
expect_after_value = 0x0044 // 0x0044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA).
|
||||
@@ -404,7 +412,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
if depth <= 1 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_0022,
|
||||
value: 0x20_1042,
|
||||
length: 1)
|
||||
break.outer
|
||||
}
|
||||
@@ -413,14 +421,14 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
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,
|
||||
value: 0x20_2042,
|
||||
length: 1)
|
||||
// 0x0104 is (EXPECT_SQUARE_CLOSE_BRACKET | EXPECT_COMMA).
|
||||
expect = 0x0104
|
||||
expect_after_value = 0x0104
|
||||
} else {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_2022,
|
||||
value: 0x20_4042,
|
||||
length: 1)
|
||||
// 0x0044 is (EXPECT_CURLY_CLOSE_BRACE | EXPECT_COMMA).
|
||||
expect = 0x0044
|
||||
@@ -429,6 +437,14 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
continue.outer
|
||||
|
||||
} else if class == 0x07 { // 0x07 is CLASS_OPEN_SQUARE_BRACKET.
|
||||
token_value = 0x20_2011
|
||||
if depth == 0 {
|
||||
// No-op.
|
||||
} else if 0 <> (expect_after_value & 0x0040) { // 0x0040 is EXPECT_CLOSE_CURLY_BRACE.
|
||||
token_value = 0x20_2041
|
||||
} else {
|
||||
token_value = 0x20_2021
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
@@ -439,7 +455,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_0011,
|
||||
value: token_value,
|
||||
length: 1)
|
||||
expect = 0x0FB2 // 0x0FB2 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_VALUE).
|
||||
expect_after_value = 0x0104 // 0x0104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA).
|
||||
@@ -449,7 +465,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
if depth <= 1 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_0012,
|
||||
value: 0x20_1022,
|
||||
length: 1)
|
||||
break.outer
|
||||
}
|
||||
@@ -458,14 +474,14 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
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,
|
||||
value: 0x20_2022,
|
||||
length: 1)
|
||||
// 0x0104 is (EXPECT_CLOSE_SQUARE_BRACKET | EXPECT_COMMA).
|
||||
expect = 0x0104
|
||||
expect_after_value = 0x0104
|
||||
} else {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x20_2012,
|
||||
value: 0x20_4022,
|
||||
length: 1)
|
||||
// 0x0044 is (EXPECT_CLOSE_CURLY_BRACE | EXPECT_COMMA).
|
||||
expect = 0x0044
|
||||
|
||||
Reference in new issue
Block a user