From 30d9257fe09cd308bd4cdf86eb3d808a9dcba6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 14 Mar 2011 20:54:55 +0000 Subject: [PATCH] improve SWI call interface code. --- C/c_interface.c | 57 +++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index 6fa78626a..39d16a286 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -1538,12 +1538,12 @@ Int YAP_Execute(PredEntry *pe, CPredicate exec_code) { CACHE_REGS + Int ret; if (pe->PredFlags & SWIEnvPredFlag) { CPredicateV codev = (CPredicateV)exec_code; struct foreign_context ctx; UInt i; Int sl = 0; - Int ret; ctx.engine = NULL; for (i=pe->ArityOfPE; i > 0; i--) { @@ -1551,48 +1551,25 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code) } PP = pe; ret = ((codev)(sl,0,&ctx)); - PP = NULL; - if (!ret) { - Term t; - - BallTerm = EX; - EX = NULL; - if ((t = Yap_GetException())) { - Yap_JumpToEnv(t); - return FALSE; - } - } - return ret; - } - if (pe->PredFlags & CArgsPredFlag) { + } else if (pe->PredFlags & CArgsPredFlag) { PP = pe; - Int out = execute_cargs(pe, exec_code PASS_REGS); - PP = NULL; - if (!out) { - Term t; - - BallTerm = EX; - EX = NULL; - if ((t = Yap_GetException())) { - Yap_JumpToEnv(t); - return FALSE; - } - } - return out; + ret = execute_cargs(pe, exec_code PASS_REGS); } else { - Int ret = (exec_code)( PASS_REGS1 ); - if (!ret) { - Term t; - - BallTerm = EX; - EX = NULL; - if ((t = Yap_GetException())) { - Yap_JumpToEnv(t); - return FALSE; - } - } - return ret; + PP = pe; + ret = (exec_code)( PASS_REGS1 ); } + PP = NULL; + if (!ret) { + Term t; + + BallTerm = EX; + EX = NULL; + if ((t = Yap_GetException())) { + Yap_JumpToEnv(t); + return FALSE; + } + } + return ret; } #define FRG_REDO_MASK 0x00000003L