NewExecutionFrame creates a new execution frame from the pool.
(input any)
| 133 | |
| 134 | // NewExecutionFrame creates a new execution frame from the pool. |
| 135 | func NewExecutionFrame(input any) (*ExecutionFrame, error) { |
| 136 | f := frameStack.Get().(*ExecutionFrame) |
| 137 | switch v := input.(type) { |
| 138 | case emptyActivation: |
| 139 | // empty frame, no backing scope needed |
| 140 | case Activation: |
| 141 | f.scope = v |
| 142 | fns, err := FindFunctionActivation(f.scope) |
| 143 | if err != nil { |
| 144 | frameStack.Put(f) |
| 145 | return nil, err |
| 146 | } |
| 147 | f.functions = fns |
| 148 | case map[string]any: |
| 149 | f.vars = v |
| 150 | default: |
| 151 | frameStack.Put(f) |
| 152 | return nil, fmt.Errorf("invalid input, wanted Activation or map[string]any, got: (%T)%v", input, input) |
| 153 | } |
| 154 | return f, nil |
| 155 | } |
| 156 | |
| 157 | // SetContext sets the context for the execution frame. |
| 158 | func (f *ExecutionFrame) SetContext(ctx context.Context, interruptCheckFrequency uint) error { |