frame.go 494 B

123456789101112131415161718192021222324
  1. // Author: simon
  2. // Author: ynwdlxm@163.com
  3. // Date: 2022/11/15 10:57
  4. // Desc:
  5. package vm
  6. import (
  7. "github/runnignwater/monkey/code"
  8. "github/runnignwater/monkey/object"
  9. )
  10. type Frame struct {
  11. fn *object.CompileFunction // points to the compiled function
  12. ip int // the instruction pointer in this frame
  13. }
  14. func NewFrame(fn *object.CompileFunction) *Frame {
  15. return &Frame{fn: fn, ip: -1}
  16. }
  17. func (f *Frame) Instructions() code.Instructions {
  18. return f.fn.Instructions
  19. }