bunch of changes
Some checks failed
Build / build (push) Failing after 5m54s
Publish Image / publish (push) Failing after 35s
Test / build (push) Failing after 5m46s

This commit is contained in:
Chuck Smith
2024-03-28 17:19:23 -04:00
parent 244b71d245
commit fb0cebaf56
16 changed files with 174 additions and 320 deletions

View File

@@ -3,11 +3,8 @@ package vm
import (
"monkey/internal/code"
"monkey/internal/object"
"unsafe"
)
var cache = NewFrameCache(32)
type Frame struct {
cl *object.Closure
ip int
@@ -15,21 +12,11 @@ type Frame struct {
}
func NewFrame(cl *object.Closure, basePointer int) *Frame {
key := uint(uintptr(unsafe.Pointer(cl))) + uint(basePointer)
if frame, ok := cache.Get(key); ok {
frame.Reset()
return frame
}
frame := &Frame{
return &Frame{
cl: cl,
ip: -1,
basePointer: basePointer,
}
cache.Put(key, frame)
return frame
}
// NextOp ...