MCPcopy
hub / github.com/expr-lang/expr / runVisitors

Method runVisitors

checker/checker.go:93–123  ·  view source on GitHub ↗

Run visitors in a given config over the given tree runRepeatable controls whether to filter for only vistors that require multiple passes or not

(tree *parser.Tree, runRepeatable bool)

Source from the content-addressed store, hash-verified

91// Run visitors in a given config over the given tree
92// runRepeatable controls whether to filter for only vistors that require multiple passes or not
93func (v *Checker) runVisitors(tree *parser.Tree, runRepeatable bool) {
94 for {
95 more := false
96 for _, visitor := range v.config.Visitors {
97 // We need to perform types check, because some visitors may rely on
98 // types information available in the tree.
99 _, _ = v.Check(tree, v.config)
100
101 r, repeatable := visitor.(interface {
102 Reset()
103 ShouldRepeat() bool
104 })
105
106 if repeatable {
107 if runRepeatable {
108 r.Reset()
109 ast.Walk(&tree.Node, visitor)
110 more = more || r.ShouldRepeat()
111 }
112 } else {
113 if !runRepeatable {
114 ast.Walk(&tree.Node, visitor)
115 }
116 }
117 }
118
119 if !more {
120 break
121 }
122 }
123}
124
125func (v *Checker) check(tree *parser.Tree) (reflect.Type, error) {
126 nt := v.visit(tree.Node)

Callers 1

PatchAndCheckMethod · 0.95

Implementers 3

Configconf/config.go
Checkerchecker/checker.go
OperatorOverloadingpatcher/operator_override.go

Calls 4

CheckMethod · 0.95
WalkFunction · 0.92
ShouldRepeatMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected