Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanCompileToTree ¶
CanCompileToTree determines if a match can benefit from decision tree compilation For now, simple heuristic: worth it if there are multiple literal/constructor patterns
Types ¶
type DecisionTree ¶
type DecisionTree interface {
String() string
// contains filtered or unexported methods
}
DecisionTree represents a compiled pattern matching decision tree This optimizes pattern matching by avoiding redundant tests
type DecisionTreeCompiler ¶
type DecisionTreeCompiler struct {
// contains filtered or unexported fields
}
DecisionTreeCompiler compiles match arms into a decision tree
func NewDecisionTreeCompiler ¶
func NewDecisionTreeCompiler(arms []core.MatchArm) *DecisionTreeCompiler
NewDecisionTreeCompiler creates a new compiler
func (*DecisionTreeCompiler) Compile ¶
func (c *DecisionTreeCompiler) Compile() DecisionTree
Compile builds a decision tree from match arms
type LeafNode ¶
type LeafNode struct {
ArmIndex int // Index of the original match arm
Body core.CoreExpr
Guard core.CoreExpr // Optional guard
}
LeafNode represents a match with a body to execute
type SwitchNode ¶
type SwitchNode struct {
Path []int // Path to the value being tested (e.g., [0, 1] = first field of second field)
Cases map[interface{}]DecisionTree // Map from constructor/literal to subtree
Default DecisionTree // Fallback for wildcard/variable patterns
}
SwitchNode represents a choice based on a discriminator
func (*SwitchNode) String ¶
func (s *SwitchNode) String() string
Click to show internal directories.
Click to hide internal directories.