Add wuffs_base__make_status

This commit is contained in:
Nigel Tao committed 2020-01-02 20:44:23 +11:00
1 parent 7d4a3a127d
commit fb54ba452f
11 files changed
+530 -383

No files matched your search

+5 -1
View File
@@ -30,8 +30,10 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, depth uint32) error {
if cv := n.ConstValue(); cv != nil {
if typ := n.MType(); typ.IsNumTypeOrIdeal() {
b.writes(cv.String())
} else if typ.IsNullptr() || typ.IsStatus() {
} else if typ.IsNullptr() {
b.writes("NULL")
} else if typ.IsStatus() {
b.writes("wuffs_base__make_status(NULL)")
} else if cv.Cmp(zero) == 0 {
b.writes("false")
} else if cv.Cmp(one) == 0 {
@@ -70,7 +72,9 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
} else if ident.IsStrLiteral(g.tm) {
if z := g.statusMap[n.StatusQID()]; z.cName != "" {
b.writes("wuffs_base__make_status(")
b.writes(z.cName)
b.writes(")")
} else {
return fmt.Errorf("unrecognized status %s", n.StatusQID().Str(g.tm))
}