Pop pops the topmost stack frame after a function call.
(s *Stack)
| 76 | |
| 77 | // Pop pops the topmost stack frame after a function call. |
| 78 | func Pop(s *Stack) { |
| 79 | if !s.isTop() { |
| 80 | panic("pop when caller is not on topmost frame") |
| 81 | } |
| 82 | i := len(s.Frames) - 1 |
| 83 | s.Frames[i] = nil |
| 84 | s.Frames = s.Frames[:i] |
| 85 | s.FP-- |
| 86 | } |
| 87 | |
| 88 | func (s *Stack) isTop() bool { |
| 89 | return s.FP == len(s.Frames)-1 |
no test coverage detected