Drop the "?" from "copy_from32?".

Also add a PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND macro.

Also add a loop to decoder.decode, as the code generator was previously
(incorrectly) not generating a coro_susp_point at the end of the
function.
This commit is contained in:
Nigel Tao committed 2017-10-07 14:34:31 +11:00
1 parent 0e09aa8c10
commit 585ea2024d
10 files changed
+218 -134

No files matched your search

+30 -1
View File
@@ -15,7 +15,15 @@
// so that clang-format doesn't get confused by the unusual "case"s.
#define PUFFS_COROUTINE_SUSPENSION_POINT(n) \
coro_susp_point = n; \
case n:
case n:;
#define PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \
if (status <= 0) { \
goto exit; \
} \
coro_susp_point = n; \
goto suspend; \
case n:;
// Clang also defines "__GNUC__".
#if defined(__GNUC__)
@@ -132,6 +140,27 @@ static inline uint64_t puffs_base_slice_u8_copy_from(puffs_base_slice_u8 dst,
return n;
}
static inline uint32_t puffs_base_writer1_copy_from32(uint8_t** ptr_wptr,
uint8_t* wend,
uint8_t** ptr_rptr,
uint8_t* rend,
uint32_t length) {
uint8_t* wptr = *ptr_wptr;
if (length > (wend - wptr)) {
length = wend - wptr;
}
uint8_t* rptr = *ptr_rptr;
if (length > (rend - rptr)) {
length = rend - rptr;
}
if (length > 0) {
memmove(wptr, rptr, length);
*ptr_wptr += length;
*ptr_rptr += length;
}
return length;
}
static inline uint32_t puffs_base_writer1_copy_history32(uint8_t** ptr_ptr,
uint8_t* start,
uint8_t* end,
+4 -5
View File
@@ -126,7 +126,7 @@ const maxTemp = 10000
type status struct {
name string
msg string
isError bool
keyword t.ID
}
type buffer []byte
@@ -230,7 +230,7 @@ func (g *gen) genHeader(b *buffer) error {
}
for i, s := range g.statusList {
code := pkgID << statusCodeNamespaceShift
if s.isError {
if s.keyword.Key() == t.KeyError {
code |= 1 << 31
}
code |= uint32(i)
@@ -445,14 +445,13 @@ func (g *gen) gatherStatuses(b *buffer, n *a.Status) error {
return fmt.Errorf("bad status message %q", raw)
}
prefix := "SUSPENSION_"
isError := n.Keyword().Key() == t.KeyError
if isError {
if n.Keyword().Key() == t.KeyError {
prefix = "ERROR_"
}
s := status{
name: strings.ToUpper(g.cName(prefix + msg)),
msg: msg,
isError: isError,
keyword: n.Keyword(),
}
g.statusList = append(g.statusList, s)
g.statusMap[n.Message()] = s
+7 -6
View File
@@ -12,12 +12,13 @@ const baseHeader = "" +
""
const baseImpl = "" +
"#ifndef PUFFS_BASE_IMPL_H\n#define PUFFS_BASE_IMPL_H\n\n// Use of this source code is governed by a BSD-style license that can be found\n// in the LICENSE file.\n\n#define PUFFS_IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use a trivial macro instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define PUFFS_COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n case n:\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define PUFFS_LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define PUFFS_UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n// Declare the printf prototype. The generated code shouldn't need this at all,\n// but it's useful for manual printf debugging.\nextern int printf(const char* __restrict __format, ...);\n#else\n#define PUFFS_LIKELY(expr) (expr)\n#de" +
"fine PUFFS_UNLIKELY(expr) (expr)\n#endif\n\n// ---------------- Static Inline Functions\n//\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are in base-impl.h and hence copy/pasted into every generated C file,\n// instead of being in some \"base.c\" file, since a design goal is that users of\n// the generated C code can often just #include a single .c file, such as\n// \"gif.c\", without having to additionally include or otherwise build and link\n// a \"base.c\" file.\n//\n// They are static, so that linking multiple puffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline uint16_t puffs_base_load_u16be(uint8_t* p) {\n return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1" +
"]) << 0);\n}\n\nstatic inline uint16_t puffs_base_load_u16le(uint8_t* p) {\n return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);\n}\n\nstatic inline uint32_t puffs_base_load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t puffs_base_load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_subslice_i(\n puffs_base_slice_u8 s,\n uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.len)) {\n return ((puffs_base_slice_u8){\n .ptr = s.ptr + i,\n .len = s.len - i,\n });\n }\n return ((puffs_base_slice_u8){});\n}\n\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_subslice_j(\n puffs_base_slice_u8 s,\n uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return ((puffs_base_slice_u8){.ptr = s.ptr, .len = j});\n }\n return ((pu" +
"ffs_base_slice_u8){});\n}\n\nstatic inline puffs_base_slice_u8\npuffs_base_slice_u8_subslice_ij(puffs_base_slice_u8 s, uint64_t i, uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return ((puffs_base_slice_u8){\n .ptr = s.ptr + i,\n .len = j - i,\n });\n }\n return ((puffs_base_slice_u8){});\n}\n\n// puffs_base_slice_u8_prefix returns up to the first n bytes of s.\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_prefix(\n puffs_base_slice_u8 s,\n uint64_t n) {\n if ((uint64_t)(s.len) > n) {\n s.len = n;\n }\n return s;\n}\n\n// puffs_base_slice_u8_suffix returns up to the last n bytes of s.\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_suffix(\n puffs_base_slice_u8 s,\n uint64_t n) {\n if ((uint64_t)(s.len) > n) {\n s.ptr += (uint64_t)(s.len) - n;\n s.len = n;\n }\n return s;\n}\n\n// puffs_base_slice_u8_copy_from calls memmove(dst.ptr, src.ptr, n) where n is\n// the minimum of dst.len and src.len.\n//\n// Passing a puffs_base_slice_u8 with all fields NULL or zer" +
"o (a valid, empty\n// slice) is valid and results in a no-op.\nstatic inline uint64_t puffs_base_slice_u8_copy_from(puffs_base_slice_u8 dst,\n puffs_base_slice_u8 src) {\n size_t n = dst.len < src.len ? dst.len : src.len;\n if (n > 0) {\n memmove(dst.ptr, src.ptr, n);\n }\n return n;\n}\n\nstatic inline uint32_t puffs_base_writer1_copy_history32(uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t distance,\n uint32_t length) {\n uint8_t* ptr = *ptr_ptr;\n size_t d = ptr - start;\n if ((d == 0) || (d < (size_t)(distance))) {\n return 0;\n }\n start = ptr - distance;\n size_t l = end - ptr;\n if ((size_t)(length) > l) {\n length = l;\n } else {\n l = length;\n }\n // TODO: is manual unrolling actually helpful?\n for (; l >= 8; l -" +
"= 8) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; l; l--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\n#endif // PUFFS_BASE_IMPL_H\n" +
"#ifndef PUFFS_BASE_IMPL_H\n#define PUFFS_BASE_IMPL_H\n\n// Use of this source code is governed by a BSD-style license that can be found\n// in the LICENSE file.\n\n#define PUFFS_IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// We use a trivial macro instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define PUFFS_COROUTINE_SUSPENSION_POINT(n) \\\n coro_susp_point = n; \\\n case n:;\n\n#define PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (status <= 0) { \\\n goto exit; \\\n } \\\n coro_susp_point = n; \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__" +
"\".\n#if defined(__GNUC__)\n#define PUFFS_LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define PUFFS_UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n// Declare the printf prototype. The generated code shouldn't need this at all,\n// but it's useful for manual printf debugging.\nextern int printf(const char* __restrict __format, ...);\n#else\n#define PUFFS_LIKELY(expr) (expr)\n#define PUFFS_UNLIKELY(expr) (expr)\n#endif\n\n// ---------------- Static Inline Functions\n//\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are in base-impl.h and hence copy/pasted into every generated C file,\n// instead of being in some \"base.c\" file, since a design goal is that users of\n// the generated C code can often just #include a single .c file, such as\n// \"gif.c\", without having to additionally include or otherwise build and link\n// a \"base.c\" file.\n//\n// They are static, so that linking multiple puffs .o files won't complain about" +
"\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline uint16_t puffs_base_load_u16be(uint8_t* p) {\n return ((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0);\n}\n\nstatic inline uint16_t puffs_base_load_u16le(uint8_t* p) {\n return ((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8);\n}\n\nstatic inline uint32_t puffs_base_load_u32be(uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t puffs_base_load_u32le(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_subslice_i(\n puffs_base_slice_u8 s,\n uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.le" +
"n)) {\n return ((puffs_base_slice_u8){\n .ptr = s.ptr + i,\n .len = s.len - i,\n });\n }\n return ((puffs_base_slice_u8){});\n}\n\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_subslice_j(\n puffs_base_slice_u8 s,\n uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return ((puffs_base_slice_u8){.ptr = s.ptr, .len = j});\n }\n return ((puffs_base_slice_u8){});\n}\n\nstatic inline puffs_base_slice_u8\npuffs_base_slice_u8_subslice_ij(puffs_base_slice_u8 s, uint64_t i, uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return ((puffs_base_slice_u8){\n .ptr = s.ptr + i,\n .len = j - i,\n });\n }\n return ((puffs_base_slice_u8){});\n}\n\n// puffs_base_slice_u8_prefix returns up to the first n bytes of s.\nstatic inline puffs_base_slice_u8 puffs_base_slice_u8_prefix(\n puffs_base_slice_u8 s,\n uint64_t n) {\n if ((uint64_t)(s.len) > n) {\n s.len = n;\n }\n return s;\n}\n\n// puffs_base_slice_u8_suffix returns up to the last n bytes of s.\nstatic inline pu" +
"ffs_base_slice_u8 puffs_base_slice_u8_suffix(\n puffs_base_slice_u8 s,\n uint64_t n) {\n if ((uint64_t)(s.len) > n) {\n s.ptr += (uint64_t)(s.len) - n;\n s.len = n;\n }\n return s;\n}\n\n// puffs_base_slice_u8_copy_from calls memmove(dst.ptr, src.ptr, n) where n is\n// the minimum of dst.len and src.len.\n//\n// Passing a puffs_base_slice_u8 with all fields NULL or zero (a valid, empty\n// slice) is valid and results in a no-op.\nstatic inline uint64_t puffs_base_slice_u8_copy_from(puffs_base_slice_u8 dst,\n puffs_base_slice_u8 src) {\n size_t n = dst.len < src.len ? dst.len : src.len;\n if (n > 0) {\n memmove(dst.ptr, src.ptr, n);\n }\n return n;\n}\n\nstatic inline uint32_t puffs_base_writer1_copy_from32(uint8_t** ptr_wptr,\n uint8_t* wend,\n uint8_t** ptr_rptr,\n uint8_t* rend,\n " +
" uint32_t length) {\n uint8_t* wptr = *ptr_wptr;\n if (length > (wend - wptr)) {\n length = wend - wptr;\n }\n uint8_t* rptr = *ptr_rptr;\n if (length > (rend - rptr)) {\n length = rend - rptr;\n }\n if (length > 0) {\n memmove(wptr, rptr, length);\n *ptr_wptr += length;\n *ptr_rptr += length;\n }\n return length;\n}\n\nstatic inline uint32_t puffs_base_writer1_copy_history32(uint8_t** ptr_ptr,\n uint8_t* start,\n uint8_t* end,\n uint32_t distance,\n uint32_t length) {\n uint8_t* ptr = *ptr_ptr;\n size_t d = ptr - start;\n if ((d == 0) || (d < (size_t)(distance))) {\n return 0;\n }\n start = ptr - distance;\n size_t l = end - ptr;\n if ((size_t)(length) > l) {\n length = l;\n } else {\n l = length;\n }\n // TODO: is manual unrolling actually helpful?\n f" +
"or (; l >= 8; l -= 8) {\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n *ptr++ = *start++;\n }\n for (; l; l--) {\n *ptr++ = *start++;\n }\n *ptr_ptr = ptr;\n return length;\n}\n\n#endif // PUFFS_BASE_IMPL_H\n" +
""
type template_args_short_read struct {
+20 -2
View File
@@ -148,6 +148,17 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
b.writes(")")
return nil
}
if isInDst(g.tm, n, t.KeyCopyFrom32, 2) {
b.printf("puffs_base_writer1_copy_from32(&%swptr_dst, %swend_dst", bPrefix, bPrefix)
// TODO: don't assume that the first argument is "in.src".
b.printf(", &%srptr_src, %srend_src,", bPrefix, bPrefix)
a := n.Args()[1].Arg().Value()
if err := g.writeExpr(b, a, rp, parenthesesOptional, depth); err != nil {
return err
}
b.writeb(')')
return nil
}
if isInDst(g.tm, n, t.KeyCopyHistory32, 2) {
b.printf("puffs_base_writer1_copy_history32(&%swptr_dst, %swstart_dst, %swend_dst",
bPrefix, bPrefix, bPrefix)
@@ -304,8 +315,15 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
}
func (g *gen) writeExprUnaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
// TODO.
return nil
switch n.ID0().Key() {
case t.KeyXUnaryPlus:
b.writeb('+')
case t.KeyXUnaryMinus:
b.writeb('-')
case t.KeyXUnaryNot:
b.writeb('!')
}
return g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth)
}
func (g *gen) writeExprBinaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
+29 -62
View File
@@ -132,10 +132,12 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
return fmt.Errorf("no status code for %q", msg)
}
ret.name = strings.ToUpper(g.cName(z.String()))
ret.keyword = z.Keyword
}
} else if retExpr = n.Value(); retExpr == nil {
ret.name = g.PKGPREFIX + "STATUS_OK"
}
if g.currFunk.suspendible {
b.writes("status = ")
if retExpr == nil {
@@ -146,17 +148,23 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
return err
}
b.writes(";")
if ret.isError {
b.writes("goto exit;")
} else {
b.writes("goto suspend;")
if retExpr == nil {
switch ret.keyword.Key() {
case 0:
// TODO: set csp=0, then goto ok.
// Also update the PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND macro.
b.writes("goto suspend;")
return nil
case t.KeyError:
b.writes("goto exit;")
return nil
case t.KeySuspension:
// No-op.
}
}
} else {
// TODO: consider the return values, especially if they involve
// suspendible function calls.
b.writes("return;\n")
return g.writeCoroSuspPoint(b, true)
}
return nil
return fmt.Errorf("TODO: return statements in non-suspendible functions")
case a.KVar:
n := n.Var()
@@ -239,14 +247,18 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
return fmt.Errorf("unrecognized ast.Kind (%s) for writeStatement", n.Kind())
}
func (g *gen) writeCoroSuspPoint(b *buffer) error {
func (g *gen) writeCoroSuspPoint(b *buffer, maybeSuspend bool) error {
const maxCoroSuspPoint = 0xFFFFFFFF
g.currFunk.coroSuspPoint++
if g.currFunk.coroSuspPoint == maxCoroSuspPoint {
return fmt.Errorf("too many coroutine suspension points required")
}
b.printf("PUFFS_COROUTINE_SUSPENSION_POINT(%d);\n", g.currFunk.coroSuspPoint)
macro := ""
if maybeSuspend {
macro = "_MAYBE_SUSPEND"
}
b.printf("PUFFS_COROUTINE_SUSPENSION_POINT%s(%d);\n", macro, g.currFunk.coroSuspPoint)
return nil
}
@@ -254,7 +266,7 @@ func (g *gen) writeSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
if !n.Suspendible() {
return nil
}
if err := g.writeCoroSuspPoint(b); err != nil {
if err := g.writeCoroSuspPoint(b, false); err != nil {
return err
}
return g.writeCallSuspendibles(b, n, depth)
@@ -335,7 +347,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
b.writes(";\n")
// TODO: the CSP prior to this is probably unnecessary.
if err := g.writeCoroSuspPoint(b); err != nil {
if err := g.writeCoroSuspPoint(b, false); err != nil {
return err
}
@@ -381,53 +393,6 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
}
b.writes(";\n")
} else if isInDst(g.tm, n, t.KeyCopyFrom32, 2) {
if g.currFunk.tempW > maxTemp {
return fmt.Errorf("too many temporary variables required")
}
temp := g.currFunk.tempW
g.currFunk.tempW++
g.currFunk.tempR++
b.writes("{\n")
g.currFunk.usesScratch = true
// TODO: don't hard-code [0], and allow recursive coroutines.
scratchName := fmt.Sprintf("self->private_impl.%s%s[0].scratch",
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
b.printf("%s = ", scratchName)
x := n.Args()[1].Arg().Value()
if err := g.writeExpr(b, x, replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
return err
}
b.writes(";\n")
if err := g.writeCoroSuspPoint(b); err != nil {
return err
}
b.printf("size_t %s%d = %s;\n", tPrefix, temp, scratchName)
const wName = "dst"
b.printf("if (%s%d > %swend_%s - %swptr_%s) {\n", tPrefix, temp, bPrefix, wName, bPrefix, wName)
b.printf("%s%d = %swend_%s - %swptr_%s;\n", tPrefix, temp, bPrefix, wName, bPrefix, wName)
b.printf("status = %sSUSPENSION_SHORT_WRITE;\n", g.PKGPREFIX)
b.writes("}\n")
// TODO: don't assume that the first argument is "in.src".
const rName = "src"
b.printf("if (%s%d > %srend_%s - %srptr_%s) {\n", tPrefix, temp, bPrefix, rName, bPrefix, rName)
b.printf("%s%d = %srend_%s - %srptr_%s;\n", tPrefix, temp, bPrefix, rName, bPrefix, rName)
b.printf("status = %sSUSPENSION_SHORT_READ;\n", g.PKGPREFIX)
b.writes("}\n")
b.printf("memmove(%swptr_%s, %srptr_%s, %s%d);\n", bPrefix, wName, bPrefix, rName, tPrefix, temp)
b.printf("%swptr_%s += %s%d;\n", bPrefix, wName, tPrefix, temp)
b.printf("%srptr_%s += %s%d;\n", bPrefix, rName, tPrefix, temp)
b.printf("if (status) { %s -= %s%d; goto suspend; }\n", scratchName, tPrefix, temp)
b.writes("}\n")
} else if isThisMethod(g.tm, n, "decode_header", 1) {
b.printf("status = %s%s_decode_header(self, %ssrc);\n",
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix)
@@ -586,7 +551,7 @@ func (g *gen) writeReadUXX(b *buffer, n *a.Expr, name string, size uint32, endia
b.printf("%srptr_src += %d;\n", bPrefix, size/8)
b.printf("} else {")
b.printf("%s = 0;\n", scratchName)
if err := g.writeCoroSuspPoint(b); err != nil {
if err := g.writeCoroSuspPoint(b, false); err != nil {
return err
}
b.printf("while (true) {")
@@ -650,7 +615,9 @@ func isInSrc(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
}
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
callSuspendible := methodName != t.KeyCopyHistory32 && methodName != t.KeySlice
callSuspendible := methodName != t.KeyCopyFrom32 &&
methodName != t.KeyCopyHistory32 &&
methodName != t.KeySlice
// TODO: check that n.Args() is "(x:bar)".
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
return false