RemoveCallerFrame removes the stack frame above the current stack frame. This is useful in tail calls. It returns the new current frame.
()
| 2074 | // RemoveCallerFrame removes the stack frame above the current stack frame. This is useful in tail calls. It returns |
| 2075 | // the new current frame. |
| 2076 | func (ls *LState) RemoveCallerFrame() *callFrame { |
| 2077 | cs := ls.stack |
| 2078 | sp := cs.Sp() |
| 2079 | parentFrame := cs.At(sp - 2) |
| 2080 | currentFrame := cs.At(sp - 1) |
| 2081 | parentsParentFrame := parentFrame.Parent |
| 2082 | *parentFrame = *currentFrame |
| 2083 | parentFrame.Parent = parentsParentFrame |
| 2084 | parentFrame.Idx = sp - 2 |
| 2085 | cs.Pop() |
| 2086 | return parentFrame |
| 2087 | } |
| 2088 | |
| 2089 | /* }}} */ |
| 2090 |