mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 17:01:35 +01:00
Have cgen look for !?? methods not ? methods
This commit is contained in:
1 parent
2100a9f837
commit
5cca9471ec
4 files changed
+10
-19
No files matched your search
@@ -669,8 +669,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
o := tld.AsFunc()
|
o := tld.AsFunc()
|
||||||
// XXX: s/Optional/Coroutine/
|
if o.Receiver() != n.QID() || !o.Effect().Coroutine() {
|
||||||
if o.Receiver() != n.QID() || !o.Effect().Optional() {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
k := g.funks[o.QQID()]
|
k := g.funks[o.QQID()]
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, rp replacementPolicy, depth uint32
|
|||||||
}
|
}
|
||||||
depth++
|
depth++
|
||||||
|
|
||||||
// XXX: s/Optional/Coroutine/
|
if rp == replaceCallSuspendibles && n.Effect().RootCause() && n.Effect().Coroutine() {
|
||||||
if rp == replaceCallSuspendibles && n.Effect().RootCause() && n.Effect().Optional() {
|
|
||||||
if g.currFunk.tempR >= g.currFunk.tempW {
|
if g.currFunk.tempR >= g.currFunk.tempW {
|
||||||
return fmt.Errorf("internal error: temporary variable count out of sync")
|
return fmt.Errorf("internal error: temporary variable count out of sync")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ func (g *gen) writeFuncSignature(b *buffer, n *a.Func, cpp uint32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: write n's return values.
|
// TODO: write n's return values.
|
||||||
// XXX: s/Optional/Coroutine/
|
if n.Effect().Coroutine() {
|
||||||
if n.Effect().Optional() {
|
|
||||||
b.writes("wuffs_base__status ")
|
b.writes("wuffs_base__status ")
|
||||||
} else if out := n.Out(); out == nil {
|
} else if out := n.Out(); out == nil {
|
||||||
// TODO: wuffs_base__empty_struct.
|
// TODO: wuffs_base__empty_struct.
|
||||||
@@ -175,7 +174,7 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
|
|||||||
astFunc: n,
|
astFunc: n,
|
||||||
cName: g.funcCName(n),
|
cName: g.funcCName(n),
|
||||||
public: n.Public(),
|
public: n.Public(),
|
||||||
suspendible: n.Effect().Optional(), // XXX: s/Optional/Coroutine/
|
suspendible: n.Effect().Coroutine(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := g.writeFuncImplHeader(&g.currFunk.bHeader); err != nil {
|
if err := g.writeFuncImplHeader(&g.currFunk.bHeader); err != nil {
|
||||||
|
|||||||
@@ -43,12 +43,10 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
|||||||
switch n.Kind() {
|
switch n.Kind() {
|
||||||
case a.KAssign:
|
case a.KAssign:
|
||||||
n := n.AsAssign()
|
n := n.AsAssign()
|
||||||
// XXX: s/Optional/Coroutine/
|
mightIntroduceTemporaries = n.LHS().Effect().Coroutine() || n.RHS().Effect().Coroutine()
|
||||||
mightIntroduceTemporaries = n.LHS().Effect().Optional() || n.RHS().Effect().Optional()
|
|
||||||
case a.KVar:
|
case a.KVar:
|
||||||
v := n.AsVar().Value()
|
v := n.AsVar().Value()
|
||||||
// XXX: s/Optional/Coroutine/
|
mightIntroduceTemporaries = v != nil && v.Effect().Coroutine()
|
||||||
mightIntroduceTemporaries = v != nil && v.Effect().Optional()
|
|
||||||
}
|
}
|
||||||
if mightIntroduceTemporaries {
|
if mightIntroduceTemporaries {
|
||||||
// Put n's code into its own block, to restrict the scope of the
|
// Put n's code into its own block, to restrict the scope of the
|
||||||
@@ -141,8 +139,7 @@ func (g *gen) writeStatementExpr(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
if err := g.writeSuspendibles(b, n, depth); err != nil {
|
if err := g.writeSuspendibles(b, n, depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// XXX: s/Optional/Coroutine/
|
if n.Effect().RootCause() && n.Effect().Coroutine() {
|
||||||
if n.Effect().RootCause() && n.Effect().Optional() {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := g.writeExpr(b, n, replaceCallSuspendibles, depth); err != nil {
|
if err := g.writeExpr(b, n, replaceCallSuspendibles, depth); err != nil {
|
||||||
@@ -222,8 +219,7 @@ func (g *gen) writeStatementIf(b *buffer, n *a.If, depth uint32) error {
|
|||||||
nCloseCurly := 1
|
nCloseCurly := 1
|
||||||
for first := true; ; first = false {
|
for first := true; ; first = false {
|
||||||
// TODO: restrict the if condition to effect-free expressions?
|
// TODO: restrict the if condition to effect-free expressions?
|
||||||
// XXX: s/Optional/Coroutine/
|
if n.Condition().Effect().Coroutine() {
|
||||||
if n.Condition().Effect().Optional() {
|
|
||||||
if !first {
|
if !first {
|
||||||
b.writeb('{')
|
b.writeb('{')
|
||||||
const maxCloseCurly = 1000
|
const maxCloseCurly = 1000
|
||||||
@@ -487,8 +483,7 @@ func (g *gen) writeCoroSuspPoint(b *buffer, maybeSuspend bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *gen) writeSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
func (g *gen) writeSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||||
// XXX: s/Optional/Coroutine/
|
if !n.Effect().Coroutine() {
|
||||||
if !n.Effect().Optional() {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if n.Operator() != t.IDTry {
|
if n.Operator() != t.IDTry {
|
||||||
@@ -507,8 +502,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
|
|
||||||
// The evaluation order for suspendible calls (which can have side effects)
|
// The evaluation order for suspendible calls (which can have side effects)
|
||||||
// is important here: LHS, MHS, RHS, Args and finally the node itself.
|
// is important here: LHS, MHS, RHS, Args and finally the node itself.
|
||||||
// XXX: s/Optional/Coroutine/
|
if e := n.Effect(); !e.RootCause() || !e.Coroutine() {
|
||||||
if e := n.Effect(); !e.RootCause() || !e.Optional() {
|
|
||||||
for _, o := range n.AsNode().AsRaw().SubNodes() {
|
for _, o := range n.AsNode().AsRaw().SubNodes() {
|
||||||
if o != nil && o.Kind() == a.KExpr {
|
if o != nil && o.Kind() == a.KExpr {
|
||||||
if err := g.writeCallSuspendibles(b, o.AsExpr(), depth); err != nil {
|
if err := g.writeCallSuspendibles(b, o.AsExpr(), depth); err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user