address.go 418 B

12345678910111213141516171819202122
  1. package glisp
  2. type Address struct {
  3. function SexpFunction
  4. position int
  5. }
  6. func (a Address) IsStackElem() {}
  7. func (stack *Stack) PushAddr(function SexpFunction, pc int) {
  8. stack.Push(Address{function, pc})
  9. }
  10. func (stack *Stack) PopAddr() (SexpFunction, int, error) {
  11. elem, err := stack.Pop()
  12. if err != nil {
  13. return MissingFunction, 0, err
  14. }
  15. addr := elem.(Address)
  16. return addr.function, addr.position, nil
  17. }