Make the status type a struct, not an int32_t

This commit is contained in:
Nigel Tao committed 2018-08-11 13:27:29 +10:00
1 parent 9c0b2d2f5c
commit 2a32a86a6c
26 files changed
+791 -668

No files matched your search

+5 -5
View File
@@ -309,7 +309,7 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
b.writes("status = ")
retKeyword := t.IDStatus
if retExpr == nil {
b.writes("WUFFS_BASE__STATUS_OK")
b.writes("WUFFS_BASE__MAKE_STATUS(WUFFS_BASE__STATUS_OK)")
} else {
retKeyword = retExpr.Operator()
// TODO: check that retExpr has no call-suspendibles.
@@ -332,8 +332,8 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
b.writes("goto ok;")
default:
g.currFunk.hasGotoOK = true
b.writes("if (status == 0) { goto ok; } else if (status > 0) { " +
"status = WUFFS_BASE__ERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;")
b.writes("if (status.code == 0) { goto ok; } else if (status.code > 0) { " +
"status = WUFFS_BASE__MAKE_STATUS(WUFFS_BASE__ERROR_CANNOT_RETURN_A_SUSPENSION); } goto exit;")
}
return nil
}
@@ -528,7 +528,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
}
if n.Operator() != t.IDTry {
b.writes("if (status) { goto suspend; }\n")
b.writes("if (status.code) { goto suspend; }\n")
}
return nil
}
@@ -571,7 +571,7 @@ func (g *gen) writeReadUXX(b *buffer, n *a.Expr, preName string, size uint32, en
b.printf("while (true) {")
b.printf("if (WUFFS_BASE__UNLIKELY(iop_%s == io1_%s)) {"+
"status = WUFFS_BASE__SUSPENSION_SHORT_READ; goto suspend; }",
"status = WUFFS_BASE__MAKE_STATUS(WUFFS_BASE__SUSPENSION_SHORT_READ); goto suspend; }",
preName, preName)
b.printf("uint64_t *scratch = &%s;", scratchName)