diff --git a/cmd/wuffs-c/internal/cgen/cgen.go b/cmd/wuffs-c/internal/cgen/cgen.go index 74ad983d..fdf231c0 100644 --- a/cmd/wuffs-c/internal/cgen/cgen.go +++ b/cmd/wuffs-c/internal/cgen/cgen.go @@ -228,7 +228,7 @@ func (g *gen) genHeader(b *buffer) error { for i, z := range builtin.StatusList { code := uint32(0) - if z.Keyword == t.IDError { + if z.Keyword.Key() == t.KeyError { code |= 1 << 31 } code |= uint32(i) diff --git a/cmd/wuffs-c/internal/cgen/statement.go b/cmd/wuffs-c/internal/cgen/statement.go index 68bc8683..4bf0368d 100644 --- a/cmd/wuffs-c/internal/cgen/statement.go +++ b/cmd/wuffs-c/internal/cgen/statement.go @@ -219,8 +219,8 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error { b.printf("goto label_%d_%s;\n", jt, keyword) return nil - case a.KReturn: - n := n.Return() + case a.KRet: + n := n.Ret() retExpr := n.Value() if g.currFunk.suspendible { @@ -238,15 +238,20 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error { } b.writes(";") + if n.Keyword().Key() == t.KeyYield { + return g.writeCoroSuspPoint(b, true) + } + switch retKeyword { case t.KeyError: b.writes("goto exit;") - return nil case t.KeyStatus: b.writes("goto ok;") - return nil + default: + b.printf("if (status == 0) { goto ok; } else if (status > 0) { "+ + "status = %sERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;", g.PKGPREFIX) } - return g.writeCoroSuspPoint(b, true) + return nil } b.writes("return ") diff --git a/doc/changelog.md b/doc/changelog.md index ab8309f5..2cc8c546 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -3,14 +3,15 @@ ## Work In Progress -- Renamed Puffs to Wuffs +- Renamed Puffs to Wuffs. +- Added a `yield` keyword. ## 2017-11-16 - [Initial open source release](https://groups.google.com/d/topic/puffslang/2z61mNTAMns/discussion), - under the "Puffs" name + under the "Puffs" name. --- diff --git a/doc/wuffs-the-language.md b/doc/wuffs-the-language.md index 6446e40d..ea6a7702 100644 --- a/doc/wuffs-the-language.md +++ b/doc/wuffs-the-language.md @@ -27,7 +27,7 @@ be enclosed by curly `{}`s. There is no 'dangling else' ambiguity. - `pri` - `pub` -7 keywords deal with control flow within a function: +8 keywords deal with control flow within a function: - `break` - `continue` @@ -36,6 +36,7 @@ be enclosed by curly `{}`s. There is no 'dangling else' ambiguity. - `iterate` - `return` - `while` +- `yield` 5 keywords deal with assertions: diff --git a/gen/c/std/flate.c b/gen/c/std/flate.c index 54bca7a2..7d628e68 100644 --- a/gen/c/std/flate.c +++ b/gen/c/std/flate.c @@ -125,16 +125,17 @@ typedef int32_t wuffs_flate__status; #define wuffs_flate__packageid 967230 // 0x000ec23e -#define WUFFS_FLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_FLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_FLATE__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_FLATE__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define WUFFS_FLATE__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 -#define WUFFS_FLATE__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 -#define WUFFS_FLATE__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 -#define WUFFS_FLATE__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 -#define WUFFS_FLATE__SUSPENSION_SHORT_READ 8 // 0x00000008 -#define WUFFS_FLATE__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_FLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_FLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 +#define WUFFS_FLATE__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 +#define WUFFS_FLATE__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 +#define WUFFS_FLATE__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 +#define WUFFS_FLATE__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 +#define WUFFS_FLATE__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 +#define WUFFS_FLATE__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 +#define WUFFS_FLATE__SUSPENSION_SHORT_READ 8 // 0x00000008 +#define WUFFS_FLATE__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_FLATE__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483638 // 0x8000000a #define WUFFS_FLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ -1157040128 // 0xbb08f800 @@ -690,7 +691,7 @@ bool wuffs_flate__status__is_error(wuffs_flate__status s) { return s < 0; } -const char* wuffs_flate__status__strings0[10] = { +const char* wuffs_flate__status__strings0[11] = { "flate: ok", "flate: bad wuffs version", "flate: bad receiver", @@ -701,6 +702,7 @@ const char* wuffs_flate__status__strings0[10] = { "flate: unexpected EOF", "flate: short read", "flate: short write", + "flate: cannot return a suspension", }; const char* wuffs_flate__status__strings1[22] = { @@ -734,7 +736,7 @@ const char* wuffs_flate__status__string(wuffs_flate__status s) { switch ((s >> 10) & 0x1fffff) { case 0: a = wuffs_flate__status__strings0; - n = 10; + n = 11; break; case wuffs_flate__packageid: a = wuffs_flate__status__strings1; @@ -962,7 +964,12 @@ wuffs_flate__status wuffs_flate__flate_decoder__decode( } if (!(v_z > 0)) { status = v_z; - WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); + if (status == 0) { + goto ok; + } else if (status > 0) { + status = WUFFS_FLATE__ERROR_CANNOT_RETURN_A_SUSPENSION; + } + goto exit; } v_written = ((wuffs_base__slice_u8){ .ptr = a_dst.private_impl.mark, @@ -1003,7 +1010,7 @@ wuffs_flate__status wuffs_flate__flate_decoder__decode( } } status = v_z; - WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3); + WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); } goto ok; diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 1fc3eda8..337999ea 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -125,16 +125,17 @@ typedef int32_t wuffs_gif__status; #define wuffs_gif__packageid 1017222 // 0x000f8586 -#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 -#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 -#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 -#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 -#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 -#define WUFFS_GIF__SUSPENSION_SHORT_READ 8 // 0x00000008 -#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 +#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 +#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 +#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 +#define WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 +#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 +#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 +#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 +#define WUFFS_GIF__SUSPENSION_SHORT_READ 8 // 0x00000008 +#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483638 // 0x8000000a #define WUFFS_GIF__ERROR_BAD_GIF_BLOCK -1105848320 // 0xbe161800 #define WUFFS_GIF__ERROR_BAD_GIF_EXTENSION_LABEL -1105848319 // 0xbe161801 @@ -632,7 +633,7 @@ bool wuffs_gif__status__is_error(wuffs_gif__status s) { return s < 0; } -const char* wuffs_gif__status__strings0[10] = { +const char* wuffs_gif__status__strings0[11] = { "gif: ok", "gif: bad wuffs version", "gif: bad receiver", @@ -643,6 +644,7 @@ const char* wuffs_gif__status__strings0[10] = { "gif: unexpected EOF", "gif: short read", "gif: short write", + "gif: cannot return a suspension", }; const char* wuffs_gif__status__strings1[8] = { @@ -662,7 +664,7 @@ const char* wuffs_gif__status__string(wuffs_gif__status s) { switch ((s >> 10) & 0x1fffff) { case 0: a = wuffs_gif__status__strings0; - n = 10; + n = 11; break; case wuffs_gif__packageid: a = wuffs_gif__status__strings1; diff --git a/gen/h/std/flate.h b/gen/h/std/flate.h index cbfe39ab..96f79de7 100644 --- a/gen/h/std/flate.h +++ b/gen/h/std/flate.h @@ -125,16 +125,17 @@ typedef int32_t wuffs_flate__status; #define wuffs_flate__packageid 967230 // 0x000ec23e -#define WUFFS_FLATE__STATUS_OK 0 // 0x00000000 -#define WUFFS_FLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_FLATE__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_FLATE__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define WUFFS_FLATE__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 -#define WUFFS_FLATE__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 -#define WUFFS_FLATE__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 -#define WUFFS_FLATE__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 -#define WUFFS_FLATE__SUSPENSION_SHORT_READ 8 // 0x00000008 -#define WUFFS_FLATE__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_FLATE__STATUS_OK 0 // 0x00000000 +#define WUFFS_FLATE__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 +#define WUFFS_FLATE__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 +#define WUFFS_FLATE__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 +#define WUFFS_FLATE__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 +#define WUFFS_FLATE__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 +#define WUFFS_FLATE__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 +#define WUFFS_FLATE__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 +#define WUFFS_FLATE__SUSPENSION_SHORT_READ 8 // 0x00000008 +#define WUFFS_FLATE__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_FLATE__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483638 // 0x8000000a #define WUFFS_FLATE__ERROR_BAD_HUFFMAN_CODE_OVER_SUBSCRIBED \ -1157040128 // 0xbb08f800 diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index c40ea07b..0d3fd957 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -125,16 +125,17 @@ typedef int32_t wuffs_gif__status; #define wuffs_gif__packageid 1017222 // 0x000f8586 -#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 -#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 -#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 -#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 -#define WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 -#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 -#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 -#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 -#define WUFFS_GIF__SUSPENSION_SHORT_READ 8 // 0x00000008 -#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_GIF__STATUS_OK 0 // 0x00000000 +#define WUFFS_GIF__ERROR_BAD_WUFFS_VERSION -2147483647 // 0x80000001 +#define WUFFS_GIF__ERROR_BAD_RECEIVER -2147483646 // 0x80000002 +#define WUFFS_GIF__ERROR_BAD_ARGUMENT -2147483645 // 0x80000003 +#define WUFFS_GIF__ERROR_INITIALIZER_NOT_CALLED -2147483644 // 0x80000004 +#define WUFFS_GIF__ERROR_INVALID_I_O_OPERATION -2147483643 // 0x80000005 +#define WUFFS_GIF__ERROR_CLOSED_FOR_WRITES -2147483642 // 0x80000006 +#define WUFFS_GIF__ERROR_UNEXPECTED_EOF -2147483641 // 0x80000007 +#define WUFFS_GIF__SUSPENSION_SHORT_READ 8 // 0x00000008 +#define WUFFS_GIF__SUSPENSION_SHORT_WRITE 9 // 0x00000009 +#define WUFFS_GIF__ERROR_CANNOT_RETURN_A_SUSPENSION -2147483638 // 0x8000000a #define WUFFS_GIF__ERROR_BAD_GIF_BLOCK -1105848320 // 0xbe161800 #define WUFFS_GIF__ERROR_BAD_GIF_EXTENSION_LABEL -1105848319 // 0xbe161801 diff --git a/lang/ast/ast.go b/lang/ast/ast.go index e80a5a36..33d8ad8d 100644 --- a/lang/ast/ast.go +++ b/lang/ast/ast.go @@ -44,7 +44,7 @@ const ( KIterate KJump KPackageID - KReturn + KRet KStatus KStruct KTypeExpr @@ -75,7 +75,7 @@ var kindStrings = [...]string{ KIterate: "KIterate", KJump: "KJump", KPackageID: "KPackageID", - KReturn: "KReturn", + KRet: "KRet", KStatus: "KStatus", KStruct: "KStruct", KTypeExpr: "KTypeExpr", @@ -160,7 +160,7 @@ func (n *Node) Iterate() *Iterate { return (*Iterate)(n) } func (n *Node) Jump() *Jump { return (*Jump)(n) } func (n *Node) PackageID() *PackageID { return (*PackageID)(n) } func (n *Node) Raw() *Raw { return (*Raw)(n) } -func (n *Node) Return() *Return { return (*Return)(n) } +func (n *Node) Ret() *Ret { return (*Ret)(n) } func (n *Node) Status() *Status { return (*Status)(n) } func (n *Node) Struct() *Struct { return (*Struct)(n) } func (n *Node) TypeExpr() *TypeExpr { return (*TypeExpr)(n) } @@ -507,16 +507,19 @@ func NewIf(condition *Expr, elseIf *If, bodyIfTrue []*Node, bodyIfFalse []*Node) } } -// Return is "return LHS": +// Ret is "return LHS" or "yield LHS": +// - ID0: // - LHS: -type Return Node +type Ret Node -func (n *Return) Node() *Node { return (*Node)(n) } -func (n *Return) Value() *Expr { return n.lhs.Expr() } +func (n *Ret) Node() *Node { return (*Node)(n) } +func (n *Ret) Keyword() t.ID { return n.id0 } +func (n *Ret) Value() *Expr { return n.lhs.Expr() } -func NewReturn(value *Expr) *Return { - return &Return{ - kind: KReturn, +func NewRet(keyword t.ID, value *Expr) *Ret { + return &Ret{ + kind: KRet, + id0: keyword, lhs: value.Node(), } } @@ -663,7 +666,7 @@ const MaxBodyDepth = 255 // - If // - Iterate // - Jump -// - Return +// - Ret // - Var // - While type Func Node diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index be4602aa..69895ee9 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -36,6 +36,7 @@ func (z Status) String() string { } var StatusList = [...]Status{ + // TODO: sort these somehow, when the list has stabilized? {0, "ok"}, {t.IDError, "bad wuffs version"}, {t.IDError, "bad receiver"}, @@ -46,6 +47,7 @@ var StatusList = [...]Status{ {t.IDError, "unexpected EOF"}, // Used if reading when closed == true. {t.IDSuspension, "short read"}, // Used if reading when closed == false. {t.IDSuspension, "short write"}, + {t.IDError, "cannot return a suspension"}, } var StatusMap = map[string]Status{} diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 644674e4..94337e1f 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -218,12 +218,22 @@ func bcheckField(tm *t.Map, n *a.Field) error { } func (q *checker) bcheckBlock(block []*a.Node) error { +loop: for _, o := range block { if err := q.bcheckStatement(o); err != nil { return err } - if k := o.Kind(); k == a.KJump || k == a.KReturn { - break + switch o.Kind() { + case a.KJump: + break loop + case a.KRet: + if o.Ret().Keyword().Key() == t.KeyReturn { + break loop + } + // o is a yield statement. + // + // TODO: invalidate this-, in- and out-related facts because the + // suspension can change the state of this and its fields. } } return nil @@ -276,7 +286,7 @@ func (q *checker) bcheckStatement(n *a.Node) error { q.facts = q.facts[:0] return nil - case a.KReturn: + case a.KRet: // TODO. case a.KVar: @@ -475,8 +485,6 @@ func terminates(body []*a.Node) bool { if len(body) > 0 { n := body[len(body)-1] switch n.Kind() { - case a.KReturn, a.KJump: - return true case a.KIf: n := n.If() for { @@ -492,6 +500,10 @@ func terminates(body []*a.Node) bool { return len(bif) > 0 } } + case a.KJump: + return true + case a.KRet: + return n.Ret().Keyword().Key() == t.KeyReturn } return false } diff --git a/lang/check/type.go b/lang/check/type.go index 1e31eb0c..80422ac9 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -156,8 +156,8 @@ func (q *checker) tcheckStatement(n *a.Node) error { } n.SetJumpTarget(jumpTarget) - case a.KReturn: - n := n.Return() + case a.KRet: + n := n.Ret() if value := n.Value(); value != nil { if err := q.tcheckExpr(value, 0); err != nil { return err diff --git a/lang/parse/parse.go b/lang/parse/parse.go index fb5609e9..95155d2d 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -612,7 +612,7 @@ func (p *parser) parseStatement1() (*a.Node, error) { } return a.NewIterate(label, unroll, vars, asserts, body).Node(), nil - case t.KeyReturn: + case t.KeyReturn, t.KeyYield: p.src = p.src[1:] value, err := (*a.Expr)(nil), error(nil) if p.peek1().Key() != t.KeySemicolon { @@ -621,7 +621,7 @@ func (p *parser) parseStatement1() (*a.Node, error) { return nil, err } } - return a.NewReturn(value).Node(), nil + return a.NewRet(x, value).Node(), nil case t.KeyVar: p.src = p.src[1:] diff --git a/lang/token/list.go b/lang/token/list.go index 45bb5fa3..f1689c11 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -243,6 +243,7 @@ const ( KeyConst = Key(IDConst >> KeyShift) KeyTry = Key(IDTry >> KeyShift) KeyIterate = Key(IDIterate >> KeyShift) + KeyYield = Key(IDYield >> KeyShift) KeyFalse = Key(IDFalse >> KeyShift) KeyTrue = Key(IDTrue >> KeyShift) @@ -431,6 +432,7 @@ const ( IDConst = ID(0x66< 0 { @@ -231,7 +227,7 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() { hlen -= n_copied hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF // TODO: "closed for writes" instead? - return suspension "short write" + yield suspension "short write" } } @@ -249,7 +245,7 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() { } length -= n_copied // TODO: "closed for writes" instead? - return suspension "short write" + yield suspension "short write" } } diff --git a/std/flate/decode_zlib.wuffs b/std/flate/decode_zlib.wuffs index 771d4512..2f5369b7 100644 --- a/std/flate/decode_zlib.wuffs +++ b/std/flate/decode_zlib.wuffs @@ -54,7 +54,7 @@ pub func zlib_decoder.decode?(dst writer1, src reader1)() { if z.is_ok() { break } - return z + yield z } if checksum != in.src.read_u32be?() { return error "checksum mismatch" diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 62918757..0623e91b 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -182,7 +182,7 @@ pri func decoder.decode_id?(dst writer1, src reader1)() { if (block_size == 0) and (z == suspension "short read") { break } - return z + yield z } } } diff --git a/std/gif/decode_lzw.wuffs b/std/gif/decode_lzw.wuffs index 27c690bd..13a2fc41 100644 --- a/std/gif/decode_lzw.wuffs +++ b/std/gif/decode_lzw.wuffs @@ -118,7 +118,7 @@ pub func lzw_decoder.decode?(dst writer1, src reader1)() { } s = (s + ((n_copied & 4095) as u32)) & 4095 // TODO: "closed for writes" instead? - return suspension "short write" + yield suspension "short write" } if save_code <= 4095 {