mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 08:47:28 +01:00
Add some ast.Expr.IsEtc methods
This commit is contained in:
1 parent
b645180357
commit
41e407a774
7 files changed
+58
-48
No files matched your search
@@ -728,16 +728,16 @@ func (g *gen) writeBuiltinCPUArchX86(b *buffer, recv *a.Expr, method t.ID, args
|
||||
}
|
||||
|
||||
func (g *gen) writeExprDotPtr(b *buffer, n *a.Expr, sideEffectsOnly bool, depth uint32) error {
|
||||
if n.Operator() == t.IDDotDot {
|
||||
if err := g.writeExpr(b, n.LHS().AsExpr(), sideEffectsOnly, depth); err != nil {
|
||||
if arrayOrSlice, lo, _, ok := n.IsSlice(); ok {
|
||||
if err := g.writeExpr(b, arrayOrSlice, sideEffectsOnly, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
if n.LHS().AsExpr().MType().IsSliceType() {
|
||||
if arrayOrSlice.MType().IsSliceType() {
|
||||
b.writes(".ptr")
|
||||
}
|
||||
if n.MHS() != nil {
|
||||
if lo != nil {
|
||||
b.writes(" + ")
|
||||
if err := g.writeExpr(b, n.MHS().AsExpr(), sideEffectsOnly, depth); err != nil {
|
||||
if err := g.writeExpr(b, lo, sideEffectsOnly, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -969,13 +969,8 @@ func (g *gen) writeBuiltinSliceCopyFromSlice8(b *buffer, recv *a.Expr, method t.
|
||||
// matchFooIndexIndexPlus8 matches n with "foo[index .. index + 8]" or "foo[..
|
||||
// 8]". It returns a nil foo if there isn't a match.
|
||||
func matchFooIndexIndexPlus8(n *a.Expr) (foo *a.Expr, index *a.Expr) {
|
||||
if n.Operator() != t.IDDotDot {
|
||||
return nil, nil
|
||||
}
|
||||
foo = n.LHS().AsExpr()
|
||||
index = n.MHS().AsExpr()
|
||||
rhs := n.RHS().AsExpr()
|
||||
if rhs == nil {
|
||||
foo, index, rhs, ok := n.IsSlice()
|
||||
if !ok || (rhs == nil) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,9 +1035,9 @@ func (g *gen) writeConst(b *buffer, n *a.Const) error {
|
||||
}
|
||||
|
||||
func (g *gen) writeConstList(b *buffer, n *a.Expr) error {
|
||||
if n.Operator() == t.IDComma {
|
||||
if args, ok := n.IsList(); ok {
|
||||
b.writeb('{')
|
||||
for i, o := range n.Args() {
|
||||
for i, o := range args {
|
||||
if i&7 == 0 {
|
||||
b.writeb('\n')
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ func (g *gen) needDerivedVar(name t.ID) bool {
|
||||
switch p.Kind() {
|
||||
case a.KExpr:
|
||||
// Look for p matching "args.name.etc(etc)".
|
||||
recv, meth, args := p.AsExpr().IsMethodCall()
|
||||
if recv == nil {
|
||||
recv, meth, args, ok := p.AsExpr().IsMethodCall()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if recv.IsArgsDotFoo() == name {
|
||||
|
||||
Reference in new issue
Block a user