Simplified some code

This commit is contained in:
Julien Dessaux 2021-10-06 00:08:14 +02:00
parent 736d018152
commit 2623e80a93
3 changed files with 7 additions and 17 deletions

View file

@ -21,7 +21,6 @@ func (p *Pointer) Exec(f *field.Field) (done bool, returnValue *int) {
} }
if c == '"' { if c == '"' {
p.stringMode = false p.stringMode = false
p.lastCharWasSpace = false
} else { } else {
if c == ' ' { if c == ' ' {
p.lastCharWasSpace = true p.lastCharWasSpace = true
@ -65,30 +64,22 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
v := p.ss.head.Pop() v := p.ss.head.Pop()
return true, &v return true, &v
case 'k': case 'k':
x, y := p.x, p.y
n := p.ss.head.Pop() n := p.ss.head.Pop()
c = p.StepAndGet(*f) c = p.StepAndGet(*f)
steps := 1
for jumpingMode := false; jumpingMode || c == ' ' || c == ';'; c = p.StepAndGet(*f) { for jumpingMode := false; jumpingMode || c == ' ' || c == ';'; c = p.StepAndGet(*f) {
steps += 1
if c == ';' { if c == ';' {
jumpingMode = !jumpingMode jumpingMode = !jumpingMode
} }
} }
if n > 0 { if n > 0 {
// we need to reverse that step p.x, p.y = x, y
p.Reverse()
for i := 0; i < steps; i++ {
p.Step(*f)
}
p.Reverse()
if c != ' ' && c != ';' { if c != ' ' && c != ';' {
if n > 0 {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
p.eval(c, f) p.eval(c, f)
} }
} }
} }
}
case '!': case '!':
v := p.ss.head.Pop() v := p.ss.head.Pop()
if v == 0 { if v == 0 {

View file

@ -99,9 +99,8 @@ func (p *Pointer) Redirect(c int) bool {
case 'r': case 'r':
p.Reverse() p.Reverse()
case 'x': case 'x':
dy := p.ss.head.Pop() p.dy = p.ss.head.Pop()
dx := p.ss.head.Pop() p.dx = p.ss.head.Pop()
p.RedirectTo(dx, dy)
default: default:
return false return false
} }

View file

@ -80,7 +80,7 @@ func (ss *StackStack) End(p *Pointer) (reflect bool) {
} }
} }
ss.height-- ss.height--
ss.head = ss.head.next ss.head = soss
return false return false
} }