InitState produces a CostTracker and bundles it into an Activation in a way which is not visible to expression evaluation.
(frame *ExecutionFrame)
| 70 | // InitState produces a CostTracker and bundles it into an Activation in a way which is not visible |
| 71 | // to expression evaluation. |
| 72 | func (ct *costTrackerFactory) InitState(frame *ExecutionFrame) (any, error) { |
| 73 | if frame.ctx != nil && frame.ctx.costs != nil { |
| 74 | return frame.ctx.costs, nil |
| 75 | } |
| 76 | tracker, err := ct.factory() |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | if frame.ctx == nil { |
| 81 | frame.ctx = evalContextPool.Get().(*evalContext) |
| 82 | } |
| 83 | frame.ctx.costs = tracker |
| 84 | return tracker, nil |
| 85 | } |
| 86 | |
| 87 | // GetState extracts the CostTracker from the Activation. |
| 88 | func (ct *costTrackerFactory) GetState(frame *ExecutionFrame) any { |