mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Drop the "= RHS" out of "var x T = RHS"
This commit is contained in:
1 parent
cbe19f50e0
commit
6dc68950c0
7 files changed
+20
-68
No files matched your search
@@ -420,12 +420,6 @@ func (h *resumabilityHelper) doRet(r resumabilities, n *a.Ret, depth uint32) err
|
||||
}
|
||||
|
||||
func (h *resumabilityHelper) doVar(r resumabilities, n *a.Var, depth uint32) error {
|
||||
if n.Value() != nil {
|
||||
if err := h.doExpr(r, n.Value()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
name := n.Name()
|
||||
if i, ok := h.vars[name]; !ok {
|
||||
return fmt.Errorf("unrecognized variable %q", name.Str(h.tm))
|
||||
|
||||
@@ -43,10 +43,9 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
switch n.Kind() {
|
||||
case a.KAssign:
|
||||
n := n.AsAssign()
|
||||
mightIntroduceTemporaries = n.LHS().Effect().Coroutine() || n.RHS().Effect().Coroutine()
|
||||
case a.KVar:
|
||||
v := n.AsVar().Value()
|
||||
mightIntroduceTemporaries = v != nil && v.Effect().Coroutine()
|
||||
mightIntroduceTemporaries = n.RHS().Effect().Coroutine()
|
||||
case a.KExpr:
|
||||
// TODO.
|
||||
}
|
||||
if mightIntroduceTemporaries {
|
||||
// Put n's code into its own block, to restrict the scope of the
|
||||
@@ -86,11 +85,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
return g.writeStatementRet(b, n.AsRet(), depth)
|
||||
case a.KVar:
|
||||
n := n.AsVar()
|
||||
op := n.Operator()
|
||||
if n.Value() == nil {
|
||||
op = t.IDEq
|
||||
}
|
||||
return g.writeStatementAssign(b, n.Name(), nil, n.XType(), op, n.Value(), depth)
|
||||
return g.writeStatementAssign(b, n.Name(), nil, n.XType(), t.IDEq, nil, depth)
|
||||
case a.KWhile:
|
||||
return g.writeStatementWhile(b, n.AsWhile(), depth)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user