diff options
author | Julien Dessaux | 2021-09-23 11:45:49 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-09-23 11:45:49 +0200 |
commit | 759ee2aa10323d1960405c93f7cd4cf6d383ae7a (patch) | |
tree | 87648b4811b0264f1b54c454ed2569abe1abee94 /pkg/stack/stack-stack.go | |
parent | Began coding the interpreter (only manages the minimal example for now!) (diff) | |
download | gofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.tar.gz gofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.tar.bz2 gofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.zip |
Each pointer needs its own stack, merging the two packages to avoid a circular dependency
Diffstat (limited to '')
-rw-r--r-- | pkg/pointer/stack-stack.go (renamed from pkg/stack/stack-stack.go) | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pkg/stack/stack-stack.go b/pkg/pointer/stack-stack.go index 9b80079..6d22f51 100644 --- a/pkg/stack/stack-stack.go +++ b/pkg/pointer/stack-stack.go @@ -1,8 +1,4 @@ -package stack - -import ( - "git.adyxax.org/adyxax/gofunge/pkg/pointer" -) +package pointer type StackStack struct { head *Stack @@ -16,7 +12,7 @@ func NewStackStack() *StackStack { } } -func (ss *StackStack) Begin(p *pointer.Pointer) { +func (ss *StackStack) Begin(p *Pointer) { ss.height++ soss := ss.head n := soss.Pop() @@ -44,7 +40,7 @@ func (ss *StackStack) Begin(p *pointer.Pointer) { p.CalculateNewStorageOffset() } -func (ss *StackStack) End(p *pointer.Pointer) (reflect bool) { +func (ss *StackStack) End(p *Pointer) (reflect bool) { if ss.height == 1 { return true } @@ -89,3 +85,11 @@ func (ss *StackStack) Under() (reflect bool) { } return false } + +func (ss StackStack) Pop() int { + return ss.head.Pop() +} + +func (ss StackStack) Push(v int) { + ss.head.Push(v) +} |