aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/pointer/pointer.go6
-rw-r--r--pkg/pointer/pointer_test.go11
2 files changed, 17 insertions, 0 deletions
diff --git a/pkg/pointer/pointer.go b/pkg/pointer/pointer.go
index 5847e70..a833f5b 100644
--- a/pkg/pointer/pointer.go
+++ b/pkg/pointer/pointer.go
@@ -12,6 +12,8 @@ type Pointer struct {
// The Storage offset
sox int
soy int
+ // The next element for the multi-"threaded" b98 interpreter
+ Next *Pointer
}
func NewPointer() *Pointer {
@@ -25,3 +27,7 @@ func (p Pointer) Split() *Pointer {
func (p *Pointer) Step(f field.Field) {
p.x, p.y = f.Step(p.x, p.y, p.dx, p.dy)
}
+
+func (p Pointer) Get(f field.Field) int {
+ return f.Get(p.x, p.y)
+}
diff --git a/pkg/pointer/pointer_test.go b/pkg/pointer/pointer_test.go
index 658528d..ccbf486 100644
--- a/pkg/pointer/pointer_test.go
+++ b/pkg/pointer/pointer_test.go
@@ -39,3 +39,14 @@ func TestStep(t *testing.T) { // Step is thoroughly tested in the field package
p.Step(*f)
require.Equal(t, defaultPointer, p)
}
+
+func TestGet(t *testing.T) {
+ // File of one char
+ file, err := os.Open("../field/test_data/minimal.b98")
+ require.NoError(t, err, "Failed to open file")
+ defer file.Close()
+ f, err := field.Load(file)
+ p := NewPointer()
+ v := p.Get(*f)
+ require.Equal(t, int('@'), v)
+}