Save derived vars for returns in non-coroutines

This commit is contained in:
Nigel Tao committed 2020-02-19 14:31:42 +11:00
1 parent 0aacdfd6e3
commit 6a7a4d08e3
3 files changed
+29 -23

No files matched your search

+9
View File
@@ -471,6 +471,15 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
return nil
}
if g.currFunk.derivedVars != nil {
for _, o := range g.currFunk.astFunc.In().Fields() {
o := o.AsField()
if err := g.writeSaveDerivedVar(b, "", aPrefix, o.Name(), o.XType()); err != nil {
return err
}
}
}
b.writes("return ")
if g.currFunk.astFunc.Out() == nil {
b.writes("wuffs_base__make_empty_struct()")
+16 -12
View File
@@ -18137,8 +18137,6 @@ const char* wuffs_json__error__unsupported_number_length =
"#json: unsupported number length";
const char* wuffs_json__error__unsupported_recursion_depth =
"#json: unsupported recursion depth";
const char* wuffs_json__error__internal_error_inconsistent_i_o =
"#json: internal error: inconsistent I/O";
// ---------------- Private Consts
@@ -18464,16 +18462,6 @@ wuffs_json__decoder__decode_tokens(wuffs_json__decoder* self,
(((uint64_t)(4194306)) << WUFFS_BASE__TOKEN__VALUE__SHIFT) |
(((uint64_t)(((uint64_t)(v_number_length))))
<< WUFFS_BASE__TOKEN__LENGTH__SHIFT));
while (v_number_length > 0) {
v_number_length -= 1;
if (((uint64_t)(io2_a_src - iop_a_src)) > 0) {
(iop_a_src += 1, wuffs_base__make_empty_struct());
} else {
status = wuffs_base__make_status(
wuffs_json__error__internal_error_inconsistent_i_o);
goto exit;
}
}
goto label_4_break;
} else if (v_number_length < 1) {
status = wuffs_base__make_status(
@@ -18679,21 +18667,37 @@ wuffs_json__decoder__decode_number(wuffs_json__decoder* self,
while (true) {
if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
if (a_src && a_src->meta.closed) {
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
return (v_n + 1);
}
goto label_0_break;
}
v_c = wuffs_base__load_u8be(iop_a_src);
if ((v_c < 48) || (57 < v_c)) {
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
return (v_n + 1);
}
if (v_n >= 49) {
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
return 0;
}
v_n += 1;
(iop_a_src += 1, wuffs_base__make_empty_struct());
}
label_0_break:;
while ((v_n > 0) && (iop_a_src > io1_a_src)) {
v_n -= 1;
(iop_a_src--, wuffs_base__make_empty_struct());
}
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
}
return 1;
if (a_src) {
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
+4 -11
View File
@@ -18,8 +18,6 @@ pub status "#bad input"
pub status "#unsupported number length"
pub status "#unsupported recursion depth"
pri status "#internal error: inconsistent I/O"
pub struct decoder?(
)(
// stack is conceptually an array of bits, implemented as an array of u32.
@@ -254,14 +252,6 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader) {
if number_length > 1 {
number_length -= 1
args.dst.write_fast_token!(value: 0x40_0002, length: number_length as base.u64)
while number_length > 0 {
number_length -= 1
if args.src.available() > 0 {
args.src.skip32_fast!(actual: 1, worst_case: 1)
} else {
return "#internal error: inconsistent I/O"
}
}
break
} else if number_length < 1 {
return "#unsupported number length"
@@ -416,6 +406,9 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 50] {
args.src.skip32_fast!(actual: 1, worst_case: 1)
}
// TODO: explicitly undo arg.src reads.
while (n > 0) and args.src.can_undo_byte() {
n -= 1
args.src.undo_byte!()
}
return 1
}