func (c *ProofC) Call(f interface{}, args ...interface{}) []interface{} { entryEntry := &LogEntry{ Type: FunctionEntry, Func: f, ArgsOrResults: args, } var exitEntry *LogEntry var log *LogTreap cacheFunc := ads.GetFuncId(f) == c.ToCache if cacheFunc && c.Caching { exitEntry = c.CachedExitEntry log = c.CachedLog } else { c.Stack = append(c.Stack, NewLogTreap(entryEntry)) if cacheFunc { c.Caching = true } ret := comp.Call(f, append(args, c)) top := len(c.Stack) - 1 exitEntry = &LogEntry{ Type: FunctionExit, Length: c.Stack[top].Count(c.Outer), //Internal: c.Stack[top].SeqHash(c.Outer), ArgsOrResults: ret, } log = CombineTreap(c.Stack[top], NewLogTreap(exitEntry), c.Outer) if cacheFunc { c.Caching = false c.CachedLog = log c.CachedExitEntry = exitEntry } c.Stack = c.Stack[:top] } top := len(c.Stack) - 1 if top >= 0 { c.Stack[top] = CombineTreap(c.Stack[top], log, c.Outer) } return exitEntry.ArgsOrResults }
func (c *ResolveC) Resolve() (next *LogEntry, err error) { done := false defer func() { if done { return } result := recover() if entry, ok := result.(*LogEntry); ok { next = entry err = nil return } var ok bool err, ok = result.(error) if !ok { err = errors.New("paniced: " + fmt.Sprint(result) + "\n" + string(debug.Stack())) } else { err = errors.New("errored: " + err.Error()) } }() entry := c.Expected[0] c.Idx = 1 c.Length = 1 //c.Internal = seqhash.New(entry) ret := comp.Call(entry.Func, append(entry.ArgsOrResults, c)) next = &LogEntry{ Type: FunctionExit, ArgsOrResults: ret, Length: c.Length, //Internal: c.Internal, } err = nil done = true return }
func (c *PagingC) Call(f interface{}, args ...interface{}) []interface{} { return comp.Call(f, append(args, c)) }