本文整理汇总了Golang中github.com/paulfchristiano/dwimmer/term.SettingT.Rollback方法的典型用法代码示例。如果您正苦于以下问题:Golang SettingT.Rollback方法的具体用法?Golang SettingT.Rollback怎么用?Golang SettingT.Rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/paulfchristiano/dwimmer/term.SettingT
的用法示例。
在下文中一共展示了SettingT.Rollback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Do
func (d *Dwimmer) Do(a term.ActionT, s *term.SettingT) term.T {
switch a.Act {
case term.Return:
return a.Args[0]
case term.Ask:
Q := a.Args[0]
child := term.InitT()
dynamics.SubRun(d, Q, s, child)
return nil
case term.View:
value := a.Args[0]
if value != nil {
s.AppendTerm(value)
} else {
s.AppendTerm(Closed.T())
}
return nil
case term.Replace:
//value := a.Args[0]
//n := a.IntArgs[0]
//s.Rollback(n).AppendTerm(value)
return nil
case term.Replay:
n := a.IntArgs[0]
s.Rollback(n)
return nil
case term.Clarify:
Q := a.Args[1]
//TODO handle null pointers much better...
//(e.g. one part of an expression may refer to a deleted variable)
if a.Args[0] == nil {
s.AppendTerm(Closed.T())
return nil
}
var target *term.SettingT
channel, err := represent.ToChannel(d, a.Args[0])
if err == nil {
target = channel.(term.Channel).Instantiate()
} else {
var othererr term.T
target, othererr = represent.ToSettingT(d, a.Args[0])
if othererr != nil {
s.AppendTerm(NotAChannel.T(err))
return nil
}
}
dynamics.SubRun(d, Q, s, target)
return nil
case term.Correct:
n := a.IntArgs[0]
old := s.Setting.Rollback(n)
transition := ElicitAction(d, term.InitT(), old)
d.Save(old, transition)
s.AppendTerm(core.OK.T())
return nil
case term.Delete:
n := a.IntArgs[0]
s.Args[n] = nil
s.AppendTerm(core.OK.T())
return nil
case term.Meta:
s.AppendTerm(CurrentSetting.T(represent.SettingT(s)))
return nil
}
panic("unknown kind of action")
}