generic fixes, mostly indentin
This commit is contained in:
parent
b2369175e5
commit
42e2543ab7
4
C/save.c
4
C/save.c
@ -500,7 +500,7 @@ save_code_info(void)
|
||||
return -1;
|
||||
}
|
||||
/* and the current character codes */
|
||||
if (mywrite(splfild, Yap_chtype, NUMBER_OF_CHARS) < 0)
|
||||
if (mywrite(splfild, (char *)Yap_chtype, NUMBER_OF_CHARS*sizeof(char_kind_t)) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@ -950,7 +950,7 @@ get_insts(OPCODE old_ops[])
|
||||
static int
|
||||
get_hash(void)
|
||||
{
|
||||
return myread(splfild, Yap_chtype , NUMBER_OF_CHARS);
|
||||
return myread(splfild, (char *)Yap_chtype , NUMBER_OF_CHARS*sizeof(char_kind_t));
|
||||
}
|
||||
|
||||
/* Copy all of the old code to the new Heap */
|
||||
|
166
C/stdpreds.c
166
C/stdpreds.c
@ -182,7 +182,7 @@
|
||||
* YAP_Error changed.
|
||||
*
|
||||
* Revision 1.84 2005/03/02 18:35:46 vsc
|
||||
* try to make initialisation process more robust
|
||||
* try to make initialization process more robust
|
||||
* try to make name more robust (in case Lookup new atom fails)
|
||||
*
|
||||
* Revision 1.83 2005/03/01 22:25:09 vsc
|
||||
@ -223,13 +223,14 @@
|
||||
* replace heap_base by Yap_heap_base, according to Yap's convention for globals.
|
||||
*
|
||||
* Revision 1.74 2004/11/19 22:08:43 vsc
|
||||
* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever appropriate.
|
||||
* replace SYSTEM_ERROR_INTERNAL by out OUT_OF_WHATEVER_ERROR whenever
|
||||
*appropriate.
|
||||
*
|
||||
* Revision 1.73 2004/11/19 17:14:14 vsc
|
||||
* a few fixes for 64 bit compiling.
|
||||
*
|
||||
* Revision 1.72 2004/11/18 22:32:37 vsc
|
||||
* fix situation where we might assume nonextsing double initialisation of C
|
||||
* fix situation where we might assume nonextsing double initialization of C
|
||||
*predicates (use
|
||||
* Hidden Pred Flag).
|
||||
* $host_type was double initialised.
|
||||
@ -342,22 +343,21 @@ static Int p_walltime(USES_REGS1);
|
||||
static Int p_break(USES_REGS1);
|
||||
|
||||
#if YAP_JIT
|
||||
void* (*Yap_JitCall)(JIT_Compiler* jc, yamop* p);
|
||||
void (* Yap_llvmShutdown)(void ) ;
|
||||
Int (* Yap_traced_absmi)(void ) ;
|
||||
void *(*Yap_JitCall)(JIT_Compiler *jc, yamop *p);
|
||||
void (*Yap_llvmShutdown)(void);
|
||||
Int (*Yap_traced_absmi)(void);
|
||||
|
||||
static Int p_jit(USES_REGS1) { /* '$set_value'(+Atom,+Atomic) */
|
||||
void *jit_handle;
|
||||
|
||||
if ( (jit_handle = Yap_LoadForeignFile( YAP_YAPJITLIB, 0 ) ) ) {
|
||||
if (!Yap_CallForeignFile(jit_handle, "init_jit") )
|
||||
fprintf(stderr, "Could not load JIT\n" );
|
||||
if ((jit_handle = Yap_LoadForeignFile(YAP_YAPJITLIB, 0))) {
|
||||
if (!Yap_CallForeignFile(jit_handle, "init_jit"))
|
||||
fprintf(stderr, "Could not load JIT\n");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#endif /* YAP_JIT */
|
||||
|
||||
#ifdef BEAM
|
||||
@ -449,13 +449,14 @@ Int show_time(USES_REGS1) /* MORE PRECISION */
|
||||
}
|
||||
|
||||
#endif /* BEAM */
|
||||
// @{
|
||||
// @{
|
||||
|
||||
/**
|
||||
@defgroup YAPSetVal
|
||||
@ingroup Internal_Database
|
||||
|
||||
Maintain a light-weight map where the key is an atom, and the value can be any constant.
|
||||
Maintain a light-weight map where the key is an atom, and the value can be
|
||||
any constant.
|
||||
*/
|
||||
|
||||
/** @pred set_value(+ _A_,+ _C_)
|
||||
@ -530,7 +531,6 @@ static Int p_values(USES_REGS1) { /* '$values'(Atom,Old,New) */
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
static Int p_opdec(USES_REGS1) { /* '$opdec'(p,type,atom) */
|
||||
/* we know the arguments are integer, atom, atom */
|
||||
Term p = Deref(ARG1), t = Deref(ARG2), at = Deref(ARG3);
|
||||
@ -839,21 +839,24 @@ static Int
|
||||
}
|
||||
out = IntegerOfTerm(t);
|
||||
#if YAP_JIT
|
||||
if (ExpEnv.analysis_struc.stats_enabled || ExpEnv.analysis_struc.time_pass_enabled) {
|
||||
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDERR")) {
|
||||
if (ExpEnv.analysis_struc.stats_enabled ||
|
||||
ExpEnv.analysis_struc.time_pass_enabled) {
|
||||
if (strcmp(((char *)ExpEnv.analysis_struc.outfile), "STDERR")) {
|
||||
int stderrcopy = dup(2);
|
||||
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDOUT") == 0) {
|
||||
if (strcmp(((char *)ExpEnv.analysis_struc.outfile), "STDOUT") == 0) {
|
||||
dup2(1, 2);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
|
||||
shutdown_llvm();
|
||||
#pragma GCC diagnostic pop
|
||||
dup2(stderrcopy, 2);
|
||||
}
|
||||
else {
|
||||
int Outputfile = open(((char*)ExpEnv.analysis_struc.outfile), O_CREAT | O_APPEND | O_WRONLY, 0777);
|
||||
} else {
|
||||
int Outputfile = open(((char *)ExpEnv.analysis_struc.outfile),
|
||||
O_CREAT | O_APPEND | O_WRONLY, 0777);
|
||||
if (Outputfile < 0) {
|
||||
fprintf(stderr, "Error:: I can not write analysis passes's output on %s...\n", ((char*)ExpEnv.analysis_struc.outfile));
|
||||
fprintf(stderr,
|
||||
"Error:: I can not write analysis passes's output on %s...\n",
|
||||
((char *)ExpEnv.analysis_struc.outfile));
|
||||
fprintf(stderr, " %s...\n", strerror(errno));
|
||||
errno = 0;
|
||||
exit(1);
|
||||
@ -864,8 +867,7 @@ static Int
|
||||
dup2(stderrcopy, 2);
|
||||
}
|
||||
close(stderrcopy);
|
||||
}
|
||||
else
|
||||
} else
|
||||
shutdown_llvm();
|
||||
}
|
||||
#endif
|
||||
@ -874,25 +876,19 @@ static Int
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool
|
||||
valid_prop(Prop p, Term task)
|
||||
{
|
||||
static bool valid_prop(Prop p, Term task) {
|
||||
if (RepPredProp(p)->OpcodeOfPred == UNDEF_OPCODE)
|
||||
return false;
|
||||
if ( (RepPredProp(p)->PredFlags & (HiddenPredFlag|StandardPredFlag) ) )
|
||||
{
|
||||
return (task == SYSTEM_MODULE || task == TermTrue );
|
||||
if ((RepPredProp(p)->PredFlags & (HiddenPredFlag | StandardPredFlag))) {
|
||||
return (task == SYSTEM_MODULE || task == TermTrue);
|
||||
} else {
|
||||
return (task == USER_MODULE || task == TermTrue );
|
||||
return (task == USER_MODULE || task == TermTrue);
|
||||
}
|
||||
}
|
||||
|
||||
static PropEntry *
|
||||
followLinkedListOfProps (PropEntry *p, Term task)
|
||||
{
|
||||
static PropEntry *followLinkedListOfProps(PropEntry *p, Term task) {
|
||||
while (p) {
|
||||
if (p->KindOfPE == PEProp &&
|
||||
valid_prop(p, task) ) {
|
||||
if (p->KindOfPE == PEProp && valid_prop(p, task)) {
|
||||
// found our baby..
|
||||
return p;
|
||||
}
|
||||
@ -901,9 +897,7 @@ followLinkedListOfProps (PropEntry *p, Term task)
|
||||
return NIL;
|
||||
}
|
||||
|
||||
static PropEntry *
|
||||
getPredProp (PropEntry *p, Term task)
|
||||
{
|
||||
static PropEntry *getPredProp(PropEntry *p, Term task) {
|
||||
PredEntry *pe;
|
||||
if (p == NIL)
|
||||
return NIL;
|
||||
@ -923,9 +917,7 @@ getPredProp (PropEntry *p, Term task)
|
||||
return NIL;
|
||||
}
|
||||
|
||||
static PropEntry *
|
||||
nextPredForAtom (PropEntry *p, Term task)
|
||||
{
|
||||
static PropEntry *nextPredForAtom(PropEntry *p, Term task) {
|
||||
PredEntry *pe;
|
||||
if (p == NIL)
|
||||
return NIL;
|
||||
@ -942,18 +934,15 @@ nextPredForAtom (PropEntry *p, Term task)
|
||||
}
|
||||
|
||||
// if that fails, follow the functor
|
||||
return getPredProp( f->NextOfPE , task);
|
||||
return getPredProp(f->NextOfPE, task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Prop
|
||||
initFunctorSearch(Term t3, Term t2, Term task)
|
||||
{
|
||||
static Prop initFunctorSearch(Term t3, Term t2, Term task) {
|
||||
if (IsAtomTerm(t3)) {
|
||||
Atom at = AtomOfTerm(t3);
|
||||
// access the entry at key address.
|
||||
return followLinkedListOfProps( RepAtom( at )->PropsOfAE , task );
|
||||
return followLinkedListOfProps(RepAtom(at)->PropsOfAE, task);
|
||||
} else if (IsIntTerm(t3)) {
|
||||
if (IsNonVarTerm(t2) && t2 != IDB_MODULE) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t3, "current_predicate/2");
|
||||
@ -962,8 +951,9 @@ initFunctorSearch(Term t3, Term t2, Term task)
|
||||
Prop p;
|
||||
// access the entry at key address.
|
||||
// a single property (this will be deterministic
|
||||
p = AbsPredProp( Yap_FindLUIntKey( IntOfTerm( t3 ) ) );
|
||||
if (valid_prop(p, task)) return p;
|
||||
p = AbsPredProp(Yap_FindLUIntKey(IntOfTerm(t3)));
|
||||
if (valid_prop(p, task))
|
||||
return p;
|
||||
}
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t3, "current_predicate/2");
|
||||
return NULL;
|
||||
@ -978,35 +968,30 @@ initFunctorSearch(Term t3, Term t2, Term task)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return followLinkedListOfProps( f->PropsOfFE, task );
|
||||
return followLinkedListOfProps(f->PropsOfFE, task);
|
||||
}
|
||||
}
|
||||
|
||||
static PredEntry *
|
||||
firstModulePred( PredEntry * npp, Term task)
|
||||
{
|
||||
static PredEntry *firstModulePred(PredEntry *npp, Term task) {
|
||||
if (!npp)
|
||||
return NULL;
|
||||
do {
|
||||
npp = npp->NextPredOfModule;
|
||||
} while (npp &&
|
||||
!valid_prop(AbsPredProp(npp), task));
|
||||
} while (npp && !valid_prop(AbsPredProp(npp), task));
|
||||
return npp;
|
||||
}
|
||||
|
||||
static PredEntry *
|
||||
firstModulesPred( PredEntry *npp, Term task )
|
||||
{
|
||||
static PredEntry *firstModulesPred(PredEntry *npp, Term task) {
|
||||
ModEntry *m;
|
||||
if (npp) {
|
||||
m = Yap_GetModuleEntry( npp-> ModuleOfPred );
|
||||
m = Yap_GetModuleEntry(npp->ModuleOfPred);
|
||||
npp = npp->NextPredOfModule;
|
||||
} else {
|
||||
m = CurrentModules;
|
||||
npp = m->PredForME;
|
||||
}
|
||||
do {
|
||||
while (npp && !valid_prop(AbsPredProp(npp), task ) )
|
||||
while (npp && !valid_prop(AbsPredProp(npp), task))
|
||||
npp = npp->NextPredOfModule;
|
||||
if (npp)
|
||||
return npp;
|
||||
@ -1018,7 +1003,6 @@ firstModulesPred( PredEntry *npp, Term task )
|
||||
return npp;
|
||||
}
|
||||
|
||||
|
||||
static Int cont_current_predicate(USES_REGS1) {
|
||||
UInt Arity;
|
||||
Term name, task;
|
||||
@ -1036,11 +1020,11 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
|
||||
// t3 is a functor, or compound term,
|
||||
// just follow the functor chain
|
||||
p = AbsPredProp( pp );
|
||||
p = AbsPredProp(pp);
|
||||
if (!p) {
|
||||
// initial search, tracks down what is the first call with
|
||||
// that name, functor..
|
||||
p = initFunctorSearch( t3, t2, task );
|
||||
p = initFunctorSearch(t3, t2, task);
|
||||
// now, we can do lookahead.
|
||||
if (p == NIL)
|
||||
cut_fail();
|
||||
@ -1053,7 +1037,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
will_cut = true;
|
||||
break;
|
||||
} else {
|
||||
pp = RepPredProp(p = followLinkedListOfProps( p->NextOfPE, task ));
|
||||
pp = RepPredProp(p = followLinkedListOfProps(p->NextOfPE, task));
|
||||
}
|
||||
} while (!will_cut && p);
|
||||
}
|
||||
@ -1061,7 +1045,7 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
cut_fail();
|
||||
}
|
||||
do {
|
||||
np = followLinkedListOfProps( p->NextOfPE, task );
|
||||
np = followLinkedListOfProps(p->NextOfPE, task);
|
||||
if (!np) {
|
||||
will_cut = true;
|
||||
} else {
|
||||
@ -1073,16 +1057,16 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
PropEntry *np, *p;
|
||||
// run over the same atomany predicate defined for that atom
|
||||
// may be fair bait, depends on whether we know the module.
|
||||
p = AbsPredProp( pp );
|
||||
p = AbsPredProp(pp);
|
||||
if (!p) {
|
||||
// initialization time
|
||||
if (IsIntTerm( t1 )) {
|
||||
if (IsIntTerm(t1)) {
|
||||
// or this or nothing....
|
||||
p = AbsPredProp( Yap_FindLUIntKey( IntOfTerm( t3 ) ) );
|
||||
} else if (IsAtomTerm( t1 )) {
|
||||
p = AbsPredProp(Yap_FindLUIntKey(IntOfTerm(t3)));
|
||||
} else if (IsAtomTerm(t1)) {
|
||||
// should be the usual situation.
|
||||
Atom at = AtomOfTerm(t1);
|
||||
p = getPredProp( RepAtom(at)->PropsOfAE , task);
|
||||
p = getPredProp(RepAtom(at)->PropsOfAE, task);
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t1, "current_predicate/2");
|
||||
}
|
||||
@ -1103,15 +1087,15 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
PredEntry *npp;
|
||||
|
||||
if (!pp) {
|
||||
if (!IsAtomTerm( t2 )) {
|
||||
if (!IsAtomTerm(t2)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t2, "current_predicate/2");
|
||||
}
|
||||
ModEntry *m = Yap_GetModuleEntry(t2);
|
||||
pp = firstModulePred( m->PredForME , task );
|
||||
pp = firstModulePred(m->PredForME, task);
|
||||
if (!pp)
|
||||
cut_fail();
|
||||
}
|
||||
npp = firstModulePred( pp , task);
|
||||
npp = firstModulePred(pp, task);
|
||||
|
||||
if (!npp)
|
||||
will_cut = true;
|
||||
@ -1125,11 +1109,11 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
PredEntry *npp;
|
||||
|
||||
if (!pp) {
|
||||
pp = firstModulesPred( CurrentModules->PredForME, task );
|
||||
pp = firstModulesPred(CurrentModules->PredForME, task);
|
||||
if (!pp)
|
||||
cut_fail();
|
||||
}
|
||||
npp = firstModulesPred( pp , task);
|
||||
npp = firstModulesPred(pp, task);
|
||||
|
||||
if (!npp)
|
||||
will_cut = true;
|
||||
@ -1162,15 +1146,14 @@ static Int cont_current_predicate(USES_REGS1) {
|
||||
}
|
||||
}
|
||||
if (Arity) {
|
||||
rc = Yap_unify(t3,Yap_MkNewApplTerm(f, Arity));
|
||||
rc = Yap_unify(t3, Yap_MkNewApplTerm(f, Arity));
|
||||
} else {
|
||||
rc = Yap_unify(t3,name);
|
||||
rc = Yap_unify(t3, name);
|
||||
}
|
||||
rc = rc &&
|
||||
Yap_unify(t2, ModToTerm(pp->ModuleOfPred)) &&
|
||||
Yap_unify(t1, name);
|
||||
rc = rc && Yap_unify(t2, ModToTerm(pp->ModuleOfPred)) && Yap_unify(t1, name);
|
||||
if (will_cut) {
|
||||
if (rc) cut_succeed();
|
||||
if (rc)
|
||||
cut_succeed();
|
||||
cut_fail();
|
||||
}
|
||||
return rc;
|
||||
@ -1248,7 +1231,8 @@ static Int cont_current_op(USES_REGS1) {
|
||||
}
|
||||
}
|
||||
|
||||
static Int init_current_op(USES_REGS1) { /* current_op(-Precedence,-Type,-Atom) */
|
||||
static Int init_current_op(
|
||||
USES_REGS1) { /* current_op(-Precedence,-Type,-Atom) */
|
||||
EXTRA_CBACK_ARG(5, 1) = (CELL)MkIntegerTerm((CELL)OpList);
|
||||
B->cp_h = HR;
|
||||
return cont_current_op(PASS_REGS1);
|
||||
@ -1329,12 +1313,9 @@ void Yap_show_statistics(void) {
|
||||
Unsigned(LOCAL_TrailBase))),
|
||||
(unsigned long int)(sizeof(tr_fr_ptr) *
|
||||
(Unsigned(TR) - Unsigned(LOCAL_TrailBase))));
|
||||
fprintf(stderr, "Runtime: %lds.\n",
|
||||
(unsigned long int)(runtime(PASS_REGS1)));
|
||||
fprintf(stderr, "Cputime: %lds.\n",
|
||||
(unsigned long int)(Yap_cputime()));
|
||||
fprintf(stderr, "Walltime: %lds.\n",
|
||||
(unsigned long int)(Yap_walltime()));
|
||||
fprintf(stderr, "Runtime: %lds.\n", (unsigned long int)(runtime(PASS_REGS1)));
|
||||
fprintf(stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime()));
|
||||
fprintf(stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime()));
|
||||
}
|
||||
|
||||
static Int p_statistics_heap_max(USES_REGS1) {
|
||||
@ -1501,7 +1482,8 @@ static Int p_statistics_atom_info(USES_REGS1) {
|
||||
while (catom != NIL) {
|
||||
Atom ncatom;
|
||||
count++;
|
||||
spaceused += sizeof(AtomEntry) + strlen((char *)RepAtom(catom)->StrOfAE) + 1;
|
||||
spaceused +=
|
||||
sizeof(AtomEntry) + strlen((char *)RepAtom(catom)->StrOfAE) + 1;
|
||||
ncatom = RepAtom(catom)->NextOfAE;
|
||||
if (ncatom != NIL) {
|
||||
READ_LOCK(RepAtom(ncatom)->ARWLock);
|
||||
@ -1567,7 +1549,6 @@ static Int p_executable(USES_REGS1) {
|
||||
return Yap_unify(MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)), ARG1);
|
||||
}
|
||||
|
||||
|
||||
static Int p_system_mode(USES_REGS1) {
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
@ -1684,7 +1665,6 @@ static Int p_parallel_mode(USES_REGS1) { return FALSE; }
|
||||
static Int p_yapor_workers(USES_REGS1) { return FALSE; }
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
void Yap_InitCPreds(void) {
|
||||
/* numerical comparison */
|
||||
Yap_InitCPred("set_value", 2, p_setval, SafePredFlag | SyncPredFlag);
|
||||
@ -1758,8 +1738,7 @@ void Yap_InitCPreds(void) {
|
||||
Yap_InitCPred("$exit_undefp", 0, p_exitundefp, SafePredFlag);
|
||||
|
||||
#ifdef YAP_JIT
|
||||
Yap_InitCPred("$jit_init", 1, p_jit,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$jit_init", 1, p_jit, SafePredFlag | SyncPredFlag);
|
||||
#endif /* YAPOR */
|
||||
#ifdef INES
|
||||
Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag);
|
||||
@ -1819,8 +1798,7 @@ void Yap_InitCPreds(void) {
|
||||
Yap_init_optyap_preds();
|
||||
#endif /* YAPOR || TABLING */
|
||||
#if YAP_JIT
|
||||
Yap_InitCPred("jit", 0, p_jit,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("jit", 0, p_jit, SafePredFlag | SyncPredFlag);
|
||||
#endif
|
||||
Yap_InitThreadPreds();
|
||||
{
|
||||
|
196
C/tracer.c
196
C/tracer.c
@ -26,10 +26,8 @@
|
||||
#include "clause.h"
|
||||
#include "tracer.h"
|
||||
|
||||
|
||||
static void
|
||||
send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||
{
|
||||
static void send_tracer_message(char *start, char *name, Int arity, char *mname,
|
||||
CELL *args) {
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
fprintf(stderr, "(%d)%s", worker_id, start);
|
||||
@ -43,14 +41,16 @@ send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||
if (args)
|
||||
fprintf(stderr, "%s %s:%s(", start, mname, name);
|
||||
else
|
||||
fprintf(stderr, "%s %s:%s/%lu", start, mname, name, (unsigned long int)arity);
|
||||
fprintf(stderr, "%s %s:%s/%lu", start, mname, name,
|
||||
(unsigned long int)arity);
|
||||
} else {
|
||||
fprintf(stderr, "%s %s:%s", start, mname, name);
|
||||
}
|
||||
if (args) {
|
||||
for (i= 0; i < arity; i++) {
|
||||
if (i > 0) fprintf(stderr, ",");
|
||||
Yap_plwrite(args[i], NULL, 15, Handle_vars_f|AttVar_Portray_f, 1200);
|
||||
for (i = 0; i < arity; i++) {
|
||||
if (i > 0)
|
||||
fprintf(stderr, ",");
|
||||
Yap_plwrite(args[i], NULL, 15, Handle_vars_f | AttVar_Portray_f, 1200);
|
||||
}
|
||||
if (arity) {
|
||||
fprintf(stderr, ")");
|
||||
@ -85,7 +85,8 @@ check_trail_consistency(void) {
|
||||
CELL *p = RepPair(TrailTerm(ptr));
|
||||
if IsAttVar(p) continue;
|
||||
}
|
||||
printf("Oops at call %ld, B->cp(%p) TR(%p) pt(%p)\n", vsc_count,B->cp_tr, TR, ptr);
|
||||
printf("Oops at call %ld, B->cp(%p) TR(%p) pt(%p)\n",
|
||||
vsc_count,B->cp_tr, TR, ptr);
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -100,16 +101,13 @@ CELL old_value = 0L, old_value2 = 0L;
|
||||
|
||||
void jmp_deb(int), jmp_deb2(void);
|
||||
|
||||
void
|
||||
jmp_deb2( void )
|
||||
{
|
||||
fprintf(stderr,"Here\n");
|
||||
}
|
||||
void jmp_deb2(void) { fprintf(stderr, "Here\n"); }
|
||||
|
||||
void
|
||||
jmp_deb(int i) {
|
||||
if (i) printf("Here we go %ld\n", old_value++);
|
||||
if (old_value == 716) jmp_deb2();
|
||||
void jmp_deb(int i) {
|
||||
if (i)
|
||||
printf("Here we go %ld\n", old_value++);
|
||||
if (old_value == 716)
|
||||
jmp_deb2();
|
||||
}
|
||||
|
||||
struct various_codes *sc;
|
||||
@ -141,70 +139,76 @@ check_area(void)
|
||||
PredEntry *old_p[10000];
|
||||
Term old_x1[10000], old_x2[10000], old_x3[10000];
|
||||
|
||||
//static CELL oldv;
|
||||
// static CELL oldv;
|
||||
|
||||
void
|
||||
low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
{
|
||||
void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) {
|
||||
CACHE_REGS
|
||||
char *s;
|
||||
char *mname;
|
||||
Int arity;
|
||||
/* extern int gc_calls; */
|
||||
vsc_count++;
|
||||
//if (HR < ASP ) return;
|
||||
//fif (vsc_count == 12534) jmp_deb( 2 );
|
||||
// if (HR < ASP ) return;
|
||||
// fif (vsc_count == 12534) jmp_deb( 2 );
|
||||
#if __ANDROID__ && 0
|
||||
PredEntry *ap = pred;
|
||||
if (pred && port == enter_pred) {
|
||||
UInt flags = ap->PredFlags;
|
||||
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags);
|
||||
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags); */
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n",
|
||||
NameOfFunctor(ap->FunctorOfPred)->StrOfAE,
|
||||
ap->ArityOfPE, flags);
|
||||
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE,
|
||||
* ap->ArityOfPE, flags); */
|
||||
else if (ap->ModuleOfPred != IDB_MODULE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP "," %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
|
||||
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags); */
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP "," %x ", ap->src.OwnerFile);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n",
|
||||
((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE,
|
||||
flags);
|
||||
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE,
|
||||
* ap->ArityOfPE, flags); */
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %x ", ap->src.OwnerFile);
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
|
||||
// if (!worker_id) return;
|
||||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
sc = Yap_heap_regs;
|
||||
//if (vsc_count == 161862) jmp_deb(1);
|
||||
fprintf(stderr,"B=%ld ", LCL0-(CELL*)B);
|
||||
// if (vsc_count == 161862) jmp_deb(1);
|
||||
#ifdef THREADS
|
||||
LOCAL_ThreadHandle.thread_inst_count++;
|
||||
#endif
|
||||
#ifdef COMMENTED
|
||||
fprintf(stderr,"in %p\n");
|
||||
CELL * gc_ENV = ENV;
|
||||
fprintf(stderr, "in %p\n");
|
||||
CELL *gc_ENV = ENV;
|
||||
while (gc_ENV != NULL) { /* no more environments */
|
||||
fprintf(stderr,"%ld\n", LCL0-gc_ENV);
|
||||
gc_ENV = (CELL *) gc_ENV[E_E]; /* link to prev
|
||||
fprintf(stderr, "%ld\n", LCL0 - gc_ENV);
|
||||
gc_ENV = (CELL *)gc_ENV[E_E]; /* link to prev
|
||||
* environment */
|
||||
}
|
||||
return;
|
||||
{
|
||||
choiceptr b_p = B;
|
||||
while (b_p) {
|
||||
fprintf(stderr,"%p %ld\n",b_p,Yap_op_from_opcode(b_p->cp_ap->opc));
|
||||
fprintf(stderr, "%p %ld\n", b_p, Yap_op_from_opcode(b_p->cp_ap->opc));
|
||||
b_p = b_p->cp_b;
|
||||
}
|
||||
}
|
||||
{ choiceptr myB = B;
|
||||
while (myB) myB = myB->cp_b;
|
||||
{
|
||||
choiceptr myB = B;
|
||||
while (myB)
|
||||
myB = myB->cp_b;
|
||||
}
|
||||
//*(H0+(0xb65f2850-0xb64b2008)/sizeof(CELL))==0xc ||
|
||||
//0x4fd4d
|
||||
// 0x4fd4d
|
||||
if (vsc_count > 1388060LL && vsc_count < 1388070LL) {
|
||||
if (vsc_count==1388061LL)
|
||||
if (vsc_count == 1388061LL)
|
||||
jmp_deb(1);
|
||||
if (vsc_count % 1LL == 0) {
|
||||
UInt sz = Yap_regp->H0_[17];
|
||||
UInt end = sizeof(MP_INT)/sizeof(CELL)+sz+1;
|
||||
fprintf(stderr,"VAL %lld %d %x/%x\n",vsc_count,sz,H0[16],H0[16+end]);
|
||||
UInt end = sizeof(MP_INT) / sizeof(CELL) + sz + 1;
|
||||
fprintf(stderr, "VAL %lld %d %x/%x\n", vsc_count, sz, H0[16],
|
||||
H0[16 + end]);
|
||||
}
|
||||
} else
|
||||
return;
|
||||
@ -213,17 +217,17 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
if (pt[140].term == 0 && pt[140].value != 0)
|
||||
jmp_deb(1);
|
||||
}
|
||||
if (worker_id != 04 || worker_id != 03) return;
|
||||
if (worker_id != 04 || worker_id != 03)
|
||||
return;
|
||||
// if (vsc_count == 218280)
|
||||
// vsc_xstop = 1;
|
||||
if (vsc_count < 1468068888) {
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
}
|
||||
if (port != enter_pred ||
|
||||
!pred ||
|
||||
pred->ArityOfPE != 4 ||
|
||||
strcmp(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE,"in_between_target_phrases")) {
|
||||
if (port != enter_pred || !pred || pred->ArityOfPE != 4 ||
|
||||
strcmp(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE,
|
||||
"in_between_target_phrases")) {
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
}
|
||||
@ -243,7 +247,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
}
|
||||
if (vsc_count == 123536441LL) vsc_xstop = 1;
|
||||
if (vsc_count == 123536441LL)
|
||||
vsc_xstop = 1;
|
||||
if (vsc_count < 5530257LL) {
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
@ -259,17 +264,14 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
jmp_deb(1);
|
||||
{
|
||||
tr_fr_ptr pt = (tr_fr_ptr)LOCAL_TrailBase;
|
||||
if (pt[153].term == 0 && pt[153].value == 0 &&
|
||||
pt[154].term != 0 && pt[154].value != 0 && ( TR > pt+154 ||
|
||||
TR_FZ > pt+154))
|
||||
if (pt[153].term == 0 && pt[153].value == 0 && pt[154].term != 0 &&
|
||||
pt[154].value != 0 && (TR > pt + 154 || TR_FZ > pt + 154))
|
||||
jmp_deb(2);
|
||||
if (pt[635].term == 0 && pt[635].value == 0 &&
|
||||
pt[636].term != 0 && pt[636].value != 0 && ( TR > pt+636 ||
|
||||
TR_FZ > pt+636))
|
||||
if (pt[635].term == 0 && pt[635].value == 0 && pt[636].term != 0 &&
|
||||
pt[636].value != 0 && (TR > pt + 636 || TR_FZ > pt + 636))
|
||||
jmp_deb(3);
|
||||
if (pt[138].term == 0 && pt[138].value == 0 &&
|
||||
pt[139].term != 0 && pt[139].value != 0 && ( TR > pt+138 ||
|
||||
TR_FZ > pt+138) )
|
||||
if (pt[138].term == 0 && pt[138].value == 0 && pt[139].term != 0 &&
|
||||
pt[139].value != 0 && (TR > pt + 138 || TR_FZ > pt + 138))
|
||||
jmp_deb(4);
|
||||
}
|
||||
if (vsc_count == 287939LL)
|
||||
@ -277,8 +279,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
if (vsc_count == 173118LL)
|
||||
jmp_deb(1);
|
||||
if (!(vsc_count >= 287934LL && vsc_count <= 287939LL) &&
|
||||
!(vsc_count >= 173100LL && vsc_count <= 173239LL) &&
|
||||
vsc_count != -1)
|
||||
!(vsc_count >= 173100LL && vsc_count <= 173239LL) && vsc_count != -1)
|
||||
return;
|
||||
if (vsc_count == 51021) {
|
||||
printf("Here I go\n");
|
||||
@ -287,7 +288,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
}
|
||||
if (vsc_count > 52000) exit(0);
|
||||
if (vsc_count > 52000)
|
||||
exit(0);
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
if (vsc_count == 837074) {
|
||||
@ -304,8 +306,9 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
while (env_ptr) {
|
||||
PredEntry *pe = EnvPreg(env_ptr[E_CP]);
|
||||
|
||||
printf("%p->",env_ptr,pe);
|
||||
if (vsc_count == 52LL) printf("\n");
|
||||
printf("%p->", env_ptr, pe);
|
||||
if (vsc_count == 52LL)
|
||||
printf("\n");
|
||||
if (p == pe) {
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
return;
|
||||
@ -316,9 +319,9 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr,"%lld ",vsc_count);
|
||||
fprintf(stderr, "%lld ", vsc_count);
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
fprintf(stderr,"(%d)", worker_id);
|
||||
fprintf(stderr, "(%d)", worker_id);
|
||||
#endif
|
||||
/* check_trail_consistency(); */
|
||||
if (pred == NULL) {
|
||||
@ -405,41 +408,34 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
}
|
||||
|
||||
void
|
||||
toggle_low_level_trace(void)
|
||||
{
|
||||
void toggle_low_level_trace(void) {
|
||||
Yap_do_low_level_trace = !Yap_do_low_level_trace;
|
||||
}
|
||||
|
||||
static Int start_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
static Int start_low_level_trace(USES_REGS1) {
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int total_choicepoints( USES_REGS1 )
|
||||
{
|
||||
return Yap_unify(MkIntegerTerm(LOCAL_total_choicepoints),ARG1);
|
||||
static Int total_choicepoints(USES_REGS1) {
|
||||
return Yap_unify(MkIntegerTerm(LOCAL_total_choicepoints), ARG1);
|
||||
}
|
||||
|
||||
static Int reset_total_choicepoints( USES_REGS1 )
|
||||
{
|
||||
static Int reset_total_choicepoints(USES_REGS1) {
|
||||
LOCAL_total_choicepoints = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int show_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
fprintf(stderr,"Call counter=%lld\n",vsc_count);
|
||||
return(TRUE);
|
||||
static Int show_low_level_trace(USES_REGS1) {
|
||||
fprintf(stderr, "Call counter=%lld\n", vsc_count);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#ifdef THREADS
|
||||
static Int start_low_level_trace2( USES_REGS1 )
|
||||
{
|
||||
thread_trace = IntegerOfTerm(Deref(ARG1))+1;
|
||||
static Int start_low_level_trace2(USES_REGS1) {
|
||||
thread_trace = IntegerOfTerm(Deref(ARG1)) + 1;
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -449,38 +445,36 @@ static Int start_low_level_trace2( USES_REGS1 )
|
||||
|
||||
Stop displaying messages at procedure entry and retry.
|
||||
|
||||
Note that using this compile-time option will slow down execution, even if messages are
|
||||
Note that using this compile-time option will slow down execution, even if
|
||||
messages are
|
||||
not being output.
|
||||
|
||||
*/
|
||||
static Int stop_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
static Int stop_low_level_trace(USES_REGS1) {
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
LOCAL_do_trace_primitives = TRUE;
|
||||
#if DEBUG_LOCKS
|
||||
debug_locks = TRUE;
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
volatile int v_wait;
|
||||
|
||||
static Int vsc_wait( USES_REGS1 )
|
||||
{
|
||||
while (!v_wait);
|
||||
static Int vsc_wait(USES_REGS1) {
|
||||
while (!v_wait)
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
static Int vsc_go( USES_REGS1 )
|
||||
{
|
||||
v_wait=1;
|
||||
static Int vsc_go(USES_REGS1) {
|
||||
v_wait = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Yap_InitLowLevelTrace(void)
|
||||
{
|
||||
Yap_InitCPred("start_low_level_trace", 0, start_low_level_trace, SafePredFlag);
|
||||
void Yap_InitLowLevelTrace(void) {
|
||||
Yap_InitCPred("start_low_level_trace", 0, start_low_level_trace,
|
||||
SafePredFlag);
|
||||
/** @pred start_low_level_trace
|
||||
|
||||
|
||||
@ -489,12 +483,14 @@ Begin display of messages at procedure entry and retry.
|
||||
|
||||
*/
|
||||
#if THREADS
|
||||
Yap_InitCPred("start_low_level_trace", 1, start_low_level_trace2, SafePredFlag);
|
||||
Yap_InitCPred("start_low_level_trace", 1, start_low_level_trace2,
|
||||
SafePredFlag);
|
||||
#endif
|
||||
Yap_InitCPred("stop_low_level_trace", 0, stop_low_level_trace, SafePredFlag);
|
||||
Yap_InitCPred("show_low_level_trace", 0, show_low_level_trace, SafePredFlag);
|
||||
Yap_InitCPred("total_choicepoints", 1, total_choicepoints, SafePredFlag);
|
||||
Yap_InitCPred("reset_total_choicepoints", 0, reset_total_choicepoints, SafePredFlag);
|
||||
Yap_InitCPred("reset_total_choicepoints", 0, reset_total_choicepoints,
|
||||
SafePredFlag);
|
||||
Yap_InitCPred("vsc_wait", 0, vsc_wait, SafePredFlag);
|
||||
Yap_InitCPred("vsc_go", 0, vsc_go, SafePredFlag);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
a
|
||||
|
||||
/*
|
||||
* This file is an entry for user defined C-predicates.
|
||||
*
|
||||
@ -51,8 +51,7 @@ a
|
||||
/* You should include here the prototypes for all static functions */
|
||||
|
||||
#ifdef EUROTRA
|
||||
static int
|
||||
p_clean(void);
|
||||
static int p_clean(void);
|
||||
static int p_namelength(void);
|
||||
static int p_getpid(void);
|
||||
static int p_exit(void);
|
||||
|
@ -4607,7 +4607,6 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
||||
{
|
||||
|
||||
register CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||
Int numbv0 = numbv;
|
||||
register tr_fr_ptr TR0 = TR;
|
||||
CELL *InitialH = HR;
|
||||
|
||||
|
51
C/write.c
51
C/write.c
@ -117,7 +117,8 @@ static void putAtom(Atom, int, struct write_globs *);
|
||||
static void writeTerm(Term, int, int, int, struct write_globs *,
|
||||
struct rewind_term *);
|
||||
|
||||
#define wrputc(WF, X) (X)->stream_wputc(X-GLOBAL_Stream, WF) /* writes a character */
|
||||
#define wrputc(WF, X) \
|
||||
(X)->stream_wputc(X - GLOBAL_Stream, WF) /* writes a character */
|
||||
|
||||
/*
|
||||
protect bracket from merging with previoous character.
|
||||
@ -181,10 +182,10 @@ static void wrputn(Int n,
|
||||
protect_close_number(wglb, ob);
|
||||
}
|
||||
|
||||
inline static void
|
||||
wrputs(char *s, StreamDesc *stream) {
|
||||
inline static void wrputs(char *s, StreamDesc *stream) {
|
||||
int c;
|
||||
while ((c = *s++)) wrputc(c, stream);
|
||||
while ((c = *s++))
|
||||
wrputc(c, stream);
|
||||
}
|
||||
|
||||
static void wrputws(wchar_t *s, wrf stream) /* writes a string */
|
||||
@ -375,7 +376,7 @@ static void wrputf(Float f, struct write_globs *wglb) /* writes a float */
|
||||
wrputc(' ', stream);
|
||||
}
|
||||
/* use SWI's format_float */
|
||||
sprintf(buf, (char *)floatFormat(),f);
|
||||
sprintf(buf, (char *)floatFormat(), f);
|
||||
|
||||
wrputs(buf, stream);
|
||||
#endif
|
||||
@ -388,10 +389,11 @@ int Yap_FormatFloat(Float f, char **s, size_t sz) {
|
||||
int sno;
|
||||
char *so;
|
||||
|
||||
sno = Yap_open_buf_write_stream(*s, sz, &GLOBAL_Stream[LOCAL_c_output_stream].encoding, 0);
|
||||
sno = Yap_open_buf_write_stream(
|
||||
*s, sz, &GLOBAL_Stream[LOCAL_c_output_stream].encoding, 0);
|
||||
if (sno < 0)
|
||||
return FALSE;
|
||||
wglb.stream = GLOBAL_Stream+sno;
|
||||
wglb.stream = GLOBAL_Stream + sno;
|
||||
wrputf(f, &wglb);
|
||||
so = Yap_MemExportStreamPtr(sno);
|
||||
Yap_CloseStream(sno);
|
||||
@ -420,7 +422,7 @@ static int wrputblob(AtomEntry *ref, int Quote_illegal,
|
||||
struct write_globs *wglb) {
|
||||
wrf stream = wglb->stream;
|
||||
int rc;
|
||||
int Yap_write_blob(AtomEntry *ref, StreamDesc *stream);
|
||||
int Yap_write_blob(AtomEntry * ref, StreamDesc * stream);
|
||||
|
||||
if ((rc = Yap_write_blob(ref, stream))) {
|
||||
return rc;
|
||||
@ -485,7 +487,8 @@ static void write_quoted(wchar_t ch, wchar_t quote, wrf stream) {
|
||||
wrputc('\'', stream); /* be careful about quotes */
|
||||
return;
|
||||
}
|
||||
if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\' && ch != '`') {
|
||||
if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\' &&
|
||||
ch != '`') {
|
||||
wrputc(ch, stream);
|
||||
} else {
|
||||
switch (ch) {
|
||||
@ -557,7 +560,7 @@ static void write_string(const unsigned char *s,
|
||||
{
|
||||
StreamDesc *stream = wglb->stream;
|
||||
utf8proc_int32_t chr, qt;
|
||||
unsigned char *ptr = (unsigned char *) s;
|
||||
unsigned char *ptr = (unsigned char *)s;
|
||||
|
||||
if (wglb->Write_strings)
|
||||
qt = '`';
|
||||
@ -912,7 +915,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
return;
|
||||
}
|
||||
if (wglb->Use_portray)
|
||||
if (callPortray(t, &EX, wglb->stream-GLOBAL_Stream PASS_REGS)) {
|
||||
if (callPortray(t, &EX, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
EX = oEX;
|
||||
return;
|
||||
}
|
||||
@ -986,7 +989,7 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
}
|
||||
#endif
|
||||
if (wglb->Use_portray) {
|
||||
if (callPortray(t, &EX, wglb->stream-GLOBAL_Stream PASS_REGS)) {
|
||||
if (callPortray(t, &EX, wglb->stream - GLOBAL_Stream PASS_REGS)) {
|
||||
EX = oEX;
|
||||
return;
|
||||
}
|
||||
@ -1200,7 +1203,8 @@ static void writeTerm(Term t, int p, int depth, int rinfixarg,
|
||||
EX = oEX;
|
||||
}
|
||||
|
||||
void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, int priority)
|
||||
void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags,
|
||||
int priority)
|
||||
/* term to be written */
|
||||
/* consumer */
|
||||
/* write options */
|
||||
@ -1212,7 +1216,7 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, int prio
|
||||
|
||||
if (!mywrite) {
|
||||
CACHE_REGS
|
||||
wglb.stream = GLOBAL_Stream+LOCAL_c_error_stream;
|
||||
wglb.stream = GLOBAL_Stream + LOCAL_c_error_stream;
|
||||
} else
|
||||
wglb.stream = mywrite;
|
||||
wglb.lw = start;
|
||||
@ -1246,13 +1250,11 @@ void Yap_plwrite(Term t, StreamDesc *mywrite, int max_depth, int flags, int prio
|
||||
}
|
||||
}
|
||||
restore_from_write(&rwt, &wglb);
|
||||
Yap_CloseSlots( sls );
|
||||
Yap_CloseSlots(sls);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
Yap_TermToString(Term t, char *s, size_t sz, size_t *length, encoding_t *encp, int flags)
|
||||
{
|
||||
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length,
|
||||
encoding_t *encp, int flags) {
|
||||
CACHE_REGS
|
||||
int sno = Yap_open_buf_write_stream(s, sz, encp, flags);
|
||||
int old_output_stream = LOCAL_c_output_stream;
|
||||
@ -1264,12 +1266,11 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, encoding_t *encp,
|
||||
GLOBAL_Stream[sno].encoding = *encp;
|
||||
else
|
||||
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||
Yap_plwrite (t, GLOBAL_Stream+sno, 0, flags, 1200);
|
||||
s = Yap_MemExportStreamPtr( sno );
|
||||
Yap_CloseStream( sno );
|
||||
Yap_plwrite(t, GLOBAL_Stream + sno, 0, flags, 1200);
|
||||
s = Yap_MemExportStreamPtr(sno);
|
||||
Yap_CloseStream(sno);
|
||||
LOCAL_c_output_stream = old_output_stream;
|
||||
if ( EX == 0 ) return s;
|
||||
if (EX == 0)
|
||||
return s;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user