Files
monkey/internal/vm/frame.go
Chuck Smith fb0cebaf56
Some checks failed
Build / build (push) Failing after 5m54s
Publish Image / publish (push) Failing after 35s
Test / build (push) Failing after 5m46s
bunch of changes
2024-03-28 17:19:23 -04:00

34 lines
532 B
Go

package vm
import (
"monkey/internal/code"
"monkey/internal/object"
)
type Frame struct {
cl *object.Closure
ip int
basePointer int
}
func NewFrame(cl *object.Closure, basePointer int) *Frame {
return &Frame{
cl: cl,
ip: -1,
basePointer: basePointer,
}
}
// NextOp ...
func (f *Frame) NextOp() code.Opcode {
return code.Opcode(f.Instructions()[f.ip+1])
}
func (f *Frame) Reset() {
f.ip = -1
}
func (f *Frame) Instructions() code.Instructions {
return f.cl.Fn.Instructions
}