aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer/exec.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-11-12 15:26:16 +0100
committerJulien Dessaux2021-11-12 15:28:09 +0100
commitc913c2ae46fd81a3274ef16c64c78ea2ed421de8 (patch)
treec454e21bfe42080fae433eae402b9f3a1c68783a /pkg/pointer/exec.go
parentFixed tricky field loading bug (diff)
downloadgofunge98-c913c2ae46fd81a3274ef16c64c78ea2ed421de8.tar.gz
gofunge98-c913c2ae46fd81a3274ef16c64c78ea2ed421de8.tar.bz2
gofunge98-c913c2ae46fd81a3274ef16c64c78ea2ed421de8.zip
Refactoring : isolate stack manipulation into their own package
Diffstat (limited to '')
-rw-r--r--pkg/pointer/exec.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/pkg/pointer/exec.go b/pkg/pointer/exec.go
index e2c55e3..8bb9dba 100644
--- a/pkg/pointer/exec.go
+++ b/pkg/pointer/exec.go
@@ -185,12 +185,7 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
now := time.Now()
x, y, lx, ly := f.Dump()
const uintSize = 32 << (^uint(0) >> 32 & 1) // 32 or 64
- heights := make([]int, p.ss.height)
- s := p.ss.head
- for i := p.ss.height - 1; i >= 0; i-- {
- heights[i] = s.height
- s = s.next
- }
+ heights := p.ss.GetHeights()
// 20
for _, e := range os.Environ() {
vars := strings.SplitN(e, "=", 2)
@@ -255,14 +250,7 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
// 1
p.ss.head.Push(0b00000) // TODO update when implementing t, i, o and =
if n > 0 {
- if n > p.ss.head.height {
- p.ss.head.height = 1
- p.ss.head.data[0] = 0
- } else {
- v := p.ss.head.data[p.ss.head.height-n]
- p.ss.head.height = heights[0]
- p.ss.head.Push(v)
- }
+ p.ss.YCommandPick(n, heights[0])
}
case '(':
n := p.ss.head.Pop()