minor simplifications, removal of unused code
This commit is contained in:
parent
8d8e13d8ed
commit
22e541f391
2 changed files with 11 additions and 33 deletions
|
@ -20,8 +20,9 @@ func Get(f FE) *builtins {
|
|||
}
|
||||
|
||||
func setup(f FE) *builtins {
|
||||
voc := f.Voc()
|
||||
r := func(name string, fct forge.Callable) XT {
|
||||
return forge.Register(f.Voc(), name, fct)
|
||||
return forge.Register(voc, name, fct)
|
||||
}
|
||||
return &builtins{
|
||||
Add: r("+", func(f FE, _ XT) { f.Push(f.Pop().(int) + f.Pop().(int)) }),
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
package forge
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"git.sr.ht/~cco/go-scopes/common/ptr"
|
||||
"git.sr.ht/~cco/go-scopes/common/stack"
|
||||
"git.sr.ht/~cco/go-scopes/common/voc"
|
||||
|
@ -22,9 +19,6 @@ type forgeEnv struct {
|
|||
ds, rs fstack
|
||||
cp, ip, dp fptr
|
||||
voc *fvoc
|
||||
latestXT XT
|
||||
cstate bool
|
||||
output io.Writer
|
||||
}
|
||||
|
||||
type FE = *forgeEnv
|
||||
|
@ -43,7 +37,6 @@ func newFE(voc *fvoc) *forgeEnv {
|
|||
rs: stack.NewStack[fitem](),
|
||||
ip: ptr.NewSlice[fitem](),
|
||||
voc: voc,
|
||||
output: os.Stdout,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +48,6 @@ var newPtr = ptr.NewSlice[fitem]
|
|||
|
||||
type xitem struct {
|
||||
name string
|
||||
immediate bool
|
||||
fct Callable
|
||||
body fptr
|
||||
}
|
||||
|
@ -71,21 +63,6 @@ func Register(voc *fvoc, name string, fct Callable) *xitem {
|
|||
return &it
|
||||
}
|
||||
|
||||
func (it *xitem) IsImmediate() bool {
|
||||
return it.immediate
|
||||
}
|
||||
|
||||
func (it *xitem) Immediate() {
|
||||
it.immediate = true
|
||||
}
|
||||
|
||||
func (it *xitem) Body() fptr {
|
||||
if it.body == nil {
|
||||
it.body = newPtr()
|
||||
}
|
||||
return it.body
|
||||
}
|
||||
|
||||
func (it *xitem) Name() string {
|
||||
return it.name
|
||||
}
|
||||
|
@ -114,7 +91,7 @@ func (f *forgeEnv) Exec(items ...fitem) {
|
|||
|
||||
func (f *forgeEnv) Def(name string, items ...fitem) XT {
|
||||
xt := Register(f.voc, name, callDef)
|
||||
xt.Body().Append(f.Code(items...))
|
||||
xt.body = newPtr(f.Code(items...)).Next()
|
||||
return xt
|
||||
}
|
||||
|
||||
|
@ -141,5 +118,5 @@ func (f *forgeEnv) Peek(d int) fitem {
|
|||
// basic functions for executable items
|
||||
|
||||
func callDef(f *forgeEnv, xt XT) {
|
||||
f.Call(xt.Body().Value().(fptr))
|
||||
f.Call(xt.body.Value().(fptr))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue