This commit is contained in:
2024-05-14 12:10:58 +02:00
parent a9bb79b01c
commit 59911aebb9
645 changed files with 263320 additions and 0 deletions

45
vendor/github.com/glycerine/zygomys/zygo/closing.go generated vendored Normal file
View File

@@ -0,0 +1,45 @@
package zygo
// where we store our closure-supporing stack pointers
type Closing struct {
Stack *Stack
Name string
env *Zlisp
}
func NewClosing(name string, env *Zlisp) *Closing {
stk := env.linearstack.Clone()
// be super strict: only store up to our
// enclosing function definition, because after
// that, the definition time of that function
// should be what we use.
return &Closing{
Stack: stk,
Name: name,
env: env}
}
func NewEmptyClosing(name string, env *Zlisp) *Closing {
return &Closing{
Stack: env.NewStack(0),
Name: name,
env: env}
}
func (c *Closing) IsStackElem() {}
func (c *Closing) LookupSymbolUntilFunction(sym *SexpSymbol, setVal *Sexp, maximumFuncToSearch int, checkCaptures bool) (Sexp, error, *Scope) {
return c.Stack.LookupSymbolUntilFunction(sym, setVal, maximumFuncToSearch, checkCaptures)
}
func (c *Closing) LookupSymbol(sym *SexpSymbol, setVal *Sexp) (Sexp, error, *Scope) {
return c.Stack.LookupSymbol(sym, setVal)
}
func (c *Closing) Show(env *Zlisp, ps *PrintState, label string) (string, error) {
return c.Stack.Show(env, ps, label)
}
func (c *Closing) TopScope() *Scope {
return c.Stack.GetTop().(*Scope)
}