MCPcopy Create free account
hub / github.com/decomp/decomp / walkBeforeAfter

Function walkBeforeAfter

cmd/go-post/fix.go:57–283  ·  view source on GitHub ↗

walkBeforeAfter is like walk but calls before(x) before traversing x's children and after(x) afterward.

(x interface{}, before, after func(interface{}))

Source from the content-addressed store, hash-verified

55// walkBeforeAfter is like walk but calls before(x) before traversing
56// x's children and after(x) afterward.
57func walkBeforeAfter(x interface{}, before, after func(interface{})) {
58 before(x)
59
60 switch n := x.(type) {
61 default:
62 panic(fmt.Errorf("unexpected type %T in walkBeforeAfter", x))
63
64 case nil:
65
66 // pointers to interfaces
67 case *ast.Decl:
68 walkBeforeAfter(*n, before, after)
69 case *ast.Expr:
70 walkBeforeAfter(*n, before, after)
71 case *ast.Spec:
72 walkBeforeAfter(*n, before, after)
73 case *ast.Stmt:
74 walkBeforeAfter(*n, before, after)
75
76 // pointers to struct pointers
77 case **ast.BlockStmt:
78 walkBeforeAfter(*n, before, after)
79 case **ast.CallExpr:
80 walkBeforeAfter(*n, before, after)
81 case **ast.FieldList:
82 walkBeforeAfter(*n, before, after)
83 case **ast.FuncType:
84 walkBeforeAfter(*n, before, after)
85 case **ast.Ident:
86 walkBeforeAfter(*n, before, after)
87 case **ast.BasicLit:
88 walkBeforeAfter(*n, before, after)
89
90 // pointers to slices
91 case *[]ast.Decl:
92 walkBeforeAfter(*n, before, after)
93 case *[]ast.Expr:
94 walkBeforeAfter(*n, before, after)
95 case *[]*ast.File:
96 walkBeforeAfter(*n, before, after)
97 case *[]*ast.Ident:
98 walkBeforeAfter(*n, before, after)
99 case *[]ast.Spec:
100 walkBeforeAfter(*n, before, after)
101 case *[]ast.Stmt:
102 walkBeforeAfter(*n, before, after)
103
104 // These are ordered and grouped to match ../../go/ast/ast.go
105 case *ast.Field:
106 walkBeforeAfter(&n.Names, before, after)
107 walkBeforeAfter(&n.Type, before, after)
108 walkBeforeAfter(&n.Tag, before, after)
109 case *ast.FieldList:
110 for _, field := range n.List {
111 walkBeforeAfter(field, before, after)
112 }
113 case *ast.BadExpr:
114 case *ast.Ident:

Callers 2

typecheck1Function · 0.85
walkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected