diff options
Diffstat (limited to 'pkg/ast')
| -rw-r--r-- | pkg/ast/filter.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/ast/filter.go b/pkg/ast/filter.go new file mode 100644 index 000000000..a36114e82 --- /dev/null +++ b/pkg/ast/filter.go @@ -0,0 +1,14 @@ +// Copyright 2018 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package ast + +func (desc *Description) Filter(predicate func(Node) bool) *Description { + desc1 := &Description{} + for _, n := range desc.Nodes { + if predicate(n) { + desc1.Nodes = append(desc1.Nodes, n.Clone()) + } + } + return desc1 +} |
