type ActualCostEstimator … // CostObserver provides an observer that tracks runtime cost. func CostObserver(tracker *CostTracker) EvalObserver { … } type CostTrackerOption … // CostTrackerLimit sets the runtime limit on the evaluation cost during execution and will terminate the expression // evaluation if the limit is exceeded. func CostTrackerLimit(limit uint64) CostTrackerOption { … } // PresenceTestHasCost determines whether presence testing has a cost of one or zero. // Defaults to presence test has a cost of one. func PresenceTestHasCost(hasCost bool) CostTrackerOption { … } // NewCostTracker creates a new CostTracker with a given estimator and a set of functional CostTrackerOption values. func NewCostTracker(estimator ActualCostEstimator, opts ...CostTrackerOption) (*CostTracker, error) { … } // OverloadCostTracker binds an overload ID to a runtime FunctionTracker implementation. // // OverloadCostTracker instances augment or override ActualCostEstimator decisions, allowing for versioned and/or // optional cost tracking changes. func OverloadCostTracker(overloadID string, fnTracker FunctionTracker) CostTrackerOption { … } type FunctionTracker … type CostTracker … // ActualCost returns the runtime cost func (c *CostTracker) ActualCost() uint64 { … } func (c *CostTracker) costCall(call InterpretableCall, args []ref.Val, result ref.Val) uint64 { … } // actualSize returns the size of value func (c *CostTracker) actualSize(value ref.Val) uint64 { … } type stackVal … type refValStack … func (s *refValStack) push(val ref.Val, id int64) { … } // drop searches the stack for each ID and removes the ID and all stack items above it. // If none of the IDs are found, the stack is not modified. // WARNING: It is possible for multiple expressions with the same ID to exist (due to how macros are implemented) so it's // possible that a dropped ID will remain on the stack. They should be removed when IDs on the stack are popped. func (s *refValStack) drop(ids ...int64) { … } // dropArgs searches the stack for all the args by their IDs, accumulates their associated ref.Vals and drops any // stack items above any of the arg IDs. If any of the IDs are not found the stack, false is returned. // Args are assumed to be found in the stack in reverse order, i.e. the last arg is expected to be found highest in // the stack. // WARNING: It is possible for multiple expressions with the same ID to exist (due to how macros are implemented) so it's // possible that a dropped ID will remain on the stack. They should be removed when IDs on the stack are popped. func (s *refValStack) dropArgs(args []Interpretable) ([]ref.Val, bool) { … }