lots o fixes
Some checks failed
Build / build (push) Successful in 9m50s
Publish Image / publish (push) Failing after 49s
Test / build (push) Successful in 10m55s

This commit is contained in:
2024-04-01 18:18:45 -04:00
parent fe33fda0ab
commit 862119e90e
44 changed files with 326 additions and 170 deletions

View File

@@ -5,57 +5,57 @@ import (
"monkey/internal/object"
)
type Frame struct {
type frame struct {
cl *object.Closure
ip int
basePointer int
}
func NewFrame(cl *object.Closure, basePointer int) Frame {
return Frame{
func newFrame(cl *object.Closure, basePointer int) frame {
return frame{
cl: cl,
basePointer: basePointer,
}
}
func (f *Frame) Closure() *object.Closure {
func (f *frame) Closure() *object.Closure {
return f.cl
}
func (f *Frame) GetFree(idx uint8) object.Object {
func (f *frame) GetFree(idx uint8) object.Object {
return f.cl.Free[idx]
}
func (f *Frame) SetFree(idx uint8, obj object.Object) {
func (f *frame) SetFree(idx uint8, obj object.Object) {
f.cl.Free[idx] = obj
}
func (f *Frame) SetIP(ip int) {
func (f *frame) SetIP(ip int) {
f.ip = ip
}
func (f Frame) PeekNextOp() code.Opcode {
func (f frame) PeekNextOp() code.Opcode {
return code.Opcode(f.cl.Fn.Instructions[f.ip])
}
func (f *Frame) ReadNextOp() code.Opcode {
func (f *frame) ReadNextOp() code.Opcode {
op := code.Opcode(f.cl.Fn.Instructions[f.ip])
f.ip++
return op
}
func (f *Frame) ReadUint8() uint8 {
func (f *frame) ReadUint8() uint8 {
n := code.ReadUint8(f.cl.Fn.Instructions[f.ip:])
f.ip++
return n
}
func (f *Frame) ReadUint16() uint16 {
func (f *frame) ReadUint16() uint16 {
n := code.ReadUint16(f.cl.Fn.Instructions[f.ip:])
f.ip += 2
return n
}
func (f Frame) Instructions() code.Instructions {
func (f frame) Instructions() code.Instructions {
return f.cl.Fn.Instructions
}