From 7d85bbfa27cb93a23008e49c722538b2bea6447b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sat, 13 Apr 2019 14:05:31 +0100 Subject: [PATCH] py --- CXX/yapi.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index 9733eadc3..92e12894b 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -636,7 +636,6 @@ Term YAPEngine::fun(Term t) { Atom name; yhandle_t yt = Yap_NewHandles(1); - if (IsApplTerm(t)) { ts = RepAppl(t) + 1; f = (Functor)ts[-1]; @@ -647,29 +646,32 @@ Term YAPEngine::fun(Term t) { for (arity_t i = 0; i < arity; i++) { HR[i + 1] = ts[i]; } - HR[arity] = Yap_GetFromHandle(yt); HR += (arity+2); + arity++; } else if (IsAtomTerm(t)) { name = AtomOfTerm(t); t = AbsAppl(HR); HR[0] = (CELL)Yap_MkFunctor(name, 1); - HR[1] = Yap_GetFromHandle(yt); HR += 2; + arity = 1; } else if (IsPairTerm(t)) { HR[0] = (CELL)Yap_MkFunctor(AtomDot, 3); HR[1] = ts[0]; HR[2] = ts[1]; - HR[3] = Yap_GetFromHandle(yt); + HR += 4; + arity = 3; } else { throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE, t, 0); return 0L; } + RESET_VARIABLE(HR-1); + yt = Yap_InitHandle(t); CACHE_REGS BACKUP_MACHINE_REGS(); bool rc = YAP_RunGoalOnce(t); Term ot; if (rc) - ot = Yap_GetFromHandle(yt); + ot = ArgOfTerm(arity,Yap_GetFromHandle(yt)); else ot = TermNone; RECOVER_MACHINE_REGS();