Have cgen look for !?? methods not ? methods

This commit is contained in:
Nigel Tao committed 2018-07-29 14:01:57 +10:00
1 parent 2100a9f837
commit 5cca9471ec
4 files changed
+10 -19

No files matched your search

+1 -2
View File
@@ -669,8 +669,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
continue
}
o := tld.AsFunc()
// XXX: s/Optional/Coroutine/
if o.Receiver() != n.QID() || !o.Effect().Optional() {
if o.Receiver() != n.QID() || !o.Effect().Coroutine() {
continue
}
k := g.funks[o.QQID()]
+1 -2
View File
@@ -30,8 +30,7 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, rp replacementPolicy, depth uint32
}
depth++
// XXX: s/Optional/Coroutine/
if rp == replaceCallSuspendibles && n.Effect().RootCause() && n.Effect().Optional() {
if rp == replaceCallSuspendibles && n.Effect().RootCause() && n.Effect().Coroutine() {
if g.currFunk.tempR >= g.currFunk.tempW {
return fmt.Errorf("internal error: temporary variable count out of sync")
}
+2 -3
View File
@@ -86,8 +86,7 @@ func (g *gen) writeFuncSignature(b *buffer, n *a.Func, cpp uint32) error {
}
// TODO: write n's return values.
// XXX: s/Optional/Coroutine/
if n.Effect().Optional() {
if n.Effect().Coroutine() {
b.writes("wuffs_base__status ")
} else if out := n.Out(); out == nil {
// TODO: wuffs_base__empty_struct.
@@ -175,7 +174,7 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
astFunc: n,
cName: g.funcCName(n),
public: n.Public(),
suspendible: n.Effect().Optional(), // XXX: s/Optional/Coroutine/
suspendible: n.Effect().Coroutine(),
}
if err := g.writeFuncImplHeader(&g.currFunk.bHeader); err != nil {
+6 -12
View File
@@ -43,12 +43,10 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
switch n.Kind() {
case a.KAssign:
n := n.AsAssign()
// XXX: s/Optional/Coroutine/
mightIntroduceTemporaries = n.LHS().Effect().Optional() || n.RHS().Effect().Optional()
mightIntroduceTemporaries = n.LHS().Effect().Coroutine() || n.RHS().Effect().Coroutine()
case a.KVar:
v := n.AsVar().Value()
// XXX: s/Optional/Coroutine/
mightIntroduceTemporaries = v != nil && v.Effect().Optional()
mightIntroduceTemporaries = v != nil && v.Effect().Coroutine()
}
if mightIntroduceTemporaries {
// 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 {
return err
}
// XXX: s/Optional/Coroutine/
if n.Effect().RootCause() && n.Effect().Optional() {
if n.Effect().RootCause() && n.Effect().Coroutine() {
return 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
for first := true; ; first = false {
// TODO: restrict the if condition to effect-free expressions?
// XXX: s/Optional/Coroutine/
if n.Condition().Effect().Optional() {
if n.Condition().Effect().Coroutine() {
if !first {
b.writeb('{')
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 {
// XXX: s/Optional/Coroutine/
if !n.Effect().Optional() {
if !n.Effect().Coroutine() {
return nil
}
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)
// is important here: LHS, MHS, RHS, Args and finally the node itself.
// XXX: s/Optional/Coroutine/
if e := n.Effect(); !e.RootCause() || !e.Optional() {
if e := n.Effect(); !e.RootCause() || !e.Coroutine() {
for _, o := range n.AsNode().AsRaw().SubNodes() {
if o != nil && o.Kind() == a.KExpr {
if err := g.writeCallSuspendibles(b, o.AsExpr(), depth); err != nil {