func currentSection(vm *gelo.VM) (string, string) { k := gelo.StrToSym("section-tag") tag, ok := vm.Ns.Get(0, k) if !ok { runtimeError(vm, "Unable to get current section tag (not in the section?)") } k = gelo.StrToSym("section-name") name, ok := vm.Ns.Get(0, k) if !ok { runtimeError(vm, "Unable to get current section name (not in the section?)") } return tag.Ser().String(), name.Ser().String() }
func enterSection(vm *gelo.VM, tag string, name string) { vm.Ns.Fork(nil) k := gelo.StrToSym("section-tag") v := gelo.StrToSym(tag) if !vm.Ns.Set(0, k, v) { runtimeError(vm, "Unable to set section tag: section %s %s", tag, name) } k = gelo.StrToSym("section-name") v = gelo.StrToSym(name) if !vm.Ns.Set(0, k, v) { runtimeError(vm, "Unable to set section name: section %s %s", tag, name) } }
func Die(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word { if ac == 0 { args = gelo.AsList(gelo.StrToSym("die")) } gelo.RuntimeError(vm, args) return gelo.Null //Issue 65 }
func leaveSection(vm *gelo.VM, tag string, name string) { // In fact deleting keys is completely unneccessary; it is added only for additional check that we really are // in a section k := gelo.StrToSym("section-tag") if _, ok := vm.Ns.Del(k); !ok { runtimeError(vm, "Unable to delete section tag (not in the section?): section %s %s", tag, name) } k := gelo.StrToSym("section-name") if _, ok := vm.Ns.Del(k); !ok { runtimeError(vm, "Unable to delete section name (not in the section?): section %s %s", tag, name) } k = gelo.StrToSym if !vm.Ns.Unfork() { runtimeError(vm, "Unable to exit the namespace (not in the section?): section %s %s", tag, name) } }
func Dict_keys(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word { if ac != 1 { gelo.ArgumentError(vm, "dict.keys", "dictionary", args) } d, list := vm.API.DictOrElse(args.Value), extensions.ListBuilder() for k, _ := range d.Map() { list.Push(gelo.StrToSym(k)) } return list.List() }
func checkNotInSection(vm *gelo.VM, command string) { k := gelo.StrToSym("section") if s, ok := vm.Ns.Get(0, k); ok { gelo.RuntimeError( vm, fmt.Sprintf( "%s command is used inside a section %s while it should be toplevel", command, s.Ser().String(), ), ) } }
func getOrMakeDict(vm *gelo.VM, name string) *gelo.Dict { k := gelo.StrToSym(name) dw, ok := vm.Ns.Get(0, k) var d *gelo.Dict if ok { d, ok = dw.(*gelo.Dict) if !ok { d = gelo.NewDict() vm.Ns.Set(0, k, d) } } else { d = gelo.NewDict() vm.Ns.Set(0, k, d) } return d }
func (c *couple) Type() gelo.Symbol { return gelo.StrToSym("*COUPLED-PORT*") }
func (t *tee) Type() gelo.Symbol { return gelo.StrToSym("*TEE-PORT*") }
func (g *lr) Type() gelo.Symbol { return gelo.StrToSym("*LOGGER-PORT*") }
func (id SenderIdentity) Ser() gelo.Symbol { return gelo.StrToSym(fmt.Sprintf("%s %s", id.senderType, id.senderName)) }
func (id SenderIdentity) Type() gelo.Symbol { return gelo.StrToSym("SenderIdentity") }
} func (s *_stdio) Copy() gelo.Word { return s } func (s *_stdio) DeepCopy() gelo.Word { return s } func (s *_stdio) Equals(w gelo.Word) bool { _, ok := w.(*_stdio) return ok } var _stdio_t = gelo.StrToSym("*STDIO*") func (*_stdio) Type() gelo.Symbol { return _stdio_t } type _stderr struct{} func (s *_stderr) Send(w gelo.Word) { os.Stderr.Write(w.Ser().Bytes()) os.Stderr.WriteString("\n") } func (s *_stderr) Recv() gelo.Word { return gelo.Null }
func (r *Regexp) Ser() gelo.Symbol { return gelo.StrToSym(r.String()) }
func (*Regexp) Type() gelo.Symbol { return gelo.StrToSym("*REGULAR-EXPRESSION*") }