mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add a "while.goto_foo true { etc }" to std/json
This commit is contained in:
1 parent
c92c0f50e4
commit
93b09674a9
2 files changed
+716
-652
No files matched your search
@@ -18585,117 +18585,88 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
v_expect = 3;
|
||||
label_0_continue:;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
goto label_0_continue;
|
||||
}
|
||||
v_whitespace_length = 0;
|
||||
v_c = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
}
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
v_whitespace_length = 0;
|
||||
goto label_0_continue;
|
||||
}
|
||||
v_c = wuffs_base__load_u8be(iop_a_src);
|
||||
if (v_c > 32) {
|
||||
goto label_1_break;
|
||||
} else if ((v_c != 32) && (v_c != 10) && (v_c != 9) && (v_c != 13)) {
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_whitespace_length >= 65534) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(65535)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
goto label_0_continue;
|
||||
}
|
||||
v_whitespace_length += 1;
|
||||
}
|
||||
label_1_break:;
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
goto label_0_continue;
|
||||
}
|
||||
}
|
||||
if (v_c <= 57) {
|
||||
if (v_c == 34) {
|
||||
if (0 == (v_expect & 2)) {
|
||||
v_whitespace_length = 0;
|
||||
v_c = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
}
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
v_whitespace_length = 0;
|
||||
goto label_0_continue;
|
||||
}
|
||||
v_c = wuffs_base__load_u8be(iop_a_src);
|
||||
if (v_c > 32) {
|
||||
goto label_1_break;
|
||||
} else if ((v_c != 32) && (v_c != 10) && (v_c != 9) && (v_c != 13)) {
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_whitespace_length >= 65534) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(65535)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
goto label_0_continue;
|
||||
}
|
||||
v_whitespace_length += 1;
|
||||
}
|
||||
label_1_break:;
|
||||
if (v_whitespace_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
label_2_continue:;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
goto label_2_continue;
|
||||
(((uint64_t)(((uint64_t)(v_whitespace_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_whitespace_length = 0;
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
}
|
||||
if (v_c <= 57) {
|
||||
if (v_c == 34) {
|
||||
if (0 == (v_expect & 2)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
v_string_length = 0;
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
label_2_continue:;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
if (v_string_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291457))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_string_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
}
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
v_string_length = 0;
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
goto label_2_continue;
|
||||
}
|
||||
v_c = wuffs_base__load_u8be(iop_a_src);
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_c <= 34) {
|
||||
if (v_c == 34) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291456))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_string_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
goto label_2_break;
|
||||
} else if (v_c < 32) {
|
||||
v_string_length = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
if (v_string_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291457))
|
||||
@@ -18704,43 +18675,151 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
}
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
v_string_length = 0;
|
||||
goto label_2_continue;
|
||||
}
|
||||
v_c = wuffs_base__load_u8be(iop_a_src);
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
if (v_c <= 34) {
|
||||
if (v_c == 34) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291456))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_string_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
goto label_2_break;
|
||||
} else if (v_c < 32) {
|
||||
if (v_string_length > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291457))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_string_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
}
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
} else if (v_c == 92) {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
} else if (v_c == 92) {
|
||||
if (v_string_length >= 65534) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291457))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(65535))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
goto label_2_continue;
|
||||
}
|
||||
v_string_length += 1;
|
||||
}
|
||||
}
|
||||
label_2_break:;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_3_break;
|
||||
}
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
label_3_break:;
|
||||
if (0 == (v_expect & 1)) {
|
||||
v_expect = 8;
|
||||
goto label_0_continue;
|
||||
}
|
||||
goto label_4_break;
|
||||
} else if (v_c == 44) {
|
||||
if (0 == (v_expect & 4)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (0 == (v_expect & 16)) {
|
||||
v_expect = 2;
|
||||
} else {
|
||||
v_expect = 3;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else if ((v_c >= 48) || (v_c == 45)) {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
while (true) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_number_length = wuffs_json__decoder__decode_number(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
v_number_status = (v_number_length >> 8);
|
||||
v_token_value = 4194306;
|
||||
if ((v_number_length & 128) != 0) {
|
||||
v_token_value = 4194308;
|
||||
}
|
||||
v_number_length = (v_number_length & 127);
|
||||
if (v_number_status == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(v_token_value))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_number_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_5_break;
|
||||
}
|
||||
while (v_number_length > 0) {
|
||||
v_number_length -= 1;
|
||||
if (iop_a_src > io1_a_src) {
|
||||
(iop_a_src--, wuffs_base__make_empty_struct());
|
||||
} else {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
if (v_number_status == 1) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
} else if (v_number_status == 2) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_number_length);
|
||||
goto exit;
|
||||
} else {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
while (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
}
|
||||
}
|
||||
if (v_string_length >= 65534) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(6291457)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(65535)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_string_length = 0;
|
||||
goto label_2_continue;
|
||||
}
|
||||
v_string_length += 1;
|
||||
}
|
||||
label_5_break:;
|
||||
goto label_4_break;
|
||||
}
|
||||
label_2_break:;
|
||||
while (true) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) > 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_3_break;
|
||||
}
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
label_3_break:;
|
||||
if (0 == (v_expect & 1)) {
|
||||
v_expect = 8;
|
||||
goto label_0_continue;
|
||||
}
|
||||
} else if (v_c == 44) {
|
||||
if (0 == (v_expect & 4)) {
|
||||
} else if (v_c == 58) {
|
||||
if (0 == (v_expect & 8)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
@@ -18748,245 +18827,175 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (0 == (v_expect & 16)) {
|
||||
v_expect = 2;
|
||||
} else {
|
||||
v_expect = 3;
|
||||
}
|
||||
v_expect = 3;
|
||||
goto label_0_continue;
|
||||
} else if ((v_c >= 48) || (v_c == 45)) {
|
||||
} else if (v_c == 91) {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
while (true) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_number_length = wuffs_json__decoder__decode_number(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
v_number_status = (v_number_length >> 8);
|
||||
v_token_value = 4194306;
|
||||
if ((v_number_length & 128) != 0) {
|
||||
v_token_value = 4194308;
|
||||
}
|
||||
v_number_length = (v_number_length & 127);
|
||||
if (v_number_status == 0) {
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
goto exit;
|
||||
}
|
||||
v_stack_byte = (v_depth / 32);
|
||||
v_stack_bit = (v_depth & 31);
|
||||
self->private_data.f_stack[v_stack_byte] &=
|
||||
(4294967295 ^ (((uint32_t)(1)) << v_stack_bit));
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 19;
|
||||
v_expect_after_value = 20;
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 93) {
|
||||
if (0 == (v_expect & 16)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
v_depth -= 1;
|
||||
v_stack_byte = ((v_depth - 1) / 32);
|
||||
v_stack_bit = ((v_depth - 1) & 31);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 20;
|
||||
v_expect_after_value = 20;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105362)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 36;
|
||||
v_expect_after_value = 36;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 123) {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
goto exit;
|
||||
}
|
||||
v_stack_byte = (v_depth / 32);
|
||||
v_stack_bit = (v_depth & 31);
|
||||
self->private_data.f_stack[v_stack_byte] |=
|
||||
(((uint32_t)(1)) << v_stack_bit);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 34;
|
||||
v_expect_after_value = 36;
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 125) {
|
||||
if (0 == (v_expect & 32)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
v_depth -= 1;
|
||||
v_stack_byte = ((v_depth - 1) / 32);
|
||||
v_stack_bit = ((v_depth - 1) & 31);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 20;
|
||||
v_expect_after_value = 20;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105378)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 36;
|
||||
v_expect_after_value = 36;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
v_match = 2;
|
||||
if (v_c == 110) {
|
||||
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||
465676103172);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(v_token_value))
|
||||
<< WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(((uint64_t)(v_number_length))))
|
||||
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_4_break;
|
||||
}
|
||||
while (v_number_length > 0) {
|
||||
v_number_length -= 1;
|
||||
if (iop_a_src > io1_a_src) {
|
||||
(iop_a_src--, wuffs_base__make_empty_struct());
|
||||
} else {
|
||||
(((uint64_t)(4194337)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||
goto label_4_break;
|
||||
}
|
||||
if (v_number_status == 1) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
} else if (v_number_status == 2) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_number_length);
|
||||
goto exit;
|
||||
} else {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
while (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
} else if (v_c == 102) {
|
||||
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||
111546413966853);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4194369)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(5)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 5) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 5, wuffs_base__make_empty_struct());
|
||||
goto label_4_break;
|
||||
}
|
||||
} else if (v_c == 116) {
|
||||
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||
435762131972);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4194433)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||
goto label_4_break;
|
||||
}
|
||||
}
|
||||
label_4_break:;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
} else if (v_c == 58) {
|
||||
if (0 == (v_expect & 8)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 1, wuffs_base__make_empty_struct());
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(0)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 3;
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 91) {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
goto exit;
|
||||
}
|
||||
v_stack_byte = (v_depth / 32);
|
||||
v_stack_bit = (v_depth & 31);
|
||||
self->private_data.f_stack[v_stack_byte] &=
|
||||
(4294967295 ^ (((uint32_t)(1)) << v_stack_bit));
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 19;
|
||||
v_expect_after_value = 20;
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 93) {
|
||||
if (0 == (v_expect & 16)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
v_depth -= 1;
|
||||
v_stack_byte = ((v_depth - 1) / 32);
|
||||
v_stack_bit = ((v_depth - 1) & 31);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 20;
|
||||
v_expect_after_value = 20;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105362)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 36;
|
||||
v_expect_after_value = 36;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 123) {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
if (v_depth >= 1024) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__unsupported_recursion_depth);
|
||||
goto exit;
|
||||
}
|
||||
v_stack_byte = (v_depth / 32);
|
||||
v_stack_bit = (v_depth & 31);
|
||||
self->private_data.f_stack[v_stack_byte] |=
|
||||
(((uint32_t)(1)) << v_stack_bit);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 34;
|
||||
v_expect_after_value = 36;
|
||||
goto label_0_continue;
|
||||
} else if (v_c == 125) {
|
||||
if (0 == (v_expect & 32)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
(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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
goto label_0_break;
|
||||
}
|
||||
v_depth -= 1;
|
||||
v_stack_byte = ((v_depth - 1) / 32);
|
||||
v_stack_bit = ((v_depth - 1) & 31);
|
||||
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)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 20;
|
||||
v_expect_after_value = 20;
|
||||
} else {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(2105378)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(1)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
v_expect = 36;
|
||||
v_expect_after_value = 36;
|
||||
}
|
||||
goto label_0_continue;
|
||||
} else {
|
||||
if (0 == (v_expect & 1)) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
v_match = 2;
|
||||
if (v_c == 110) {
|
||||
v_match =
|
||||
wuffs_base__io_reader__match7(iop_a_src, io2_a_src, 465676103172);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4194337)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||
}
|
||||
} else if (v_c == 102) {
|
||||
v_match = wuffs_base__io_reader__match7(iop_a_src, io2_a_src,
|
||||
111546413966853);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4194369)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(5)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 5) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 5, wuffs_base__make_empty_struct());
|
||||
}
|
||||
} else if (v_c == 116) {
|
||||
v_match =
|
||||
wuffs_base__io_reader__match7(iop_a_src, io2_a_src, 435762131972);
|
||||
if (v_match == 0) {
|
||||
*iop_a_dst++ = wuffs_base__make_token(
|
||||
(((uint64_t)(4194433)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
|
||||
(((uint64_t)(4)) << WUFFS_BASE__TOKEN__LENGTH__SHIFT));
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(
|
||||
wuffs_json__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
(iop_a_src += 4, wuffs_base__make_empty_struct());
|
||||
if (v_match == 1) {
|
||||
status =
|
||||
wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label_0_continue;
|
||||
}
|
||||
}
|
||||
if (v_match == 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label_0_continue;
|
||||
} else if (v_match == 2) {
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_json__error__bad_input);
|
||||
goto exit;
|
||||
}
|
||||
label_4_break:;
|
||||
if (v_depth == 0) {
|
||||
goto label_0_break;
|
||||
}
|
||||
|
||||
+360
-305
@@ -89,359 +89,414 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
|
||||
expect = 0x03 // EXPECT_VALUE
|
||||
|
||||
while.outer true {
|
||||
if args.dst.available() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.outer
|
||||
}
|
||||
|
||||
// Consume whitespace.
|
||||
whitespace_length = 0
|
||||
c = 0
|
||||
while.ws true,
|
||||
inv args.dst.available() > 0,
|
||||
post args.src.available() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
||||
whitespace_length = 0
|
||||
}
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
yield? base."$short read"
|
||||
whitespace_length = 0
|
||||
continue.outer
|
||||
}
|
||||
|
||||
c = args.src.peek_u8()
|
||||
if c > 0x20 { // 0x20 is ' '.
|
||||
break.ws
|
||||
} else if (c <> 0x20) and (c <> 0x0A) and (c <> 0x09) and (c <> 0x0D) {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
||||
}
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
if whitespace_length >= 0xFFFE {
|
||||
args.dst.write_fast_token!(value: 0, length: 0xFFFF)
|
||||
whitespace_length = 0
|
||||
continue.outer
|
||||
}
|
||||
whitespace_length += 1
|
||||
}
|
||||
|
||||
// Emit whitespace.
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(value: 0, length: whitespace_length as base.u64)
|
||||
whitespace_length = 0
|
||||
while.goto_parsed_a_leaf_value true {
|
||||
if args.dst.available() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.outer
|
||||
}
|
||||
}
|
||||
|
||||
// These assertions are redundant (the Wuffs compiler should already
|
||||
// know these facts; deleting these assertions should still compile)
|
||||
// but are listed explicitly to help guard against future edits to the
|
||||
// code above inadvertently invalidating these assertions.
|
||||
assert args.dst.available() > 0
|
||||
assert args.src.available() > 0
|
||||
|
||||
if c <= 0x39 { // 0x39 is '9'.
|
||||
if c == 0x22 { // 0x22 is '"'.
|
||||
// -------- BEGIN parse strings.
|
||||
if 0 == (expect & 0x02) { // 0x02 is EXPECT_STRING_VALUE.
|
||||
return "#bad input"
|
||||
// Consume whitespace.
|
||||
whitespace_length = 0
|
||||
c = 0
|
||||
while.ws true,
|
||||
inv args.dst.available() > 0,
|
||||
post args.src.available() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: whitespace_length as base.u64)
|
||||
whitespace_length = 0
|
||||
}
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
yield? base."$short read"
|
||||
whitespace_length = 0
|
||||
continue.outer
|
||||
}
|
||||
|
||||
// The leading '"' is filler.
|
||||
args.dst.write_fast_token!(value: 0, length: 1)
|
||||
c = args.src.peek_u8()
|
||||
if c > 0x20 { // 0x20 is ' '.
|
||||
break.ws
|
||||
} else if (c <> 0x20) and (c <> 0x0A) and (c <> 0x09) and (c <> 0x0D) {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: whitespace_length as base.u64)
|
||||
}
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
while.string_loop true {
|
||||
if args.dst.available() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.string_loop
|
||||
if whitespace_length >= 0xFFFE {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: 0xFFFF)
|
||||
whitespace_length = 0
|
||||
continue.outer
|
||||
}
|
||||
whitespace_length += 1
|
||||
}
|
||||
|
||||
// Emit whitespace.
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: whitespace_length as base.u64)
|
||||
whitespace_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
continue.outer
|
||||
}
|
||||
}
|
||||
|
||||
// These assertions are redundant (the Wuffs compiler should
|
||||
// already know these facts; deleting these assertions should still
|
||||
// compile) but are listed explicitly to guard against future edits
|
||||
// to the code above inadvertently invalidating these assertions.
|
||||
assert args.dst.available() > 0
|
||||
assert args.src.available() > 0
|
||||
|
||||
if c <= 0x39 { // 0x39 is '9'.
|
||||
if c == 0x22 { // 0x22 is '"'.
|
||||
// -------- BEGIN parse strings.
|
||||
if 0 == (expect & 0x02) { // 0x02 is EXPECT_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
|
||||
string_length = 0
|
||||
// The leading '"' is filler.
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: 1)
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
while.string_loop true {
|
||||
if args.dst.available() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.string_loop
|
||||
}
|
||||
|
||||
string_length = 0
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x60_0001,
|
||||
length: string_length as base.u64)
|
||||
string_length = 0
|
||||
}
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
yield? base."$short read"
|
||||
string_length = 0
|
||||
continue.string_loop
|
||||
}
|
||||
c = args.src.peek_u8()
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
if c <= 0x22 { // 0x22 is '"'.
|
||||
if c == 0x22 { // 0x22 is '"'.
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x60_0000,
|
||||
length: string_length as base.u64)
|
||||
string_length = 0
|
||||
break.string_loop
|
||||
|
||||
} else if c < 0x20 { // 0x20 is ' '.
|
||||
if string_length > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x60_0001,
|
||||
length: string_length as base.u64)
|
||||
string_length = 0
|
||||
}
|
||||
return "#bad input"
|
||||
}
|
||||
|
||||
} else if c == 0x5C { // 0x5C is '\\'.
|
||||
// TODO: escapes.
|
||||
return "#bad input"
|
||||
|
||||
}
|
||||
|
||||
if string_length >= 0xFFFE {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x60_0001,
|
||||
length: 0xFFFF)
|
||||
string_length = 0
|
||||
continue.string_loop
|
||||
}
|
||||
string_length += 1
|
||||
}
|
||||
}
|
||||
|
||||
// The trailing '"' is filler.
|
||||
while true {
|
||||
if args.dst.available() > 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: 1)
|
||||
break
|
||||
}
|
||||
yield? base."$short write"
|
||||
}
|
||||
|
||||
// As above, expect must have contained
|
||||
// EXPECT_STRING_VALUE. If it didn't also contain
|
||||
// EXPECT_NON_STRING_VALUE then we were parsing an object
|
||||
// key and the next token should be ':'.
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
expect = 0x08 // 0x08 is EXPECT_COLON.
|
||||
continue.outer
|
||||
}
|
||||
break.goto_parsed_a_leaf_value
|
||||
// -------- END parse strings.
|
||||
|
||||
} else if c == 0x2C { // 0x2C is ','.
|
||||
if 0 == (expect & 0x04) { // 0x01 is EXPECT_COMMA.
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
// The ',' is filler.
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: 1)
|
||||
// What's valid after a comma depends on whether or not
|
||||
// we're in an array or an object.
|
||||
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
||||
expect = 0x02 // 0x02 is EXPECT_STRING_VALUE.
|
||||
} else {
|
||||
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
||||
}
|
||||
continue.outer
|
||||
|
||||
} else if (c >= 0x30) or (c == 0x2D) { // 0x30 is '0', 0x2D is '-'.
|
||||
// -------- BEGIN parse numbers.
|
||||
if 0 == (expect & 0x01) { // 0x02 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_fast_token!(value: 0x60_0001, length: string_length as base.u64)
|
||||
string_length = 0
|
||||
}
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
yield? base."$short read"
|
||||
string_length = 0
|
||||
continue.string_loop
|
||||
number_length = this.decode_number!(src: args.src)
|
||||
number_status = number_length >> 8
|
||||
token_value = 0x40_0002
|
||||
if (number_length & 0x80) <> 0 {
|
||||
token_value = 0x40_0004
|
||||
}
|
||||
number_length = number_length & 0x7F
|
||||
if number_status == 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: token_value,
|
||||
length: number_length as base.u64)
|
||||
break
|
||||
}
|
||||
c = args.src.peek_u8()
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
if c <= 0x22 { // 0x22 is '"'.
|
||||
if c == 0x22 { // 0x22 is '"'.
|
||||
args.dst.write_fast_token!(value: 0x60_0000, length: string_length as base.u64)
|
||||
string_length = 0
|
||||
break.string_loop
|
||||
|
||||
} else if c < 0x20 { // 0x20 is ' '.
|
||||
if string_length > 0 {
|
||||
args.dst.write_fast_token!(value: 0x60_0001, length: string_length as base.u64)
|
||||
string_length = 0
|
||||
}
|
||||
return "#bad input"
|
||||
while number_length > 0 {
|
||||
number_length -= 1
|
||||
if args.src.can_undo_byte() {
|
||||
args.src.undo_byte!()
|
||||
} else {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
}
|
||||
|
||||
} else if c == 0x5C { // 0x5C is '\\'.
|
||||
// TODO: escapes.
|
||||
if number_status == 1 {
|
||||
return "#bad input"
|
||||
|
||||
} else if number_status == 2 {
|
||||
return "#unsupported number length"
|
||||
} else {
|
||||
yield? base."$short read"
|
||||
while args.dst.available() <= 0,
|
||||
post args.dst.available() > 0,
|
||||
{
|
||||
yield? base."$short write"
|
||||
}
|
||||
}
|
||||
|
||||
if string_length >= 0xFFFE {
|
||||
args.dst.write_fast_token!(value: 0x60_0001, length: 0xFFFF)
|
||||
string_length = 0
|
||||
continue.string_loop
|
||||
}
|
||||
string_length += 1
|
||||
}
|
||||
break.goto_parsed_a_leaf_value
|
||||
// -------- END parse numbers.
|
||||
}
|
||||
|
||||
// The trailing '"' is filler.
|
||||
while true {
|
||||
if args.dst.available() > 0 {
|
||||
args.dst.write_fast_token!(value: 0, length: 1)
|
||||
break
|
||||
}
|
||||
yield? base."$short write"
|
||||
}
|
||||
|
||||
// As above, expect must have contained EXPECT_STRING_VALUE. If
|
||||
// it didn't also contain EXPECT_NON_STRING_VALUE then we were
|
||||
// parsing an object key and the next token should be ':'.
|
||||
// Otherwise, fall below to "We've just parsed a value".
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
expect = 0x08 // 0x08 is EXPECT_COLON.
|
||||
continue.outer
|
||||
}
|
||||
// -------- END parse strings.
|
||||
|
||||
} else if c == 0x2C { // 0x2C is ','.
|
||||
if 0 == (expect & 0x04) { // 0x01 is EXPECT_COMMA.
|
||||
} else if c == 0x3A { // 0x3A is ':'.
|
||||
if 0 == (expect & 0x08) { // 0x08 is EXPECT_COLON.
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
args.dst.write_fast_token!(value: 0, length: 1) // The ',' is filler.
|
||||
// What's valid after a comma depends on whether or not we're
|
||||
// in an array or an object.
|
||||
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
||||
expect = 0x02 // 0x02 is EXPECT_STRING_VALUE.
|
||||
} else {
|
||||
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
||||
}
|
||||
// The ':' is filler.
|
||||
args.dst.write_fast_token!(
|
||||
value: 0,
|
||||
length: 1)
|
||||
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
||||
continue.outer
|
||||
|
||||
} else if (c >= 0x30) or (c == 0x2D) { // 0x30 is '0', 0x2D is '-'.
|
||||
// -------- BEGIN parse numbers.
|
||||
if 0 == (expect & 0x01) { // 0x02 is EXPECT_NON_STRING_VALUE.
|
||||
} else if c == 0x5B { // 0x5B is '['.
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
{
|
||||
number_length = this.decode_number!(src: args.src)
|
||||
number_status = number_length >> 8
|
||||
token_value = 0x40_0002
|
||||
if (number_length & 0x80) <> 0 {
|
||||
token_value = 0x40_0004
|
||||
}
|
||||
number_length = number_length & 0x7F
|
||||
if number_status == 0 {
|
||||
args.dst.write_fast_token!(value: token_value, length: number_length as base.u64)
|
||||
break
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
stack_byte = depth / 32
|
||||
stack_bit = depth & 31
|
||||
this.stack[stack_byte] &= 0xFFFF_FFFF ^ ((1 as base.u32) << stack_bit)
|
||||
depth += 1
|
||||
|
||||
while number_length > 0 {
|
||||
number_length -= 1
|
||||
if args.src.can_undo_byte() {
|
||||
args.src.undo_byte!()
|
||||
} else {
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
|
||||
} else if c == 0x5D { // 0x5D is ']'.
|
||||
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
}
|
||||
continue.outer
|
||||
|
||||
} else if c == 0x7B { // 0x7B is '{'.
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
stack_byte = depth / 32
|
||||
stack_bit = depth & 31
|
||||
this.stack[stack_byte] |= (1 as base.u32) << stack_bit
|
||||
depth += 1
|
||||
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
|
||||
} else if c == 0x7D { // 0x7D is '}'.
|
||||
if 0 == (expect & 0x20) { // 0x20 is EXPECT_CLOSE_BRACE.
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
}
|
||||
continue.outer
|
||||
|
||||
} else {
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
match = 2
|
||||
if c == 0x6E { // 0x6E is 'n'.
|
||||
match = args.src.match7(a: 0x6C_6C75_6E04) // 4 bytes "null".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x40_0021,
|
||||
length: 4)
|
||||
if args.src.available() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||
break.goto_parsed_a_leaf_value
|
||||
}
|
||||
|
||||
if number_status == 1 {
|
||||
return "#bad input"
|
||||
} else if number_status == 2 {
|
||||
return "#unsupported number length"
|
||||
} else {
|
||||
yield? base."$short read"
|
||||
while args.dst.available() <= 0,
|
||||
post args.dst.available() > 0,
|
||||
{
|
||||
yield? base."$short write"
|
||||
} else if c == 0x66 { // 0x66 is 'f'.
|
||||
match = args.src.match7(a: 0x6573_6C61_6605) // 5 bytes "false".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x40_0041,
|
||||
length: 5)
|
||||
if args.src.available() < 5 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 5, worst_case: 5)
|
||||
break.goto_parsed_a_leaf_value
|
||||
}
|
||||
}
|
||||
// -------- END parse numbers.
|
||||
|
||||
} else {
|
||||
return "#bad input"
|
||||
}
|
||||
|
||||
} else if c == 0x3A { // 0x3A is ':'.
|
||||
if 0 == (expect & 0x08) { // 0x08 is EXPECT_COLON.
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 1)
|
||||
args.dst.write_fast_token!(value: 0, length: 1) // The ':' is filler.
|
||||
expect = 0x03 // 0x03 is EXPECT_VALUE.
|
||||
continue.outer
|
||||
|
||||
} else if c == 0x5B { // 0x5B is '['.
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
stack_byte = depth / 32
|
||||
stack_bit = depth & 31
|
||||
this.stack[stack_byte] &= 0xFFFF_FFFF ^ ((1 as base.u32) << stack_bit)
|
||||
depth += 1
|
||||
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
|
||||
} else if c == 0x5D { // 0x5D is ']'.
|
||||
if 0 == (expect & 0x10) { // 0x10 is EXPECT_CLOSE_BRACKET
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
}
|
||||
continue.outer
|
||||
|
||||
} else if c == 0x7B { // 0x7B is '{'.
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
if depth >= 1024 {
|
||||
return "#unsupported recursion depth"
|
||||
}
|
||||
stack_byte = depth / 32
|
||||
stack_bit = depth & 31
|
||||
this.stack[stack_byte] |= (1 as base.u32) << stack_bit
|
||||
depth += 1
|
||||
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
|
||||
} else if c == 0x7D { // 0x7D is '}'.
|
||||
if 0 == (expect & 0x20) { // 0x20 is EXPECT_CLOSE_BRACE.
|
||||
return "#bad input"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 1, worst_case: 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
|
||||
}
|
||||
continue.outer
|
||||
|
||||
} else {
|
||||
if 0 == (expect & 0x01) { // 0x01 is EXPECT_NON_STRING_VALUE.
|
||||
return "#bad input"
|
||||
}
|
||||
match = 2
|
||||
if c == 0x6E { // 0x6E is 'n'.
|
||||
match = args.src.match7(a: 0x6C_6C75_6E04) // 4 bytes "null".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(value: 0x40_0021, length: 4)
|
||||
if args.src.available() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
} else if c == 0x74 { // 0x74 is 't'.
|
||||
match = args.src.match7(a: 0x65_7572_7404) // 4 bytes "true".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(
|
||||
value: 0x40_0081,
|
||||
length: 4)
|
||||
if args.src.available() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||
break.goto_parsed_a_leaf_value
|
||||
}
|
||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||
|
||||
}
|
||||
|
||||
} else if c == 0x66 { // 0x66 is 'f'.
|
||||
match = args.src.match7(a: 0x6573_6C61_6605) // 5 bytes "false".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(value: 0x40_0041, length: 5)
|
||||
if args.src.available() < 5 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 5, worst_case: 5)
|
||||
if match == 1 {
|
||||
yield? base."$short read"
|
||||
continue.outer
|
||||
}
|
||||
|
||||
} else if c == 0x74 { // 0x74 is 't'.
|
||||
match = args.src.match7(a: 0x65_7572_7404) // 4 bytes "true".
|
||||
if match == 0 {
|
||||
args.dst.write_fast_token!(value: 0x40_0081, length: 4)
|
||||
if args.src.available() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip32_fast!(actual: 4, worst_case: 4)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if match == 1 {
|
||||
yield? base."$short read"
|
||||
continue.outer
|
||||
} else if match == 2 {
|
||||
return "#bad input"
|
||||
}
|
||||
}
|
||||
return "#bad input"
|
||||
} // while.goto_parsed_a_leaf_value
|
||||
|
||||
// We've just parsed a value.
|
||||
// We've just parsed a leaf (non-container) value: literal (null,
|
||||
// false, true), number or string.
|
||||
if depth == 0 {
|
||||
break.outer
|
||||
}
|
||||
expect = expect_after_value
|
||||
}
|
||||
} // while.outer
|
||||
}
|
||||
|
||||
pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
|
||||
Reference in new issue
Block a user