AsFrame promotes an Activation to an ExecutionFrame.
(a Activation)
| 197 | |
| 198 | // AsFrame promotes an Activation to an ExecutionFrame. |
| 199 | func AsFrame(a Activation) *ExecutionFrame { |
| 200 | if f, ok := a.(*ExecutionFrame); ok { |
| 201 | return f |
| 202 | } |
| 203 | frame := &ExecutionFrame{Activation: a} |
| 204 | // Walk the activation hierarchy to find a parent ExecutionFrame and inherit |
| 205 | // its shared context. |
| 206 | if parent := findFrame(a); parent != nil { |
| 207 | frame.ctx = parent.ctx |
| 208 | } |
| 209 | return frame |
| 210 | } |
| 211 | |
| 212 | // findFrame walks the activation hierarchy via Unwrap and Parent to locate an |
| 213 | // existing ExecutionFrame, if one exists. |