Exemplo n.º 1
0
func (d *Dwimmer) watchdog(setting *term.SettingT) {
	if rand.Int()%(watchFrequency<<(3*watcherDepth)) == 0 {
		watcherDepth++
		defer func() { watcherDepth-- }()
		parent := setting.Copy().AppendAction(term.MetaC())
		oldWatcher := d.lastWatcher
		newWatcher := term.InitT()
		var Q term.T
		if d.lastWatcher == nil {
			Q = IsAllWell.T(term.MakeChannel(parent))
		} else {
			Q = IsAllWellPred.T(term.MakeChannel(parent), term.MakeChannel(oldWatcher))
		}
		d.lastWatcher = newWatcher
		dynamics.SubRun(d, Q, parent, newWatcher)
	}
}
Exemplo n.º 2
0
func (r *lexer) setActionResult(head string, e *Expr, n int) {
	var a term.ActionC
	var t term.C
	if e != nil {
		t = toC(e)
	}
	switch strings.ToLower(head) {
	case "return", "reply", "say", "respond", "answer":
		if t == nil {
			t = term.Cc(represent.Int(n))
		}
		a = term.ReturnC(t)
	case "ask", "inquire", "do":
		a = term.AskC(t)
	case "view", "check", "inspect", "see":
		if t == nil {
			t = term.Cc(represent.Int(n))
		}
		a = term.ViewC(t)
	case "replace", "rewrite", "change", "jump", "set":
		a = term.ReplaceC(t, n)
	case "replay", "redo", "repeat":
		a = term.ReplayC(n)
	case "correct", "fix", "debug":
		a = term.CorrectC(n)
	case "meta", "self", "here", "this":
		a = term.MetaC()
	case "close", "dismiss", "stop", "delete", "del", "remove":
		c := toC(e)
		switch c := c.(type) {
		case term.ReferenceC:
			a = term.DeleteC(c.Index)
		}
	default:
		return
	}
	r.actionResult = &a
}