treecoll

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERIALIZED_TREE_NODE_PATTERN_VALUE_KEY = "value"
)

Variables

View Source
var (
	TREE_PATTERN = &core.TypePattern{
		Type:          reflect.TypeOf(&Tree{}),
		Name:          "tree",
		SymbolicValue: &coll_symbolic.Tree{},
	}
	TREE_NODE_PATTERN = &core.TypePattern{
		Type:          reflect.TypeOf(TreeNode{}),
		Name:          "tree.node",
		SymbolicValue: &coll_symbolic.TreeNode{},
		CallImpl: func(typePattern *core.TypePattern, values []core.Serializable) (core.Pattern, error) {
			var valuePattern core.Pattern

			for _, val := range values {
				switch v := val.(type) {
				case core.Pattern:
					if valuePattern != nil {
						return nil, commonfmt.FmtErrArgumentProvidedAtLeastTwice("value pattern")
					}

					valuePattern = v
				default:
					if valuePattern == nil {
						valuePattern = core.NewExactValuePattern(v)
						continue
					}
					return nil, core.FmtErrInvalidArgument(v)
				}
			}

			return &TreeNodePattern{
				valuePattern: valuePattern,
			}, nil
		},
		SymbolicCallImpl: func(ctx *symbolic.Context, values []symbolic.Value) (symbolic.Pattern, error) {
			return coll_symbolic.NewTreeNodePattern(symbolic.ANY_PATTERN)
		},
	}
	TREE_NODE_PATTERN_PATTERN = &core.TypePattern{
		Type:          reflect.TypeOf(&TreeNodePattern{}),
		Name:          "tree.node-pattern",
		SymbolicValue: coll_symbolic.ANY_TREE_NODE_PATTERN,
	}
)

Functions

func DeserializeTreeNodePattern

func DeserializeTreeNodePattern(ctx *core.Context, it *jsoniter.Iterator, pattern core.Pattern, try bool) (_ core.Pattern, finalErr error)

Types

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree(ctx *core.Context, treedata *core.Treedata, args ...core.Value) *Tree

func (*Tree) Equal

func (t *Tree) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*Tree) GetGoMethod

func (t *Tree) GetGoMethod(name string) (*core.GoFunction, bool)

func (*Tree) IsMutable

func (t *Tree) IsMutable() bool

func (*Tree) IsSharable

func (t *Tree) IsSharable(originState *core.GlobalState) (bool, string)

func (*Tree) IsShared

func (t *Tree) IsShared() bool

func (*Tree) Iterator

func (t *Tree) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator

func (*Tree) PrettyPrint

func (t *Tree) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*Tree) Prop

func (t *Tree) Prop(ctx *core.Context, name string) core.Value

func (*Tree) PropertyNames

func (*Tree) PropertyNames(ctx *core.Context) []string

func (*Tree) SetProp

func (*Tree) SetProp(ctx *core.Context, name string, value core.Value) error

func (*Tree) Share

func (t *Tree) Share(originState *core.GlobalState)

func (*Tree) SmartLock

func (t *Tree) SmartLock(state *core.GlobalState)

func (*Tree) SmartUnlock

func (t *Tree) SmartUnlock(state *core.GlobalState)

func (*Tree) ToSymbolicValue

func (t *Tree) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

type TreeIterator

type TreeIterator struct {
	// contains filtered or unexported fields
}

func (*TreeIterator) Equal

func (it *TreeIterator) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (TreeIterator) HasNext

func (it TreeIterator) HasNext(ctx *core.Context) bool

func (*TreeIterator) IsMutable

func (it *TreeIterator) IsMutable() bool

func (*TreeIterator) Iterator

func (it *TreeIterator) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator

func (*TreeIterator) Key

func (it *TreeIterator) Key(ctx *core.Context) core.Value

func (*TreeIterator) Next

func (it *TreeIterator) Next(ctx *core.Context) bool

func (*TreeIterator) PrettyPrint

func (it *TreeIterator) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*TreeIterator) ToSymbolicValue

func (it *TreeIterator) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

func (*TreeIterator) Value

func (it *TreeIterator) Value(ctx *core.Context) core.Value

type TreeNode

type TreeNode struct {
	// contains filtered or unexported fields
}

TODO: store tree nodes in a pool

func (*TreeNode) AddChild

func (n *TreeNode) AddChild(ctx *core.Context, childData core.Value)

func (*TreeNode) Equal

func (n *TreeNode) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*TreeNode) GetGoMethod

func (n *TreeNode) GetGoMethod(name string) (*core.GoFunction, bool)

func (TreeNode) IsMutable

func (n TreeNode) IsMutable() bool

func (*TreeNode) IsSharable

func (n *TreeNode) IsSharable(originState *core.GlobalState) (bool, string)

func (*TreeNode) IsShared

func (n *TreeNode) IsShared() bool

func (*TreeNode) Iterator

func (node *TreeNode) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator

func (TreeNode) PrettyPrint

func (n TreeNode) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*TreeNode) Prop

func (n *TreeNode) Prop(ctx *core.Context, name string) core.Value

func (*TreeNode) PropertyNames

func (*TreeNode) PropertyNames(ctx *core.Context) []string

func (*TreeNode) SetProp

func (*TreeNode) SetProp(ctx *core.Context, name string, value core.Value) error

func (*TreeNode) Share

func (n *TreeNode) Share(originState *core.GlobalState)

func (*TreeNode) SmartLock

func (n *TreeNode) SmartLock(state *core.GlobalState)

func (*TreeNode) SmartUnlock

func (n *TreeNode) SmartUnlock(state *core.GlobalState)

func (*TreeNode) ToSymbolicValue

func (n *TreeNode) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

type TreeNodePattern

type TreeNodePattern struct {
	core.NotCallablePatternMixin
	// contains filtered or unexported fields
}

func NewTreeNodePattern

func NewTreeNodePattern(valuePattern core.Pattern) *TreeNodePattern

func (*TreeNodePattern) Equal

func (p *TreeNodePattern) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*TreeNodePattern) IsMutable

func (p *TreeNodePattern) IsMutable() bool

func (*TreeNodePattern) Iterator

func (patt *TreeNodePattern) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator

func (*TreeNodePattern) PrettyPrint

func (n *TreeNodePattern) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*TreeNodePattern) Random

func (patt *TreeNodePattern) Random(ctx *core.Context, options ...core.Option) core.Value

func (*TreeNodePattern) StringPattern

func (patt *TreeNodePattern) StringPattern() (core.StringPattern, bool)

func (*TreeNodePattern) Test

func (patt *TreeNodePattern) Test(ctx *core.Context, v core.Value) bool

func (*TreeNodePattern) ToSymbolicValue

func (p *TreeNodePattern) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

func (*TreeNodePattern) WriteJSONRepresentation

func (p *TreeNodePattern) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL