trust your head
This commit is contained in:
parent
a6e578090c
commit
b6235d8ecd
@ -1801,13 +1801,39 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void completeInnerCall( bool on_cut, yamop *old_CP, yamop *old_P)
|
||||||
|
{
|
||||||
|
if (on_cut) {
|
||||||
|
P = old_P;
|
||||||
|
ENV = (CELL *)ENV[E_E];
|
||||||
|
CP = old_CP;
|
||||||
|
LOCAL_AllowRestart = TRUE;
|
||||||
|
// we are back to user code again, need slots */
|
||||||
|
} else {
|
||||||
|
P = old_P;
|
||||||
|
ENV = B->cp_env;
|
||||||
|
ENV = (CELL *)ENV[E_E];
|
||||||
|
CP = old_CP;
|
||||||
|
HR = B->cp_h;
|
||||||
|
TR = B->cp_tr;
|
||||||
|
B = B->cp_b;
|
||||||
|
LOCAL_AllowRestart = FALSE;
|
||||||
|
SET_ASP(ENV, E_CB * sizeof(CELL));
|
||||||
|
// make sure the slots are ok.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
choiceptr myB, handler;
|
choiceptr myB, handler;
|
||||||
|
|
||||||
// fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d P=%p CP=%p Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
// fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d P=%p CP=%p Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP, LOCAL_CurSlot);
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
myB = (choiceptr)(LCL0 - dgi->b0);
|
myB = (choiceptr)(LCL0 - dgi->b);
|
||||||
|
if (LOCAL_PrologMode & AsyncIntMode) {
|
||||||
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
|
}
|
||||||
handler = B;
|
handler = B;
|
||||||
while (handler
|
while (handler
|
||||||
//&& LOCAL_CBorder > LCL0 - (CELL *)handler
|
//&& LOCAL_CBorder > LCL0 - (CELL *)handler
|
||||||
@ -1815,6 +1841,7 @@ X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
|||||||
&& handler->cp_b != NULL
|
&& handler->cp_b != NULL
|
||||||
&& handler <= myB
|
&& handler <= myB
|
||||||
) {
|
) {
|
||||||
|
if (handler < myB)
|
||||||
handler->cp_ap = TRUSTFAILCODE;
|
handler->cp_ap = TRUSTFAILCODE;
|
||||||
B = handler;
|
B = handler;
|
||||||
handler = handler->cp_b;
|
handler = handler->cp_b;
|
||||||
@ -1851,7 +1878,6 @@ X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
|||||||
X_API Int YAP_RunGoal(Term t) {
|
X_API Int YAP_RunGoal(Term t) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term out;
|
Term out;
|
||||||
yamop *old_CP = CP;
|
|
||||||
yhandle_t cslot = LOCAL_CurSlot;
|
yhandle_t cslot = LOCAL_CurSlot;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
@ -1861,24 +1887,6 @@ X_API Int YAP_RunGoal(Term t) {
|
|||||||
LOCAL_PrologMode = UserCCallMode;
|
LOCAL_PrologMode = UserCCallMode;
|
||||||
// should we catch the exception or pass it through?
|
// should we catch the exception or pass it through?
|
||||||
// We'll pass it through
|
// We'll pass it through
|
||||||
Yap_RaiseException();
|
|
||||||
if (out) {
|
|
||||||
P = (yamop *)ENV[E_CP];
|
|
||||||
ENV = (CELL *)ENV[E_E];
|
|
||||||
CP = old_CP;
|
|
||||||
LOCAL_AllowRestart = TRUE;
|
|
||||||
// we are back to user code again, need slots */
|
|
||||||
} else {
|
|
||||||
ENV = B->cp_env;
|
|
||||||
ENV = (CELL *)ENV[E_E];
|
|
||||||
CP = old_CP;
|
|
||||||
HR = B->cp_h;
|
|
||||||
TR = B->cp_tr;
|
|
||||||
B = B->cp_b;
|
|
||||||
LOCAL_AllowRestart = FALSE;
|
|
||||||
SET_ASP(ENV, E_CB * sizeof(CELL));
|
|
||||||
// make sure the slots are ok.
|
|
||||||
}
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
LOCAL_CurSlot = cslot;
|
LOCAL_CurSlot = cslot;
|
||||||
return out;
|
return out;
|
||||||
|
@ -367,6 +367,7 @@ public:
|
|||||||
//> output.
|
//> output.
|
||||||
YAPTerm funCall(YAPTerm t) { return YAPTerm(fun(t.term())); };
|
YAPTerm funCall(YAPTerm t) { return YAPTerm(fun(t.term())); };
|
||||||
Term fun(Term t);
|
Term fun(Term t);
|
||||||
|
//Term fun(YAPTerm t) { return fun(t.term()); };
|
||||||
//> set a StringFlag, usually a path
|
//> set a StringFlag, usually a path
|
||||||
//>
|
//>
|
||||||
bool setStringFlag(std::string arg, std::string path) {
|
bool setStringFlag(std::string arg, std::string path) {
|
||||||
|
@ -8,7 +8,6 @@ PyObject *py_Main;
|
|||||||
void pyErrorHandler__(int line, const char *file, const char *code) {
|
void pyErrorHandler__(int line, const char *file, const char *code) {
|
||||||
// this code is called if a Python error is found.
|
// this code is called if a Python error is found.
|
||||||
// int lvl = push_text_stack();
|
// int lvl = push_text_stack();
|
||||||
PyObject *type;
|
|
||||||
// PyErr_Fetch(&type, &val, NULL);
|
// PyErr_Fetch(&type, &val, NULL);
|
||||||
// PyErr_Print();
|
// PyErr_Print();
|
||||||
// Yap_ThrowError__(file,code,line,0, SYSTEM_ERROR_RUNTIME_PYTHON ,"Python
|
// Yap_ThrowError__(file,code,line,0, SYSTEM_ERROR_RUNTIME_PYTHON ,"Python
|
||||||
@ -235,7 +234,7 @@ static foreign_t assign_python(term_t exp, term_t name) {
|
|||||||
static foreign_t python_string_to(term_t f) {
|
static foreign_t python_string_to(term_t f) {
|
||||||
if (PL_is_atom(f)) {
|
if (PL_is_atom(f)) {
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
if (!PL_get_chars(f, &s, CVT_ALL | CVT_EXCEPTION | REP_UTF8)) {
|
if (!PL_get_chars(f, &s, CVT_ATOM |CVT_STRING | CVT_EXCEPTION | REP_UTF8)) {
|
||||||
pyErrorAndReturn(false);
|
pyErrorAndReturn(false);
|
||||||
}
|
}
|
||||||
if (!strcmp(s,"atom")) {
|
if (!strcmp(s,"atom")) {
|
||||||
@ -571,27 +570,6 @@ static foreign_t python_export(term_t t, term_t pl) {
|
|||||||
pyErrorAndReturn(rc);
|
pyErrorAndReturn(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_mod(const char *s0)
|
|
||||||
{
|
|
||||||
PyObject *pName;
|
|
||||||
term_t t0 = python_acquire_GIL();
|
|
||||||
#if PY_MAJOR_VERSION < 3
|
|
||||||
pName = PyString_FromString(s0);
|
|
||||||
#else
|
|
||||||
pName = PyUnicode_FromString(s0);
|
|
||||||
#endif
|
|
||||||
if (pName == NULL) {
|
|
||||||
python_release_GIL(t0);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *pModule = PyImport_Import(pName);
|
|
||||||
|
|
||||||
Py_XDECREF(pName);
|
|
||||||
python_release_GIL(t0);
|
|
||||||
|
|
||||||
return pModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred python_import(MName, Mod)
|
* @pred python_import(MName, Mod)
|
||||||
* Import a python module to the YAP environment.
|
* Import a python module to the YAP environment.
|
||||||
|
@ -479,6 +479,7 @@ If this hook preodicate succeeds it must instantiate the _Action_ argument to t
|
|||||||
|
|
||||||
:- yap_flag(user:unknown,error).
|
:- yap_flag(user:unknown,error).
|
||||||
|
|
||||||
|
%:- ensure_loaded('../android.yap').
|
||||||
|
|
||||||
|
|
||||||
%% @}
|
%% @}
|
||||||
|
@ -91,6 +91,18 @@ lists:delete([Head|List], Elem, Residue) :-
|
|||||||
lists:delete([Head|List], Elem, [Head|Residue]) :-
|
lists:delete([Head|List], Elem, [Head|Residue]) :-
|
||||||
lists:delete(List, Elem, Residue).
|
lists:delete(List, Elem, Residue).
|
||||||
|
|
||||||
|
|
||||||
|
% reverse(List, Reversed)
|
||||||
|
% is true when List and Reversed are lists with the same elements
|
||||||
|
% but in opposite orders. rev/2 is a synonym for reverse/2.
|
||||||
|
|
||||||
|
lists:reverse(List, Reversed) :-
|
||||||
|
lists:reverse(List, [], Reversed).
|
||||||
|
|
||||||
|
lists:reverse([], Reversed, Reversed).
|
||||||
|
lists:reverse([Head|Tail], Sofar, Reversed) :-
|
||||||
|
lists:reverse(Tail, [Head|Sofar], Reversed).
|
||||||
|
|
||||||
:- set_prolog_flag(source, false). % disable source.
|
:- set_prolog_flag(source, false). % disable source.
|
||||||
|
|
||||||
|
|
||||||
@ -135,4 +147,3 @@ prolog:length(L, M) :-
|
|||||||
M is N + 1, NL = [_|L], '$$_length2'(L, O, M) ).
|
M is N + 1, NL = [_|L], '$$_length2'(L, O, M) ).
|
||||||
|
|
||||||
%% @}
|
%% @}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user