1
0
Fork 0

Moved the character execution's to the pointer in order to handle the k command

This commit is contained in:
Julien Dessaux 2021-09-23 14:59:14 +02:00
parent 759ee2aa10
commit f86b5724e5
5 changed files with 78 additions and 26 deletions
pkg/pointer

View file

@ -17,13 +17,13 @@ type Pointer struct {
sox int
soy int
// The stack
ss *StackStack
Ss *StackStack
// The next element for the multi-"threaded" b98 interpreter
Next *Pointer
}
func NewPointer() *Pointer {
return &Pointer{dx: 1, ss: NewStackStack()}
return &Pointer{dx: 1, Ss: NewStackStack()}
}
func (p Pointer) Split() *Pointer {
@ -38,6 +38,11 @@ func (p Pointer) Get(f field.Field) int {
return f.Get(p.x, p.y)
}
func (p *Pointer) StepAndGet(f field.Field) int {
p.Step(f)
return p.Get(f)
}
func (p *Pointer) Set(x, y int) {
p.x, p.y = x, y
}
@ -71,8 +76,8 @@ func (p *Pointer) Redirect(c int) bool {
case 'r':
p.Reverse()
case 'x':
dy := p.ss.Pop()
dx := p.ss.Pop()
dy := p.Ss.Pop()
dx := p.Ss.Pop()
p.RedirectTo(dx, dy)
default:
return false