mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Add an implicit coroutine_resumed variable
This commit is contained in:
1 parent
89c136ebe4
commit
1af543866c
4 files changed
+19
-6
No files matched your search
@@ -59,6 +59,15 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
if ident := n.Ident(); ident == t.IDThis {
|
if ident := n.Ident(); ident == t.IDThis {
|
||||||
b.writes("self")
|
b.writes("self")
|
||||||
|
|
||||||
|
} else if ident == t.IDCoroutineResumed {
|
||||||
|
if g.currFunk.astFunc.Effect().Coroutine() {
|
||||||
|
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||||
|
b.printf("(self->private_impl.%s%s[0].coro_susp_point != 0)",
|
||||||
|
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||||
|
} else {
|
||||||
|
b.writes("false")
|
||||||
|
}
|
||||||
|
|
||||||
} else if ident.IsStrLiteral(g.tm) {
|
} else if ident.IsStrLiteral(g.tm) {
|
||||||
if z := g.statusMap[n.StatusQID()]; z.cName != "" {
|
if z := g.statusMap[n.StatusQID()]; z.cName != "" {
|
||||||
b.writes(z.cName)
|
b.writes(z.cName)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
- Dropped the `= RHS` out of `var x T = RHS`.
|
- Dropped the `= RHS` out of `var x T = RHS`.
|
||||||
- Changed func out-type from struct to bare type.
|
- Changed func out-type from struct to bare type.
|
||||||
- Renamed the implicit `in` variable to `args`.
|
- Renamed the implicit `in` variable to `args`.
|
||||||
|
- Added an implicit `coroutine_resumed` variable.
|
||||||
- Added `std/adler32`, `std/crc32` and `std/gzip`.
|
- Added `std/adler32`, `std/crc32` and `std/gzip`.
|
||||||
- Spun `std/lzw` out of `std/gif`.
|
- Spun `std/lzw` out of `std/gif`.
|
||||||
- Spun `std/zlib` out of `std/flate`.
|
- Spun `std/zlib` out of `std/flate`.
|
||||||
|
|||||||
+2
-1
@@ -484,7 +484,8 @@ func (c *Checker) checkFuncSignature(node *a.Node) error {
|
|||||||
inTyp.AsNode().SetMType(typeExprTypeExpr)
|
inTyp.AsNode().SetMType(typeExprTypeExpr)
|
||||||
|
|
||||||
localVars := typeMap{
|
localVars := typeMap{
|
||||||
t.IDArgs: inTyp,
|
t.IDArgs: inTyp,
|
||||||
|
t.IDCoroutineResumed: typeExprBool,
|
||||||
}
|
}
|
||||||
if qqid[1] != 0 {
|
if qqid[1] != 0 {
|
||||||
if _, ok := c.structs[t.QID{qqid[0], qqid[1]}]; !ok {
|
if _, ok := c.structs[t.QID{qqid[0], qqid[1]}]; !ok {
|
||||||
|
|||||||
+7
-5
@@ -400,7 +400,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
minBuiltInIdent = 0x100
|
minBuiltInIdent = 0x100
|
||||||
minCannotAssignTo = 0x100
|
minCannotAssignTo = 0x100
|
||||||
maxCannotAssignTo = 0x101
|
maxCannotAssignTo = 0x102
|
||||||
minNumTypeOrIdeal = 0x10F
|
minNumTypeOrIdeal = 0x10F
|
||||||
minNumType = 0x110
|
minNumType = 0x110
|
||||||
maxNumType = 0x117
|
maxNumType = 0x117
|
||||||
@@ -409,8 +409,9 @@ const (
|
|||||||
|
|
||||||
// -------- 0x100 block.
|
// -------- 0x100 block.
|
||||||
|
|
||||||
IDArgs = ID(0x100)
|
IDArgs = ID(0x100)
|
||||||
IDThis = ID(0x101)
|
IDCoroutineResumed = ID(0x101)
|
||||||
|
IDThis = ID(0x102)
|
||||||
|
|
||||||
IDT1 = ID(0x108)
|
IDT1 = ID(0x108)
|
||||||
IDT2 = ID(0x109)
|
IDT2 = ID(0x109)
|
||||||
@@ -717,8 +718,9 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
|
|
||||||
// -------- 0x100 block.
|
// -------- 0x100 block.
|
||||||
|
|
||||||
IDArgs: "args",
|
IDArgs: "args",
|
||||||
IDThis: "this",
|
IDCoroutineResumed: "coroutine_resumed",
|
||||||
|
IDThis: "this",
|
||||||
|
|
||||||
// Some of the next few IDs are never returned by the tokenizer, as it
|
// Some of the next few IDs are never returned by the tokenizer, as it
|
||||||
// rejects non-ASCII input. The string representations "¶", "ℤ" etc. are
|
// rejects non-ASCII input. The string representations "¶", "ℤ" etc. are
|
||||||
|
|||||||
Reference in new issue
Block a user