From f86b5724e530ec86eed04ebeb257293244f4be69 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 23 Sep 2021 14:59:14 +0200 Subject: Moved the character execution's to the pointer in order to handle the k command --- pkg/pointer/pointer.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'pkg/pointer/pointer.go') diff --git a/pkg/pointer/pointer.go b/pkg/pointer/pointer.go index 4d847bf..902fe69 100644 --- a/pkg/pointer/pointer.go +++ b/pkg/pointer/pointer.go @@ -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 -- cgit v1.2.3