eval: Add DeleteGlobal

Will be use by edit module soon.
This commit is contained in:
Manuel Mendez 2022-12-08 16:38:16 -05:00 committed by Qi Xiao
parent b178367ca7
commit 9fae00d125

View File

@ -174,6 +174,19 @@ func (ev *Evaler) ExtendGlobal(ns Nser) {
ev.global = CombineNs(ev.global, ns.Ns())
}
// DeleteGlobal deletes a binding from the global namespace.
func (ev *Evaler) DeleteGlobal(name string) {
ev.mu.Lock()
defer ev.mu.Unlock()
g := ev.global.clone()
for i := range g.infos {
if g.infos[i].name == name {
g.infos[i].deleted = true
}
}
ev.global = g
}
// Builtin returns the builtin Ns.
func (ev *Evaler) Builtin() *Ns {
ev.mu.RLock()