Pass context through operators

Allows more sophisticated functionality
This commit is contained in:
Mike Farah
2021-02-11 10:58:40 +11:00
parent 3bae44be68
commit c6efd5519b
40 changed files with 439 additions and 434 deletions
+18
View File
@@ -0,0 +1,18 @@
package yqlib
import "container/list"
type Context struct {
MatchingNodes *list.List
Variables map[string]*list.List
}
func (n *Context) SingleChildContext(candidate *CandidateNode) Context {
elMap := list.New()
elMap.PushBack(candidate)
return Context{MatchingNodes: elMap, Variables: n.Variables}
}
func (n *Context) ChildContext(results *list.List) Context {
return Context{MatchingNodes: results, Variables: n.Variables}
}