Documentation ¶
Index ¶
- func ContainsNode(root ast.Node, pred func(ast.Node) bool) bool
- func CouldBeMutated(info *types.Info, body ast.Node, dst ast.Expr) bool
- func FindNode(root ast.Node, followFunc, pred func(ast.Node) bool) ast.Node
- func IsImmutable(info *types.Info, n ast.Expr) bool
- func IsZeroValue(info *types.Info, x ast.Expr) bool
- func ZeroValueOf(typeExpr ast.Expr, typ types.Type) ast.Expr
- type AstSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsNode ¶
ContainsNode reports whether `FindNode(root, pred)!=nil`.
func CouldBeMutated ¶
CouldBeMutated reports whether dst can be modified inside body.
Note that it does not take already existing pointers to dst. An example of safe and correct usage is checking of something that was just defined, so the dst is a result of that definition.
func FindNode ¶
FindNode applies pred for root and all it's childs until it returns true. If followFunc is defined, it's called before following any node to check whether it needs to be followed. followFunc has to return true in order to continuing traversing the node and return false otherwise. Matched node is returned. If none of the nodes matched predicate, nil is returned.
func IsImmutable ¶
IsImmutable reports whether n can be modified through any operation.
func IsZeroValue ¶ added in v0.4.0
IsZeroValue reports whether x represents zero value of its type.
The functions is conservative and may return false for zero values if some cases are not handled in a comprehensive way but is should never return true for something that's not a proper zv.
Types ¶
type AstSet ¶
type AstSet struct {
// contains filtered or unexported fields
}
AstSet is a simple ast.Node set. Zero value is ready to use set. Can be reused after Clear call.