frame.go 600 B

1234567891011121314151617181920212223242526272829
  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. basePointer int
  14. }
  15. func NewFrame(fn *object.CompileFunction, basePointer int) *Frame {
  16. return &Frame{
  17. fn: fn,
  18. ip: -1,
  19. basePointer: basePointer,
  20. }
  21. }
  22. func (f *Frame) Instructions() code.Instructions {
  23. return f.fn.Instructions
  24. }