write
This commit is contained in:
parent
5ec9e31eb9
commit
13d764067f
@ -2109,7 +2109,9 @@ X_API void YAP_ClearExceptions(void) {
|
||||
X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
||||
int *osnop) {
|
||||
CACHE_REGS
|
||||
|
||||
int sno;
|
||||
int lvl = push_text_stack();
|
||||
BACKUP_MACHINE_REGS();
|
||||
const char *fl = NULL;
|
||||
if (mode == YAP_BOOT_MODE) {
|
||||
@ -2126,8 +2128,6 @@ X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
||||
}
|
||||
__android_log_print(
|
||||
ANDROID_LOG_INFO, "YAPDroid", "done init_ consult %s ",fl);
|
||||
|
||||
int lvl = push_text_stack();
|
||||
char *d = Malloc(strlen(fl) + 1);
|
||||
strcpy(d, fl);
|
||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||
@ -2136,9 +2136,9 @@ int lvl = push_text_stack();
|
||||
LOCAL_encoding);
|
||||
__android_log_print(
|
||||
ANDROID_LOG_INFO, "YAPDroid", "OpenStream got %d ",sno);
|
||||
pop_text_stack(lvl);
|
||||
if (sno < 0 || !Yap_ChDir(dirname((char *)d))) {
|
||||
*full = NULL;
|
||||
pop_text_stack(lvl);
|
||||
return -1;
|
||||
}
|
||||
LOCAL_PrologMode = UserMode;
|
||||
|
@ -458,16 +458,16 @@ int Yap_copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
goto trail_overflow;
|
||||
}
|
||||
}
|
||||
TrailedMaBind(ptd0, new);
|
||||
ptf++;
|
||||
|
||||
} else {
|
||||
/* first time we met this term */
|
||||
RESET_VARIABLE(ptf);
|
||||
if ((ADDR)TR > LOCAL_TrailTop - 16)
|
||||
goto trail_overflow;
|
||||
DO_TRAIL(ptd0, (CELL)ptf);
|
||||
*ptd0 = (CELL)ptf;
|
||||
ptf++;
|
||||
if ((ADDR)TR > LOCAL_TrailTop - 16)
|
||||
goto trail_overflow;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,8 @@ static wtype AtomIsSymbols(unsigned char *);
|
||||
static void putAtom(Atom, int, struct write_globs *);
|
||||
static void writeTerm(Term, int, int, int, struct write_globs *,
|
||||
struct rewind_term *);
|
||||
static void writeTerm__(Term t, yhandle_t sl, int p, int depth, int rinfixarg,
|
||||
struct write_globs *wglb, struct rewind_term *rwt);
|
||||
|
||||
static void write_list(Term t, int direction, int depth,
|
||||
struct write_globs *wglb, struct rewind_term *rwt);
|
||||
@ -760,7 +762,7 @@ static void write_list__(Term t, yhandle_t sl, int direction, int depth,
|
||||
if (!IsPairTerm(ti))
|
||||
break;
|
||||
if (check_for_loops(ti,wglb)) return;
|
||||
wglb->sl = Yap_InitHandle(ti);
|
||||
sl = wglb->sl = Yap_InitHandle(ti);
|
||||
ndirection = RepPair(ti) - RepPair(t);
|
||||
/* make sure we're not trapped in loops */
|
||||
if (ndirection > 0) {
|
||||
@ -793,14 +795,14 @@ static void write_list__(Term t, yhandle_t sl, int direction, int depth,
|
||||
/* we found an infinite loop */
|
||||
/* keep going on the list */
|
||||
wrputc(',', wglb->stream);
|
||||
write_list(ti, direction, depth, wglb, &nrwt);
|
||||
write_list__(ti, sl, direction, depth, wglb, &nrwt);
|
||||
} else if (ti != MkAtomTerm(AtomNil)) {
|
||||
if (lastw == symbol || lastw == separator) {
|
||||
wrputc(' ', wglb->stream);
|
||||
}
|
||||
wrputc('|', wglb->stream);
|
||||
lastw = separator;
|
||||
writeTerm(ti, 999, depth, FALSE, wglb, &nrwt);
|
||||
writeTerm__(ti, sl, 999, depth, FALSE, wglb, &nrwt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,8 @@
|
||||
* [TOC]
|
||||
*
|
||||
* @{
|
||||
* \*/
|
||||
*
|
||||
*/
|
||||
|
||||
:- '$system_meta_predicates'([
|
||||
gated_call(0,0,?,0),
|
||||
@ -330,8 +331,8 @@ live :-
|
||||
|
||||
|
||||
'$process_answer'(Vs, LGs, Bindings) :-
|
||||
'$purge_dontcares'(Vs,IVs),
|
||||
'$sort'(IVs, NVs),
|
||||
%'$purge_dontcares'(Vs,IVs),
|
||||
'$sort'(Vs, NVs),
|
||||
'$prep_answer_var_by_var'(NVs, LAnsw, LGs),
|
||||
'$name_vars_in_goals'(LAnsw, Vs, Bindings).
|
||||
|
||||
|
@ -96,27 +96,25 @@ undefined_query(G0, M0, Cut) :-
|
||||
% undef handler
|
||||
'$undefp'([M0|G0],MG) :-
|
||||
% make sure we do not loop on undefined predicates
|
||||
'$undef_setup'(Action,Debug,Current),
|
||||
('$get_undefined_predicates'(M0:G0, MG)
|
||||
'$undef_setup'(M0:G0, Action,Debug,Current, MGI),
|
||||
('$get_undefined_predicates'(Current, MGI, MG ) , MG)
|
||||
->
|
||||
true
|
||||
;
|
||||
'$undef_error'(M0:G0, MG)
|
||||
),
|
||||
'$undef_error'(Current, M0:G0, MGI, MG)
|
||||
,
|
||||
'$undef_cleanup'(Action,Debug,Current).
|
||||
|
||||
'$undef_error'(M0:G0, MG) :-
|
||||
'$undef_error'(_, M0:G0, _, MG) :-
|
||||
'$pred_exists'(unknown_predicate_handler(_,_,_,_), user),
|
||||
'$yap_strip_module'(M0:G0, EM0, GM0),
|
||||
user:unknown_predicate_handler(GM0,EM0,MG),
|
||||
!.
|
||||
'$handle_error'(Mod:Goal,_) :-
|
||||
functor(Goal,Name,Arity),
|
||||
'$do_error'(existence_error(procedure,Name/Arity), Mod:Goal).
|
||||
'$handle_error'(warning,Goal,Mod) :-
|
||||
functor(Goal,Name,Arity),
|
||||
'$handle_error'(error, Mod:Goal, I,_) :-
|
||||
'$do_error'(existence_error(procedure,I), Mod:Goal).
|
||||
'$handle_error'(warning,Mod:Goal,I,_) :-
|
||||
'program_continuation'(PMod,PName,PAr),
|
||||
print_message(warning,error(existence_error(procedure,Name/Arity), context(Mod:Goal,PMod:PName/PAr))),
|
||||
print_message(warning,error(existence_error(procedure,I), context(Mod:Goal,PMod:PName/PAr))),
|
||||
fail.
|
||||
'$handle_error'(fail,_Goal,_Mod) :-
|
||||
fail.
|
||||
@ -126,6 +124,15 @@ undefined_query(G0, M0, Cut) :-
|
||||
yap_flag( debug, Debug, false),
|
||||
'$stop_creeping'(Current).
|
||||
|
||||
'$g2i'(user:G, Na/Ar ) :-
|
||||
!,
|
||||
functor(G, Na, Ar).
|
||||
'$g2i'(prolog:G, Na/Ar ) :-
|
||||
!,
|
||||
functor(G, Na, Ar).
|
||||
'$g2i'(M:G, M:Na/Ar ) :-
|
||||
!,
|
||||
functor(G, Na, Ar).
|
||||
|
||||
'$undef_cleanup'(Action,Debug,_Current) :-
|
||||
yap_flag( unknown, _, Action),
|
||||
|
Reference in New Issue
Block a user