Moved the character execution's to the pointer in order to handle the k command
This commit is contained in:
parent
759ee2aa10
commit
f86b5724e5
5 changed files with 78 additions and 26 deletions
39
pkg/pointer/exec.go
Normal file
39
pkg/pointer/exec.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package pointer
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.adyxax.org/adyxax/gofunge/pkg/field"
|
||||
)
|
||||
|
||||
func (p *Pointer) Exec(f *field.Field) (done bool, returnValue *int) {
|
||||
c := p.Get(*f)
|
||||
for jumpingMode := false; jumpingMode || c == ' ' || c == ';'; c = p.StepAndGet(*f) {
|
||||
if jumpingMode {
|
||||
if c == ';' {
|
||||
jumpingMode = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
switch c {
|
||||
case '@':
|
||||
return true, nil
|
||||
case '#':
|
||||
p.Step(*f)
|
||||
case 'j':
|
||||
n := p.Ss.Pop()
|
||||
for j := 0; j < n; j++ {
|
||||
p.Step(*f)
|
||||
}
|
||||
case 'q':
|
||||
v := p.Ss.Pop()
|
||||
return true, &v
|
||||
default:
|
||||
if !p.Redirect(c) {
|
||||
log.Fatalf("Non implemented instruction code %d : %c", c, c)
|
||||
}
|
||||
}
|
||||
p.Step(*f)
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue