aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer/pointer.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-23 14:59:14 +0200
committerJulien Dessaux2021-09-23 14:59:14 +0200
commitf86b5724e530ec86eed04ebeb257293244f4be69 (patch)
tree0ceaddd9f08229899eb94f7134a048c5b36d9ba4 /pkg/pointer/pointer.go
parentEach pointer needs its own stack, merging the two packages to avoid a circula... (diff)
downloadgofunge98-f86b5724e530ec86eed04ebeb257293244f4be69.tar.gz
gofunge98-f86b5724e530ec86eed04ebeb257293244f4be69.tar.bz2
gofunge98-f86b5724e530ec86eed04ebeb257293244f4be69.zip
Moved the character execution's to the pointer in order to handle the k command
Diffstat (limited to '')
-rw-r--r--pkg/pointer/pointer.go13
1 files changed, 9 insertions, 4 deletions
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