EvalActivation runs an InterpretableV2 Exec method safely with any Activation, wrapping it in a pooled ExecutionFrame if needed and releasing it after execution.
(ctx Activation, exec func(*ExecutionFrame) ref.Val)
| 207 | // EvalActivation runs an InterpretableV2 Exec method safely with any Activation, |
| 208 | // wrapping it in a pooled ExecutionFrame if needed and releasing it after execution. |
| 209 | func EvalActivation(ctx Activation, exec func(*ExecutionFrame) ref.Val) ref.Val { |
| 210 | if f, ok := ctx.(*ExecutionFrame); ok { |
| 211 | return exec(f) |
| 212 | } |
| 213 | f, err := NewExecutionFrame(ctx) |
| 214 | if err != nil { |
| 215 | return types.NewErr("invalid activation: %v", err) |
| 216 | } |
| 217 | res := exec(f) |
| 218 | f.Close() |
| 219 | return res |
| 220 | } |
| 221 | |
| 222 | // findFrame walks the activation hierarchy via Unwrap and Parent to locate an |
| 223 | // existing ExecutionFrame, if one exists. |