From c913c2ae46fd81a3274ef16c64c78ea2ed421de8 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 12 Nov 2021 15:26:16 +0100 Subject: Refactoring : isolate stack manipulation into their own package --- pkg/pointer/exec.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'pkg/pointer/exec.go') 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() -- cgit v1.2.3