Merge branch 'master' of ssh://git.dcc.fc.up.pt/yap-6.3

This commit is contained in:
Vitor Santos Costa 2014-06-11 19:45:21 +01:00
commit 489bb27a7e
103 changed files with 5484 additions and 4122 deletions

1780
C/absmi.c

File diff suppressed because it is too large Load Diff

592
C/amasm.c

File diff suppressed because it is too large Load Diff

View File

@ -407,63 +407,63 @@ For implementation details and more information, please check term_t_slots in th
/// @brief report the current position of the slots, assuming that they occupy the top of the stack. /// @brief report the current position of the slots, assuming that they occupy the top of the stack.
/// ///
/// ///
X_API Int YAP_CurrentSlot(void); X_API handle_t YAP_CurrentSlot(void);
/// @brief allocate n empty new slots /// @brief allocate n empty new slots
/// ///
/// Return a handle to the system's default slot. /// Return a handle to the system's default slot.
X_API Int YAP_NewSlots(int NumberOfSlots); X_API handle_t YAP_NewSlots(int NumberOfSlots);
/// @brief allocate n empty new slots /// @brief allocate n empty new slots
/// ///
/// Allocate _NumberOfSlots_ from the stack and return an handle to the /// Allocate _NumberOfSlots_ from the stack and return an handle to the
/// last one. The other handle can be obtained by decrementing the handle. /// last one. The other handle can be obtained by decrementing the handle.
X_API Int YAP_InitSlot(YAP_Term t); X_API handle_t YAP_InitSlot(YAP_Term t);
/// @brief read from a slot. /// @brief read from a slot.
/// ///
/// ///
X_API YAP_Term YAP_GetFromSlot(YAP_Int slot); X_API YAP_Term YAP_GetFromSlot(YAP_handle_t slot);
/// @brief get the memory address of a slot /// @brief get the memory address of a slot
/// ///
/// Return the address of slot _slot_: please use with care. /// Return the address of slot _slot_: please use with care.
X_API YAP_Term *YAP_AddressFromSlot(YAP_Int); X_API YAP_Term *YAP_AddressFromSlot(YAP_handle_t);
/// @brief get the memory address of the term actually stored in a slot /// @brief get the memory address of the term actually stored in a slot
/// ///
/// ///
X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_Int); X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_handle_t);
/// @brief store term in a slot /// @brief store term in a slot
/// ///
/// ///
X_API void YAP_PutInSlot(YAP_Int slot, YAP_Term t); X_API void YAP_PutInSlot(YAP_handle_t slot, YAP_Term t);
/// @brief Succeeds if it recovers the space allocated for $n$ contiguous slots starting at topSlot. /// @brief Succeeds if it recovers the space allocated for $n$ contiguous slots starting at topSlot.
/// ///
/// Set the contents of slot _slot_ to _t_. /// Set the contents of slot _slot_ to _t_.
X_API int YAP_RecoverSlots(int, YAP_Int topSlot); X_API int YAP_RecoverSlots(int, YAP_handle_t topSlot);
/// @brief copies the first new n YAAM registers to slots /// @brief copies the first new n YAAM registers to slots
/// ///
/// Store the current first _HowMany_ arguments in new slots. /// Store the current first _HowMany_ arguments in new slots.
X_API YAP_Int YAP_ArgsToSlots(int HowMany); X_API YAP_handle_t YAP_ArgsToSlots(int HowMany);
/// @brief copies n slots such that sl is copied to the last abstract ,achine register. /// @brief copies n slots such that sl is copied to the last abstract ,achine register.
/// ///
/// Set the first _HowMany_ arguments to the _HowMany_ slots /// Set the first _HowMany_ arguments to the _HowMany_ slots
// starting at _slot_. // starting at _slot_.
X_API void YAP_SlotsToArgs(int HowMany, YAP_Int slot); X_API void YAP_SlotsToArgs(int HowMany, YAP_handle_t slot);
/// @} /// @}
static UInt static arity_t
current_arity(void) current_arity(void)
{ {
CACHE_REGS CACHE_REGS
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) { if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
return PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE; return PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
} else { } else {
return 0; return 0;
} }
@ -476,7 +476,7 @@ doexpand(UInt sz)
UInt arity; UInt arity;
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) { if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
arity = PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE; arity = PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
} else { } else {
arity = 0; arity = 0;
} }
@ -1068,7 +1068,7 @@ YAP_ExtraSpaceCut(void)
void *ptr; void *ptr;
BACKUP_B(); BACKUP_B();
ptr = (void *)(((CELL *)(Yap_REGS.CUT_C_TOP))-(((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.OtapFs.extra)); ptr = (void *)(((CELL *)(Yap_REGS.CUT_C_TOP))-(((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->y_u.OtapFs.extra));
RECOVER_B(); RECOVER_B();
return(ptr); return(ptr);
@ -1083,7 +1083,7 @@ YAP_ExtraSpace(void)
BACKUP_H(); BACKUP_H();
/* find a pointer to extra space allocable */ /* find a pointer to extra space allocable */
ptr = (void *)((CELL *)(B+1)+P->u.OtapFs.s); ptr = (void *)((CELL *)(B+1)+P->y_u.OtapFs.s);
B->cp_h = HR; B->cp_h = HR;
RECOVER_H(); RECOVER_H();
@ -2294,15 +2294,20 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
dgi->cp = CP; dgi->cp = CP;
dgi->CurSlot = LOCAL_CurSlot; dgi->CurSlot = LOCAL_CurSlot;
// ensure our current ENV receives current P. // ensure our current ENV receives current P.
Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS); Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS);
P = pe->CodeOfPred; P = pe->CodeOfPred;
dgi->b = LCL0-(CELL*)B; dgi->b = LCL0-(CELL*)B;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL IN Yap_regp=%p LCL0=(%p) %x", &Yap_REGS, LCL0, LCL0[-15]) ; }
out = run_emulator(dgi PASS_REGS); out = run_emulator(dgi PASS_REGS);
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE Yap_regp=%p LCL0=(%p) %x", &Yap_REGS, LCL0, LCL0[-15]) ; }
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
if (out) { if (out) {
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
Yap_StartSlots( PASS_REGS1 ); Yap_StartSlots( PASS_REGS1 );
} else {
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
} }
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE %d", out) ; }
return out; return out;
} }
@ -2986,6 +2991,7 @@ YAP_Init(YAP_init_args *yap_init)
if (initialised) if (initialised)
return YAP_BOOT_DONE_BEFOREHAND; return YAP_BOOT_DONE_BEFOREHAND;
initialised = TRUE; initialised = TRUE;
__android_log_print(ANDROID_LOG_INFO, "c_interface.c", "entered init %p", yap_init);
Yap_InitPageSize(); /* init memory page size, required by later functions */ Yap_InitPageSize(); /* init memory page size, required by later functions */
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) #if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
@ -3065,6 +3071,7 @@ YAP_Init(YAP_init_args *yap_init)
if (restore_result == FAIL_RESTORE) { if (restore_result == FAIL_RESTORE) {
yap_init->ErrorNo = LOCAL_Error_TYPE; yap_init->ErrorNo = LOCAL_Error_TYPE;
yap_init->ErrorCause = LOCAL_ErrorMessage; yap_init->ErrorCause = LOCAL_ErrorMessage;
__android_log_print(ANDROID_LOG_INFO, __FILE__, "restore failed, %s ", LOCAL_ErrorMessage);
/* shouldn't RECOVER_MACHINE_REGS(); be here ??? */ /* shouldn't RECOVER_MACHINE_REGS(); be here ??? */
return YAP_BOOT_ERROR; return YAP_BOOT_ERROR;
} }
@ -3101,6 +3108,7 @@ YAP_Init(YAP_init_args *yap_init)
#endif /* YAPOR */ #endif /* YAPOR */
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
} }
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %p", yap_init);
/* make sure we do this after restore */ /* make sure we do this after restore */
if (yap_init->MaxStackSize) { if (yap_init->MaxStackSize) {
GLOBAL_AllowLocalExpansion = FALSE; GLOBAL_AllowLocalExpansion = FALSE;
@ -3117,7 +3125,7 @@ YAP_Init(YAP_init_args *yap_init)
} else { } else {
GLOBAL_AllowTrailExpansion = TRUE; GLOBAL_AllowTrailExpansion = TRUE;
} }
if (yap_init->YapPrologRCFile) { if (yap_init->YapPrologRCFile) {
Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile))); Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
/* /*
This must be done again after restore, as yap_flags This must be done again after restore, as yap_flags
@ -3125,6 +3133,7 @@ YAP_Init(YAP_init_args *yap_init)
*/ */
yap_flags[HALT_AFTER_CONSULT_FLAG] = yap_init->HaltAfterConsult; yap_flags[HALT_AFTER_CONSULT_FLAG] = yap_init->HaltAfterConsult;
} }
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %s",yap_init->YapPrologRCFile);
if (yap_init->YapPrologTopLevelGoal) { if (yap_init->YapPrologTopLevelGoal) {
Yap_PutValue(AtomTopLevelGoal, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologTopLevelGoal))); Yap_PutValue(AtomTopLevelGoal, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologTopLevelGoal)));
} }
@ -3137,6 +3146,7 @@ YAP_Init(YAP_init_args *yap_init)
if (yap_init->QuietMode) { if (yap_init->QuietMode) {
yap_flags[QUIET_MODE_FLAG] = TRUE; yap_flags[QUIET_MODE_FLAG] = TRUE;
} }
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after setting startup ");
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) { if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
if (restore_result == FAIL_RESTORE) { if (restore_result == FAIL_RESTORE) {
yap_init->ErrorNo = LOCAL_Error_TYPE; yap_init->ErrorNo = LOCAL_Error_TYPE;
@ -3152,9 +3162,11 @@ YAP_Init(YAP_init_args *yap_init)
if (restore_result == DO_ONLY_CODE) { if (restore_result == DO_ONLY_CODE) {
/* first, initialise the saved state */ /* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomInitProlog); Term t_goal = MkAtomTerm(AtomInitProlog);
YAP_RunGoalOnce(t_goal); __android_log_print(ANDROID_LOG_INFO, __FILE__, "restore init goal ");
YAP_RunGoalOnce(t_goal);
Yap_InitYaamRegs( 0 ); Yap_InitYaamRegs( 0 );
return YAP_BOOT_FROM_SAVED_CODE; __android_log_print(ANDROID_LOG_INFO, __FILE__, "restore done, loaded startup ");
return YAP_BOOT_FROM_SAVED_CODE;
} else { } else {
return YAP_BOOT_FROM_SAVED_STACKS; return YAP_BOOT_FROM_SAVED_STACKS;
} }
@ -3566,7 +3578,7 @@ X_API char *
YAP_cwd(void) YAP_cwd(void)
{ {
CACHE_REGS CACHE_REGS
char *buf; char *buf = NULL;
int len; int len;
if (!Yap_getcwd(LOCAL_FileNameBuf, YAP_FILENAME_MAX)) if (!Yap_getcwd(LOCAL_FileNameBuf, YAP_FILENAME_MAX))
return FALSE; return FALSE;
@ -3880,11 +3892,11 @@ YAP_Erase(void *handle)
return 1; return 1;
} }
X_API Int X_API handle_t
YAP_ArgsToSlots(int n) YAP_ArgsToSlots(int n)
{ {
CACHE_REGS CACHE_REGS
Int slot = Yap_NewSlots(n PASS_REGS); handle_t slot = Yap_NewSlots(n PASS_REGS);
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1; CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
while (n--) { while (n--) {
*ptr0++ = *ptr1++; *ptr0++ = *ptr1++;
@ -3893,7 +3905,7 @@ YAP_ArgsToSlots(int n)
} }
X_API void X_API void
YAP_SlotsToArgs(int n, Int slot) YAP_SlotsToArgs(int n, handle_t slot)
{ {
CACHE_REGS CACHE_REGS
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1; CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
@ -3935,8 +3947,8 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
} }
/* Int YAP_VarSlotToNumber(Int) */ /* handle_t YAP_VarSlotToNumber(handle_t) */
Int YAP_VarSlotToNumber(Int s) { handle_t YAP_VarSlotToNumber(handle_t s) {
CACHE_REGS CACHE_REGS
Term *t = (CELL *)Deref(Yap_GetFromSlot(s PASS_REGS)); Term *t = (CELL *)Deref(Yap_GetFromSlot(s PASS_REGS));
if (t < HR) if (t < HR)
@ -3950,7 +3962,7 @@ Term YAP_ModuleUser(void) {
} }
/* int YAP_PredicateHasClauses() */ /* int YAP_PredicateHasClauses() */
Int YAP_NumberOfClausesForPredicate(PredEntry *pe) { handle_t YAP_NumberOfClausesForPredicate(PredEntry *pe) {
return pe->cs.p_code.NOfClauses; return pe->cs.p_code.NOfClauses;
} }

248
C/cdmgr.c
View File

@ -537,14 +537,14 @@ PredForChoicePt(yamop *p_code) {
case _Nstop: case _Nstop:
return NULL; return NULL;
case _jump: case _jump:
p_code = p_code->u.l.l; p_code = p_code->y_u.l.l;
break; break;
case _retry_me: case _retry_me:
case _trust_me: case _trust_me:
return p_code->u.Otapl.p; return p_code->y_u.Otapl.p;
case _retry_exo: case _retry_exo:
case _retry_all_exo: case _retry_all_exo:
return p_code->u.lp.p; return p_code->y_u.lp.p;
case _try_logical: case _try_logical:
case _retry_logical: case _retry_logical:
case _trust_logical: case _trust_logical:
@ -552,7 +552,7 @@ PredForChoicePt(yamop *p_code) {
case _count_trust_logical: case _count_trust_logical:
case _profiled_retry_logical: case _profiled_retry_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
return p_code->u.OtaLl.d->ClPred; return p_code->y_u.OtaLl.d->ClPred;
#ifdef TABLING #ifdef TABLING
case _trie_trust_var: case _trie_trust_var:
case _trie_retry_var: case _trie_retry_var:
@ -596,19 +596,19 @@ PredForChoicePt(yamop *p_code) {
/* compile error --> return ENV_ToP(gc_B->cp_cp); */ /* compile error --> return ENV_ToP(gc_B->cp_cp); */
#endif /* TABLING */ #endif /* TABLING */
case _or_else: case _or_else:
if (p_code == p_code->u.Osblp.l) { if (p_code == p_code->y_u.Osblp.l) {
/* repeat */ /* repeat */
Atom at = AtomRepeatSpace; Atom at = AtomRepeatSpace;
return RepPredProp(PredPropByAtom(at, PROLOG_MODULE)); return RepPredProp(PredPropByAtom(at, PROLOG_MODULE));
} else { } else {
return p_code->u.Osblp.p0; return p_code->y_u.Osblp.p0;
} }
break; break;
case _or_last: case _or_last:
#ifdef YAPOR #ifdef YAPOR
return p_code->u.Osblp.p0; return p_code->y_u.Osblp.p0;
#else #else
return p_code->u.p.p; return p_code->y_u.p.p;
#endif /* YAPOR */ #endif /* YAPOR */
break; break;
case _count_retry_me: case _count_retry_me:
@ -619,7 +619,7 @@ PredForChoicePt(yamop *p_code) {
p_code = NEXTOP(p_code,l); p_code = NEXTOP(p_code,l);
break; break;
default: default:
return p_code->u.Otapl.p; return p_code->y_u.Otapl.p;
} }
} }
return NULL; return NULL;
@ -1040,7 +1040,7 @@ Yap_IPred(PredEntry *p, UInt NSlots, yamop *next_pc)
IPred(p, NSlots, next_pc); IPred(p, NSlots, next_pc);
} }
#define GONEXT(TYPE) code_p = ((yamop *)(&(code_p->u.TYPE.next))) #define GONEXT(TYPE) code_p = ((yamop *)(&(code_p->y_u.TYPE.next)))
static void static void
RemoveMainIndex(PredEntry *ap) RemoveMainIndex(PredEntry *ap)
@ -1097,29 +1097,29 @@ static yamop *
release_wcls(yamop *cop, OPCODE ecs) release_wcls(yamop *cop, OPCODE ecs)
{ {
if (cop->opc == ecs) { if (cop->opc == ecs) {
cop->u.sssllp.s3--; cop->y_u.sssllp.s3--;
if (!cop->u.sssllp.s3) { if (!cop->y_u.sssllp.s3) {
UInt sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+cop->u.sssllp.s1*sizeof(yamop *); UInt sz = (UInt)NEXTOP((yamop *)NULL,sssllp)+cop->y_u.sssllp.s1*sizeof(yamop *);
LOCK(ExpandClausesListLock); LOCK(ExpandClausesListLock);
#ifdef DEBUG #ifdef DEBUG
Yap_expand_clauses_sz -= sz; Yap_expand_clauses_sz -= sz;
Yap_ExpandClauses--; Yap_ExpandClauses--;
#endif #endif
if (cop->u.sssllp.p->PredFlags & LogUpdatePredFlag) { if (cop->y_u.sssllp.p->PredFlags & LogUpdatePredFlag) {
Yap_LUIndexSpace_EXT -= sz; Yap_LUIndexSpace_EXT -= sz;
} else { } else {
Yap_IndexSpace_EXT -= sz; Yap_IndexSpace_EXT -= sz;
} }
if (ExpandClausesFirst == cop) if (ExpandClausesFirst == cop)
ExpandClausesFirst = cop->u.sssllp.snext; ExpandClausesFirst = cop->y_u.sssllp.snext;
if (ExpandClausesLast == cop) { if (ExpandClausesLast == cop) {
ExpandClausesLast = cop->u.sssllp.sprev; ExpandClausesLast = cop->y_u.sssllp.sprev;
} }
if (cop->u.sssllp.sprev) { if (cop->y_u.sssllp.sprev) {
cop->u.sssllp.sprev->u.sssllp.snext = cop->u.sssllp.snext; cop->y_u.sssllp.sprev->y_u.sssllp.snext = cop->y_u.sssllp.snext;
} }
if (cop->u.sssllp.snext) { if (cop->y_u.sssllp.snext) {
cop->u.sssllp.snext->u.sssllp.sprev = cop->u.sssllp.sprev; cop->y_u.sssllp.snext->y_u.sssllp.sprev = cop->y_u.sssllp.sprev;
} }
UNLOCK(ExpandClausesListLock); UNLOCK(ExpandClausesListLock);
Yap_InformOfRemoval(cop); Yap_InformOfRemoval(cop);
@ -1163,12 +1163,12 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _retry2: case _retry2:
case _retry3: case _retry3:
case _retry4: case _retry4:
decrease_ref_counter(ipc->u.l.l, beg, end, suspend_code); decrease_ref_counter(ipc->y_u.l.l, beg, end, suspend_code);
ipc = NEXTOP(ipc,l); ipc = NEXTOP(ipc,l);
break; break;
case _retry: case _retry:
case _trust: case _trust:
decrease_ref_counter(ipc->u.Otapl.d, beg, end, suspend_code); decrease_ref_counter(ipc->y_u.Otapl.d, beg, end, suspend_code);
ipc = NEXTOP(ipc,Otapl); ipc = NEXTOP(ipc,Otapl);
break; break;
case _try_clause: case _try_clause:
@ -1185,8 +1185,8 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _profiled_retry_logical: case _profiled_retry_logical:
{ {
yamop *oipc = ipc; yamop *oipc = ipc;
decrease_ref_counter(ipc->u.OtaLl.d->ClCode, beg, end, suspend_code); decrease_ref_counter(ipc->y_u.OtaLl.d->ClCode, beg, end, suspend_code);
ipc = ipc->u.OtaLl.n; ipc = ipc->y_u.OtaLl.n;
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtaLl); Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtaLl);
Yap_FreeCodeSpace((ADDR)oipc); Yap_FreeCodeSpace((ADDR)oipc);
#ifdef DEBUG #ifdef DEBUG
@ -1202,35 +1202,35 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
Yap_DirtyCps--; Yap_DirtyCps--;
Yap_FreedCps++; Yap_FreedCps++;
#endif #endif
decrease_ref_counter(ipc->u.OtILl.d->ClCode, beg, end, suspend_code); decrease_ref_counter(ipc->y_u.OtILl.d->ClCode, beg, end, suspend_code);
Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtILl); Yap_LUIndexSpace_CP -= (UInt)NEXTOP((yamop *)NULL,OtILl);
Yap_FreeCodeSpace((ADDR)ipc); Yap_FreeCodeSpace((ADDR)ipc);
return; return;
case _enter_lu_pred: case _enter_lu_pred:
{ {
yamop *oipc = ipc; yamop *oipc = ipc;
if (ipc->u.Illss.I->ClFlags & InUseMask || ipc->u.Illss.I->ClRefCount) if (ipc->y_u.Illss.I->ClFlags & InUseMask || ipc->y_u.Illss.I->ClRefCount)
return; return;
#ifdef DEBUG #ifdef DEBUG
Yap_DirtyCps+=ipc->u.Illss.s; Yap_DirtyCps+=ipc->y_u.Illss.s;
Yap_LiveCps-=ipc->u.Illss.s; Yap_LiveCps-=ipc->y_u.Illss.s;
#endif #endif
ipc = ipc->u.Illss.l1; ipc = ipc->y_u.Illss.l1;
/* in case we visit again */ /* in case we visit again */
oipc->u.Illss.l1 = FAILCODE; oipc->y_u.Illss.l1 = FAILCODE;
oipc->u.Illss.s = 0; oipc->y_u.Illss.s = 0;
oipc->u.Illss.e = 0; oipc->y_u.Illss.e = 0;
} }
break; break;
case _try_in: case _try_in:
case _jump: case _jump:
case _jump_if_var: case _jump_if_var:
ipc->u.l.l = release_wcls(ipc->u.l.l, ecs); ipc->y_u.l.l = release_wcls(ipc->y_u.l.l, ecs);
ipc = NEXTOP(ipc,l); ipc = NEXTOP(ipc,l);
break; break;
/* instructions type xl */ /* instructions type xl */
case _jump_if_nonvar: case _jump_if_nonvar:
ipc->u.xll.l1 = release_wcls(ipc->u.xll.l1, ecs); ipc->y_u.xll.l1 = release_wcls(ipc->y_u.xll.l1, ecs);
ipc = NEXTOP(ipc,xll); ipc = NEXTOP(ipc,xll);
break; break;
/* instructions type p */ /* instructions type p */
@ -1239,31 +1239,31 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
break; break;
/* instructions type e */ /* instructions type e */
case _switch_on_type: case _switch_on_type:
ipc->u.llll.l1 = release_wcls(ipc->u.llll.l1, ecs); ipc->y_u.llll.l1 = release_wcls(ipc->y_u.llll.l1, ecs);
ipc->u.llll.l2 = release_wcls(ipc->u.llll.l2, ecs); ipc->y_u.llll.l2 = release_wcls(ipc->y_u.llll.l2, ecs);
ipc->u.llll.l3 = release_wcls(ipc->u.llll.l3, ecs); ipc->y_u.llll.l3 = release_wcls(ipc->y_u.llll.l3, ecs);
ipc->u.llll.l4 = release_wcls(ipc->u.llll.l4, ecs); ipc->y_u.llll.l4 = release_wcls(ipc->y_u.llll.l4, ecs);
ipc = NEXTOP(ipc,llll); ipc = NEXTOP(ipc,llll);
break; break;
case _switch_list_nl: case _switch_list_nl:
ipc->u.ollll.l1 = release_wcls(ipc->u.ollll.l1, ecs); ipc->y_u.ollll.l1 = release_wcls(ipc->y_u.ollll.l1, ecs);
ipc->u.ollll.l2 = release_wcls(ipc->u.ollll.l2, ecs); ipc->y_u.ollll.l2 = release_wcls(ipc->y_u.ollll.l2, ecs);
ipc->u.ollll.l3 = release_wcls(ipc->u.ollll.l3, ecs); ipc->y_u.ollll.l3 = release_wcls(ipc->y_u.ollll.l3, ecs);
ipc->u.ollll.l4 = release_wcls(ipc->u.ollll.l4, ecs); ipc->y_u.ollll.l4 = release_wcls(ipc->y_u.ollll.l4, ecs);
ipc = NEXTOP(ipc,ollll); ipc = NEXTOP(ipc,ollll);
break; break;
case _switch_on_arg_type: case _switch_on_arg_type:
ipc->u.xllll.l1 = release_wcls(ipc->u.xllll.l1, ecs); ipc->y_u.xllll.l1 = release_wcls(ipc->y_u.xllll.l1, ecs);
ipc->u.xllll.l2 = release_wcls(ipc->u.xllll.l2, ecs); ipc->y_u.xllll.l2 = release_wcls(ipc->y_u.xllll.l2, ecs);
ipc->u.xllll.l3 = release_wcls(ipc->u.xllll.l3, ecs); ipc->y_u.xllll.l3 = release_wcls(ipc->y_u.xllll.l3, ecs);
ipc->u.xllll.l4 = release_wcls(ipc->u.xllll.l4, ecs); ipc->y_u.xllll.l4 = release_wcls(ipc->y_u.xllll.l4, ecs);
ipc = NEXTOP(ipc,xllll); ipc = NEXTOP(ipc,xllll);
break; break;
case _switch_on_sub_arg_type: case _switch_on_sub_arg_type:
ipc->u.sllll.l1 = release_wcls(ipc->u.sllll.l1, ecs); ipc->y_u.sllll.l1 = release_wcls(ipc->y_u.sllll.l1, ecs);
ipc->u.sllll.l2 = release_wcls(ipc->u.sllll.l2, ecs); ipc->y_u.sllll.l2 = release_wcls(ipc->y_u.sllll.l2, ecs);
ipc->u.sllll.l3 = release_wcls(ipc->u.sllll.l3, ecs); ipc->y_u.sllll.l3 = release_wcls(ipc->y_u.sllll.l3, ecs);
ipc->u.sllll.l4 = release_wcls(ipc->u.sllll.l4, ecs); ipc->y_u.sllll.l4 = release_wcls(ipc->y_u.sllll.l4, ecs);
ipc = NEXTOP(ipc,sllll); ipc = NEXTOP(ipc,sllll);
break; break;
case _if_not_then: case _if_not_then:
@ -1276,7 +1276,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
case _if_cons: case _if_cons:
case _go_on_cons: case _go_on_cons:
/* make sure we don't leave dangling references to memory that is going to be removed */ /* make sure we don't leave dangling references to memory that is going to be removed */
ipc->u.sssl.l = NULL; ipc->y_u.sssl.l = NULL;
ipc = NEXTOP(ipc,sssl); ipc = NEXTOP(ipc,sssl);
break; break;
case _op_fail: case _op_fail:
@ -1755,9 +1755,9 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
p->OpcodeOfPred = ncp->opc = Yap_opcode(_spy_or_trymark); p->OpcodeOfPred = ncp->opc = Yap_opcode(_spy_or_trymark);
else else
p->OpcodeOfPred = ncp->opc = Yap_opcode(_try_and_mark); p->OpcodeOfPred = ncp->opc = Yap_opcode(_try_and_mark);
ncp->u.Otapl.s = p->ArityOfPE; ncp->y_u.Otapl.s = p->ArityOfPE;
ncp->u.Otapl.p = p; ncp->y_u.Otapl.p = p;
ncp->u.Otapl.d = cp; ncp->y_u.Otapl.d = cp;
/* This is the point we enter the code */ /* This is the point we enter the code */
p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = ncp; p->cs.p_code.TrueCodeOfPred = p->CodeOfPred = ncp;
p->cs.p_code.NOfClauses = 1; p->cs.p_code.NOfClauses = 1;
@ -1777,9 +1777,9 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
cp->opc = Yap_opcode(_count_retry_and_mark); cp->opc = Yap_opcode(_count_retry_and_mark);
else else
cp->opc = Yap_opcode(_retry_and_mark); cp->opc = Yap_opcode(_retry_and_mark);
cp->u.Otapl.s = p->ArityOfPE; cp->y_u.Otapl.s = p->ArityOfPE;
cp->u.Otapl.p = p; cp->y_u.Otapl.p = p;
cp->u.Otapl.d = ncp; cp->y_u.Otapl.d = ncp;
/* also, keep a backpointer for the days you delete the clause */ /* also, keep a backpointer for the days you delete the clause */
ClauseCodeToDynamicClause(cp)->ClPrevious = ncp; ClauseCodeToDynamicClause(cp)->ClPrevious = ncp;
/* Don't forget to say who is the only clause for the predicate so /* Don't forget to say who is the only clause for the predicate so
@ -1796,7 +1796,7 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
/* and close the code */ /* and close the code */
ncp = NEXTOP(ncp,e); ncp = NEXTOP(ncp,e);
ncp->opc = Yap_opcode(_Ystop); ncp->opc = Yap_opcode(_Ystop);
ncp->u.l.l = cl->ClCode; ncp->y_u.l.l = cl->ClCode;
} }
/* p is already locked */ /* p is already locked */
@ -1840,7 +1840,7 @@ asserta_stat_clause(PredEntry *p, yamop *q, int spy_flag)
p->OpcodeOfPred = INDEX_OPCODE; p->OpcodeOfPred = INDEX_OPCODE;
p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred)); p->CodeOfPred = (yamop *)(&(p->OpcodeOfPred));
} }
p->cs.p_code.LastClause->u.Otapl.d = q; p->cs.p_code.LastClause->y_u.Otapl.d = q;
} }
/* p is already locked */ /* p is already locked */
@ -1856,22 +1856,22 @@ asserta_dynam_clause(PredEntry *p, yamop *cp)
cl->ClPrevious = (yamop *)(p->CodeOfPred); cl->ClPrevious = (yamop *)(p->CodeOfPred);
cl->ClFlags |= DynamicMask; cl->ClFlags |= DynamicMask;
UNLOCK(ClauseCodeToDynamicClause(p->cs.p_code.FirstClause)->ClLock); UNLOCK(ClauseCodeToDynamicClause(p->cs.p_code.FirstClause)->ClLock);
q->u.Otapl.d = p->cs.p_code.FirstClause; q->y_u.Otapl.d = p->cs.p_code.FirstClause;
q->u.Otapl.s = p->ArityOfPE; q->y_u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p; q->y_u.Otapl.p = p;
if (p->PredFlags & ProfiledPredFlag) if (p->PredFlags & ProfiledPredFlag)
cp->opc = Yap_opcode(_profiled_retry_and_mark); cp->opc = Yap_opcode(_profiled_retry_and_mark);
else if (p->PredFlags & CountPredFlag) else if (p->PredFlags & CountPredFlag)
cp->opc = Yap_opcode(_count_retry_and_mark); cp->opc = Yap_opcode(_count_retry_and_mark);
else else
cp->opc = Yap_opcode(_retry_and_mark); cp->opc = Yap_opcode(_retry_and_mark);
cp->u.Otapl.s = p->ArityOfPE; cp->y_u.Otapl.s = p->ArityOfPE;
cp->u.Otapl.p = p; cp->y_u.Otapl.p = p;
p->cs.p_code.FirstClause = cp; p->cs.p_code.FirstClause = cp;
q = p->CodeOfPred; q = p->CodeOfPred;
q->u.Otapl.d = cp; q->y_u.Otapl.d = cp;
q->u.Otapl.s = p->ArityOfPE; q->y_u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p; q->y_u.Otapl.p = p;
} }
@ -1931,7 +1931,7 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
q = p->cs.p_code.LastClause; q = p->cs.p_code.LastClause;
LOCK(ClauseCodeToDynamicClause(q)->ClLock); LOCK(ClauseCodeToDynamicClause(q)->ClLock);
q->u.Otapl.d = cp; q->y_u.Otapl.d = cp;
p->cs.p_code.LastClause = cp; p->cs.p_code.LastClause = cp;
/* also, keep backpointers for the days we'll delete all the clause */ /* also, keep backpointers for the days we'll delete all the clause */
cl->ClPrevious = q; cl->ClPrevious = q;
@ -1944,9 +1944,9 @@ assertz_dynam_clause(PredEntry *p, yamop *cp)
q->opc = Yap_opcode(_count_retry_and_mark); q->opc = Yap_opcode(_count_retry_and_mark);
else else
q->opc = Yap_opcode(_retry_and_mark); q->opc = Yap_opcode(_retry_and_mark);
q->u.Otapl.d = p->CodeOfPred; q->y_u.Otapl.d = p->CodeOfPred;
q->u.Otapl.s = p->ArityOfPE; q->y_u.Otapl.s = p->ArityOfPE;
q->u.Otapl.p = p; q->y_u.Otapl.p = p;
p->cs.p_code.NOfClauses++; p->cs.p_code.NOfClauses++;
} }
@ -3553,16 +3553,16 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
if (p->PredFlags & LogUpdatePredFlag) { if (p->PredFlags & LogUpdatePredFlag) {
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(code_beg); LogUpdIndex *cl = ClauseCodeToLogUpdIndex(code_beg);
if (find_owner_log_index(cl, code_p)) if (find_owner_log_index(cl, code_p))
b_ptr->cp_ap = cur_log_upd_clause(pe, b_ptr->cp_ap->u.Otapl.d); b_ptr->cp_ap = cur_log_upd_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
} else if (p->PredFlags & MegaClausePredFlag) { } else if (p->PredFlags & MegaClausePredFlag) {
StaticIndex *cl = ClauseCodeToStaticIndex(code_beg); StaticIndex *cl = ClauseCodeToStaticIndex(code_beg);
if (find_owner_static_index(cl, code_p)) if (find_owner_static_index(cl, code_p))
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->u.Otapl.d); b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
} else { } else {
/* static clause */ /* static clause */
StaticIndex *cl = ClauseCodeToStaticIndex(code_beg); StaticIndex *cl = ClauseCodeToStaticIndex(code_beg);
if (find_owner_static_index(cl, code_p)) { if (find_owner_static_index(cl, code_p)) {
b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->u.Otapl.d); b_ptr->cp_ap = cur_clause(pe, b_ptr->cp_ap->y_u.Otapl.d);
} }
} }
} }
@ -4151,7 +4151,7 @@ found_idb_clause(yamop *pc, CODEADDR *startp, CODEADDR *endp)
static PredEntry * static PredEntry *
found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr USES_REGS) found_expand_index(yamop *pc, CODEADDR *startp, CODEADDR *endp, yamop *codeptr USES_REGS)
{ {
PredEntry *pp = codeptr->u.sssllp.p; PredEntry *pp = codeptr->y_u.sssllp.p;
if (pc == codeptr) { if (pc == codeptr) {
*startp = (CODEADDR)codeptr; *startp = (CODEADDR)codeptr;
*endp = (CODEADDR)NEXTOP(codeptr,sssllp); *endp = (CODEADDR)NEXTOP(codeptr,sssllp);
@ -4199,30 +4199,30 @@ found_ystop(yamop *pc, int clause_code, CODEADDR *startp, CODEADDR *endp, PredEn
} }
if (!pp) { if (!pp) {
/* must be an index */ /* must be an index */
PredEntry **pep = (PredEntry **)pc->u.l.l; PredEntry **pep = (PredEntry **)pc->y_u.l.l;
pp = pep[-1]; pp = pep[-1];
} }
if (pp->PredFlags & LogUpdatePredFlag) { if (pp->PredFlags & LogUpdatePredFlag) {
if (clause_code) { if (clause_code) {
LogUpdClause *cl = ClauseCodeToLogUpdClause(pc->u.l.l); LogUpdClause *cl = ClauseCodeToLogUpdClause(pc->y_u.l.l);
*startp = (CODEADDR)cl; *startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize; *endp = (CODEADDR)cl+cl->ClSize;
} else { } else {
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(pc->u.l.l); LogUpdIndex *cl = ClauseCodeToLogUpdIndex(pc->y_u.l.l);
*startp = (CODEADDR)cl; *startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize; *endp = (CODEADDR)cl+cl->ClSize;
} }
} else if (pp->PredFlags & DynamicPredFlag) { } else if (pp->PredFlags & DynamicPredFlag) {
DynamicClause *cl = ClauseCodeToDynamicClause(pc->u.l.l); DynamicClause *cl = ClauseCodeToDynamicClause(pc->y_u.l.l);
*startp = (CODEADDR)cl; *startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize; *endp = (CODEADDR)cl+cl->ClSize;
} else { } else {
if (clause_code) { if (clause_code) {
StaticClause *cl = ClauseCodeToStaticClause(pc->u.l.l); StaticClause *cl = ClauseCodeToStaticClause(pc->y_u.l.l);
*startp = (CODEADDR)cl; *startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize; *endp = (CODEADDR)cl+cl->ClSize;
} else { } else {
StaticIndex *cl = ClauseCodeToStaticIndex(pc->u.l.l); StaticIndex *cl = ClauseCodeToStaticIndex(pc->y_u.l.l);
*startp = (CODEADDR)cl; *startp = (CODEADDR)cl;
*endp = (CODEADDR)cl+cl->ClSize; *endp = (CODEADDR)cl+cl->ClSize;
} }
@ -5150,7 +5150,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
case _trust_logical: case _trust_logical:
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
if (bptr->cp_ap->u.OtaLl.d->ClPred == ap) { if (bptr->cp_ap->y_u.OtaLl.d->ClPred == ap) {
UInt ts = IntegerOfTerm(bptr->cp_args[ar]); UInt ts = IntegerOfTerm(bptr->cp_args[ar]);
if (ts != arp[0]) { if (ts != arp[0]) {
if (arp-HR < 1024) { if (arp-HR < 1024) {
@ -5214,7 +5214,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
case _trust_logical: case _trust_logical:
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
if (bptr->cp_ap->u.OtaLl.d->ClPred == ap) { if (bptr->cp_ap->y_u.OtaLl.d->ClPred == ap) {
UInt ts = IntegerOfTerm(bptr->cp_args[ar]); UInt ts = IntegerOfTerm(bptr->cp_args[ar]);
while (ts != arp[0]) while (ts != arp[0])
arp--; arp--;
@ -5579,9 +5579,9 @@ index_ssz(StaticIndex *x, PredEntry *pe)
} }
/* expand clause blocks */ /* expand clause blocks */
while (ep) { while (ep) {
if (ep->u.sssllp.p == pe) if (ep->y_u.sssllp.p == pe)
sz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *); sz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->y_u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext; ep = ep->y_u.sssllp.snext;
} }
/* main indexing tree */ /* main indexing tree */
sz += tree_index_ssz(x); sz += tree_index_ssz(x);
@ -5787,7 +5787,7 @@ p_env_info( USES_REGS1 )
env_b = MkIntegerTerm((Int)(LCL0-(CELL *)env[E_CB])); env_b = MkIntegerTerm((Int)(LCL0-(CELL *)env[E_CB]));
env_cp = (yamop *)env[E_CP]; env_cp = (yamop *)env[E_CP];
/* pe = PREVOP(env_cp,Osbpp)->u.Osbpp.p0; */ /* pe = PREVOP(env_cp,Osbpp)->y_u.Osbpp.p0; */
taddr = MkIntegerTerm((Int)env); taddr = MkIntegerTerm((Int)env);
return Yap_unify(ARG3,MkIntegerTerm((Int)env_cp)) && return Yap_unify(ARG3,MkIntegerTerm((Int)env_cp)) &&
Yap_unify(ARG2, taddr) && Yap_unify(ARG2, taddr) &&
@ -5800,7 +5800,7 @@ p_cpc_info( USES_REGS1 )
PredEntry *pe; PredEntry *pe;
yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1)); yamop *ipc = (yamop *)IntegerOfTerm(Deref(ARG1));
pe = PREVOP(ipc,Osbpp)->u.Osbpp.p0; pe = PREVOP(ipc,Osbpp)->y_u.Osbpp.p0;
return UnifyPredInfo(pe, 2 PASS_REGS) && return UnifyPredInfo(pe, 2 PASS_REGS) &&
Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe))); Yap_unify(ARG5,MkIntegerTerm(ClauseId(ipc,pe)));
} }
@ -5903,21 +5903,21 @@ p_choicepoint_info( USES_REGS1 )
case _count_trust_logical: case _count_trust_logical:
case _profiled_retry_logical: case _profiled_retry_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
ncl = ipc->u.OtaLl.d->ClCode; ncl = ipc->y_u.OtaLl.d->ClCode;
pe = ipc->u.OtaLl.d->ClPred; pe = ipc->y_u.OtaLl.d->ClPred;
t = BuildActivePred(pe, cptr->cp_args); t = BuildActivePred(pe, cptr->cp_args);
break; break;
case _or_else: case _or_else:
pe = ipc->u.Osblp.p0; pe = ipc->y_u.Osblp.p0;
ncl = ipc; ncl = ipc;
t = Yap_MkNewApplTerm(FunctorOr, 2); t = Yap_MkNewApplTerm(FunctorOr, 2);
break; break;
case _or_last: case _or_last:
#ifdef YAPOR #ifdef YAPOR
pe = ipc->u.Osblp.p0; pe = ipc->y_u.Osblp.p0;
#else #else
pe = ipc->u.p.p; pe = ipc->y_u.p.p;
#endif #endif
ncl = ipc; ncl = ipc;
t = Yap_MkNewApplTerm(FunctorOr, 2); t = Yap_MkNewApplTerm(FunctorOr, 2);
@ -5929,26 +5929,26 @@ p_choicepoint_info( USES_REGS1 )
t = TermNil; t = TermNil;
ipc = NEXTOP(ipc,l); ipc = NEXTOP(ipc,l);
if (!ncl) if (!ncl)
ncl = ipc->u.Otapl.d; ncl = ipc->y_u.Otapl.d;
go_on = TRUE; go_on = TRUE;
break; break;
case _jump: case _jump:
pe = NULL; pe = NULL;
t = TermNil; t = TermNil;
ipc = ipc->u.l.l; ipc = ipc->y_u.l.l;
go_on = TRUE; go_on = TRUE;
break; break;
case _retry_c: case _retry_c:
case _retry_userc: case _retry_userc:
ncl = NEXTOP(ipc,OtapFs); ncl = NEXTOP(ipc,OtapFs);
pe = ipc->u.OtapFs.p; pe = ipc->y_u.OtapFs.p;
t = BuildActivePred(pe, cptr->cp_args); t = BuildActivePred(pe, cptr->cp_args);
break; break;
case _retry_profiled: case _retry_profiled:
case _count_retry: case _count_retry:
pe = NULL; pe = NULL;
t = TermNil; t = TermNil;
ncl = ipc->u.Otapl.d; ncl = ipc->y_u.Otapl.d;
ipc = NEXTOP(ipc,p); ipc = NEXTOP(ipc,p);
go_on = TRUE; go_on = TRUE;
break; break;
@ -5963,14 +5963,14 @@ p_choicepoint_info( USES_REGS1 )
case _retry: case _retry:
case _trust: case _trust:
if (!ncl) if (!ncl)
ncl = ipc->u.Otapl.d; ncl = ipc->y_u.Otapl.d;
pe = ipc->u.Otapl.p; pe = ipc->y_u.Otapl.p;
t = BuildActivePred(pe, cptr->cp_args); t = BuildActivePred(pe, cptr->cp_args);
break; break;
case _retry_exo: case _retry_exo:
case _retry_all_exo: case _retry_all_exo:
ncl = NULL; ncl = NULL;
pe = ipc->u.lp.p; pe = ipc->y_u.lp.p;
t = BuildActivePred(pe, cptr->cp_args); t = BuildActivePred(pe, cptr->cp_args);
break; break;
case _Nstop: case _Nstop:
@ -6031,61 +6031,61 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
case 2: case 2:
pc->opc = Yap_opcode(_get_2atoms); pc->opc = Yap_opcode(_get_2atoms);
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.cc.c1 = t; pc->y_u.cc.c1 = t;
DerefAndCheck(t, tp[1]); DerefAndCheck(t, tp[1]);
pc->u.cc.c2 = t; pc->y_u.cc.c2 = t;
pc = NEXTOP(pc,cc); pc = NEXTOP(pc,cc);
break; break;
case 3: case 3:
pc->opc = Yap_opcode(_get_3atoms); pc->opc = Yap_opcode(_get_3atoms);
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.ccc.c1 = t; pc->y_u.ccc.c1 = t;
DerefAndCheck(t, tp[1]); DerefAndCheck(t, tp[1]);
pc->u.ccc.c2 = t; pc->y_u.ccc.c2 = t;
DerefAndCheck(t, tp[2]); DerefAndCheck(t, tp[2]);
pc->u.ccc.c3 = t; pc->y_u.ccc.c3 = t;
pc = NEXTOP(pc,ccc); pc = NEXTOP(pc,ccc);
break; break;
case 4: case 4:
pc->opc = Yap_opcode(_get_4atoms); pc->opc = Yap_opcode(_get_4atoms);
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.cccc.c1 = t; pc->y_u.cccc.c1 = t;
DerefAndCheck(t, tp[1]); DerefAndCheck(t, tp[1]);
pc->u.cccc.c2 = t; pc->y_u.cccc.c2 = t;
DerefAndCheck(t, tp[2]); DerefAndCheck(t, tp[2]);
pc->u.cccc.c3 = t; pc->y_u.cccc.c3 = t;
DerefAndCheck(t, tp[3]); DerefAndCheck(t, tp[3]);
pc->u.cccc.c4 = t; pc->y_u.cccc.c4 = t;
pc = NEXTOP(pc,cccc); pc = NEXTOP(pc,cccc);
break; break;
case 5: case 5:
pc->opc = Yap_opcode(_get_5atoms); pc->opc = Yap_opcode(_get_5atoms);
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.ccccc.c1 = t; pc->y_u.ccccc.c1 = t;
DerefAndCheck(t, tp[1]); DerefAndCheck(t, tp[1]);
pc->u.ccccc.c2 = t; pc->y_u.ccccc.c2 = t;
DerefAndCheck(t, tp[2]); DerefAndCheck(t, tp[2]);
pc->u.ccccc.c3 = t; pc->y_u.ccccc.c3 = t;
DerefAndCheck(t, tp[3]); DerefAndCheck(t, tp[3]);
pc->u.ccccc.c4 = t; pc->y_u.ccccc.c4 = t;
DerefAndCheck(t, tp[4]); DerefAndCheck(t, tp[4]);
pc->u.ccccc.c5 = t; pc->y_u.ccccc.c5 = t;
pc = NEXTOP(pc,ccccc); pc = NEXTOP(pc,ccccc);
break; break;
case 6: case 6:
pc->opc = Yap_opcode(_get_6atoms); pc->opc = Yap_opcode(_get_6atoms);
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.cccccc.c1 = t; pc->y_u.cccccc.c1 = t;
DerefAndCheck(t, tp[1]); DerefAndCheck(t, tp[1]);
pc->u.cccccc.c2 = t; pc->y_u.cccccc.c2 = t;
DerefAndCheck(t, tp[2]); DerefAndCheck(t, tp[2]);
pc->u.cccccc.c3 = t; pc->y_u.cccccc.c3 = t;
DerefAndCheck(t, tp[3]); DerefAndCheck(t, tp[3]);
pc->u.cccccc.c4 = t; pc->y_u.cccccc.c4 = t;
DerefAndCheck(t, tp[4]); DerefAndCheck(t, tp[4]);
pc->u.cccccc.c5 = t; pc->y_u.cccccc.c5 = t;
DerefAndCheck(t, tp[5]); DerefAndCheck(t, tp[5]);
pc->u.cccccc.c6 = t; pc->y_u.cccccc.c6 = t;
pc = NEXTOP(pc,cccccc); pc = NEXTOP(pc,cccccc);
break; break;
default: default:
@ -6094,12 +6094,12 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
for (i = 0; i< arity; i++) { for (i = 0; i< arity; i++) {
pc->opc = Yap_opcode(_get_atom); pc->opc = Yap_opcode(_get_atom);
#if PRECOMPUTE_REGADDRESS #if PRECOMPUTE_REGADDRESS
pc->u.xc.x = (CELL) (XREGS + (i+1)); pc->y_u.xc.x = (CELL) (XREGS + (i+1));
#else #else
pc->u.xc.x = i+1; pc->y_u.xc.x = i+1;
#endif #endif
DerefAndCheck(t, tp[0]); DerefAndCheck(t, tp[0]);
pc->u.xc.c = t; pc->y_u.xc.c = t;
tp++; tp++;
pc = NEXTOP(pc,xc); pc = NEXTOP(pc,xc);
} }
@ -6107,7 +6107,7 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
break; break;
} }
pc->opc = Yap_opcode(_procceed); pc->opc = Yap_opcode(_procceed);
pc->u.p.p = pe; pc->y_u.p.p = pe;
return TRUE; return TRUE;
} }

View File

@ -75,22 +75,22 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
fclause = ptr[-1]; fclause = ptr[-1];
code_p = (yamop *)(ptr-1); code_p = (yamop *)(ptr-1);
code_p->opc = Yap_opcode(_try_clause); code_p->opc = Yap_opcode(_try_clause);
code_p->u.Otapl.d = fclause; code_p->y_u.Otapl.d = fclause;
code_p->u.Otapl.s = ap->ArityOfPE; code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap; code_p->y_u.Otapl.p = ap;
#ifdef TABLING #ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred; code_p->y_u.Otapl.te = ap->TableOfPred;
#endif #endif
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0); INIT_YAMOP_LTT(code_p, 0);
#endif /* YAPOR */ #endif /* YAPOR */
code_p = NEXTOP(code_p,Otapl); code_p = NEXTOP(code_p,Otapl);
code_p->opc = Yap_opcode(_trust); code_p->opc = Yap_opcode(_trust);
code_p->u.Otapl.d = clause; code_p->y_u.Otapl.d = clause;
code_p->u.Otapl.s = ap->ArityOfPE; code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap; code_p->y_u.Otapl.p = ap;
#ifdef TABLING #ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred; code_p->y_u.Otapl.te = ap->TableOfPred;
#endif #endif
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0); INIT_YAMOP_LTT(code_p, 0);
@ -100,11 +100,11 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE; if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE;
code_p->opc = Yap_opcode(_trust); code_p->opc = Yap_opcode(_trust);
code_p->u.Otapl.d = clause; code_p->y_u.Otapl.d = clause;
code_p->u.Otapl.s = ap->ArityOfPE; code_p->y_u.Otapl.s = ap->ArityOfPE;
code_p->u.Otapl.p = ap; code_p->y_u.Otapl.p = ap;
#ifdef TABLING #ifdef TABLING
code_p->u.Otapl.te = ap->TableOfPred; code_p->y_u.Otapl.te = ap->TableOfPred;
#endif #endif
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(code_p, 0); INIT_YAMOP_LTT(code_p, 0);

View File

@ -3614,14 +3614,14 @@ index_sz(LogUpdIndex *x)
endop = Yap_opcode(_profiled_trust_logical); endop = Yap_opcode(_profiled_trust_logical);
else else
endop = Yap_opcode(_trust_logical); endop = Yap_opcode(_trust_logical);
start = start->u.Illss.l1; start = start->y_u.Illss.l1;
if (start->u.Illss.s) do { if (start->y_u.Illss.s) do {
sz += (UInt)NEXTOP((yamop*)NULL,OtaLl); sz += (UInt)NEXTOP((yamop*)NULL,OtaLl);
op1 = start->opc; op1 = start->opc;
count++; count++;
if (start->u.OtaLl.d->ClFlags & ErasedMask) if (start->y_u.OtaLl.d->ClFlags & ErasedMask)
dead++; dead++;
start = start->u.OtaLl.n; start = start->y_u.OtaLl.n;
} while (op1 != endop); } while (op1 != endop);
} }
x = x->ChildIndex; x = x->ChildIndex;
@ -3656,9 +3656,9 @@ lu_statistics(PredEntry *pe USES_REGS)
/* expand clause blocks */ /* expand clause blocks */
yamop *ep = ExpandClausesFirst; yamop *ep = ExpandClausesFirst;
while (ep) { while (ep) {
if (ep->u.sssllp.p == pe) if (ep->y_u.sssllp.p == pe)
isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->u.sssllp.s1*sizeof(yamop *); isz += (UInt)NEXTOP((yamop *)NULL,sssllp)+ep->y_u.sssllp.s1*sizeof(yamop *);
ep = ep->u.sssllp.snext; ep = ep->y_u.sssllp.snext;
} }
isz += index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred)); isz += index_sz(ClauseCodeToLogUpdIndex(pe->cs.p_code.TrueCodeOfPred));
} }
@ -3915,7 +3915,7 @@ find_next_clause(DBRef ref0 USES_REGS)
static Int static Int
p_jump_to_next_dynamic_clause( USES_REGS1 ) p_jump_to_next_dynamic_clause( USES_REGS1 )
{ {
DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.bmap); DBRef ref = (DBRef)(((yamop *)((CODEADDR)P-(CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
yamop *newp = find_next_clause(ref PASS_REGS); yamop *newp = find_next_clause(ref PASS_REGS);
if (newp == NULL) { if (newp == NULL) {
@ -4070,20 +4070,20 @@ MyEraseClause(DynamicClause *clau USES_REGS)
I don't need to lock the clause at this point because I don't need to lock the clause at this point because
I am the last one using it anyway. I am the last one using it anyway.
*/ */
ref = (DBRef) NEXTOP(clau->ClCode,Otapl)->u.Osbpp.bmap; ref = (DBRef) NEXTOP(clau->ClCode,Otapl)->y_u.Osbpp.bmap;
/* don't do nothing if the reference is still in use */ /* don't do nothing if the reference is still in use */
if (DBREF_IN_USE(ref)) if (DBREF_IN_USE(ref))
return; return;
if ( P == clau->ClCode ) { if ( P == clau->ClCode ) {
yamop *np = RTRYCODE; yamop *np = RTRYCODE;
/* make it the next alternative */ /* make it the next alternative */
np->u.Otapl.d = find_next_clause((DBRef)(NEXTOP(P,Otapl)->u.Osbpp.bmap) PASS_REGS); np->y_u.Otapl.d = find_next_clause((DBRef)(NEXTOP(P,Otapl)->y_u.Osbpp.bmap) PASS_REGS);
if (np->u.Otapl.d == NULL) if (np->y_u.Otapl.d == NULL)
P = (yamop *)FAILCODE; P = (yamop *)FAILCODE;
else { else {
/* with same arity as before */ /* with same arity as before */
np->u.Otapl.s = P->u.Otapl.s; np->y_u.Otapl.s = P->y_u.Otapl.s;
np->u.Otapl.p = P->u.Otapl.p; np->y_u.Otapl.p = P->y_u.Otapl.p;
/* go ahead and try this code */ /* go ahead and try this code */
P = np; P = np;
} }
@ -4134,7 +4134,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.FirstClause != cl) { if (p->cs.p_code.FirstClause != cl) {
/* we are not the first clause... */ /* we are not the first clause... */
yamop *prev_code_p = (yamop *)(dbr->Prev->Code); yamop *prev_code_p = (yamop *)(dbr->Prev->Code);
prev_code_p->u.Otapl.d = code_p->u.Otapl.d; prev_code_p->y_u.Otapl.d = code_p->y_u.Otapl.d;
/* are we the last? */ /* are we the last? */
if (p->cs.p_code.LastClause == cl) if (p->cs.p_code.LastClause == cl)
p->cs.p_code.LastClause = prev_code_p; p->cs.p_code.LastClause = prev_code_p;
@ -4143,7 +4143,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.LastClause == p->cs.p_code.FirstClause) { if (p->cs.p_code.LastClause == p->cs.p_code.FirstClause) {
p->cs.p_code.LastClause = p->cs.p_code.FirstClause = NULL; p->cs.p_code.LastClause = p->cs.p_code.FirstClause = NULL;
} else { } else {
p->cs.p_code.FirstClause = code_p->u.Otapl.d; p->cs.p_code.FirstClause = code_p->y_u.Otapl.d;
p->cs.p_code.FirstClause->opc = p->cs.p_code.FirstClause->opc =
Yap_opcode(_try_me); Yap_opcode(_try_me);
} }
@ -4158,7 +4158,7 @@ PrepareToEraseLogUpdClause(LogUpdClause *clau, DBRef dbr)
if (p->cs.p_code.FirstClause == p->cs.p_code.LastClause) { if (p->cs.p_code.FirstClause == p->cs.p_code.LastClause) {
if (p->cs.p_code.FirstClause != NULL) { if (p->cs.p_code.FirstClause != NULL) {
code_p = p->cs.p_code.FirstClause; code_p = p->cs.p_code.FirstClause;
code_p->u.Otapl.d = p->cs.p_code.FirstClause; code_p->y_u.Otapl.d = p->cs.p_code.FirstClause;
p->cs.p_code.TrueCodeOfPred = NEXTOP(code_p, Otapl); p->cs.p_code.TrueCodeOfPred = NEXTOP(code_p, Otapl);
if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) { if (p->PredFlags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) {
p->OpcodeOfPred = Yap_opcode(_spy_pred); p->OpcodeOfPred = Yap_opcode(_spy_pred);

View File

@ -1587,9 +1587,9 @@ static int is_cleanup_cp(choiceptr cp_b)
if (cp_b->cp_ap->opc != ORLAST_OPCODE) if (cp_b->cp_ap->opc != ORLAST_OPCODE)
return FALSE; return FALSE;
#ifdef YAPOR #ifdef YAPOR
pe = cp_b->cp_ap->u.Osblp.p0; pe = cp_b->cp_ap->y_u.Osblp.p0;
#else #else
pe = cp_b->cp_ap->u.p.p; pe = cp_b->cp_ap->y_u.p.p;
#endif /* YAPOR */ #endif /* YAPOR */
/* /*
it has to be a cleanup and it has to be a completed goal, it has to be a cleanup and it has to be a completed goal,
@ -1902,7 +1902,7 @@ Yap_dogc( int extra_args, Term *tp USES_REGS )
int i; int i;
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) { if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
arity = PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE; arity = PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
nextpc = P; nextpc = P;
} else { } else {
arity = 0; arity = 0;

16
C/exo.c
View File

@ -467,30 +467,30 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
ptr->opc = Yap_opcode(_try_exo); ptr->opc = Yap_opcode(_try_exo);
else else
ptr->opc = Yap_opcode(_try_all_exo); ptr->opc = Yap_opcode(_try_all_exo);
ptr->u.lp.l = (yamop *)i; ptr->y_u.lp.l = (yamop *)i;
ptr->u.lp.p = ap; ptr->y_u.lp.p = ap;
ptr = NEXTOP(ptr, lp); ptr = NEXTOP(ptr, lp);
if (count) if (count)
ptr->opc = Yap_opcode(_retry_exo); ptr->opc = Yap_opcode(_retry_exo);
else else
ptr->opc = Yap_opcode(_retry_all_exo); ptr->opc = Yap_opcode(_retry_all_exo);
ptr->u.lp.p = ap; ptr->y_u.lp.p = ap;
ptr->u.lp.l = (yamop *)i; ptr->y_u.lp.l = (yamop *)i;
ptr = NEXTOP(ptr, lp); ptr = NEXTOP(ptr, lp);
for (j = 0; j < i->arity; j++) { for (j = 0; j < i->arity; j++) {
ptr->opc = Yap_opcode(_get_atom_exo); ptr->opc = Yap_opcode(_get_atom_exo);
#if PRECOMPUTE_REGADDRESS #if PRECOMPUTE_REGADDRESS
ptr->u.x.x = (CELL) (XREGS + (j+1)); ptr->y_u.x.x = (CELL) (XREGS + (j+1));
#else #else
ptr->u.x.x = j+1; ptr->y_u.x.x = j+1;
#endif #endif
ptr = NEXTOP(ptr, x); ptr = NEXTOP(ptr, x);
} }
ptr->opc = Yap_opcode(_procceed); ptr->opc = Yap_opcode(_procceed);
ptr->u.p.p = ap; ptr->y_u.p.p = ap;
ptr = NEXTOP(ptr, p); ptr = NEXTOP(ptr, p);
ptr->opc = Yap_opcode(_Ystop); ptr->opc = Yap_opcode(_Ystop);
ptr->u.l.l = i->code; ptr->y_u.l.l = i->code;
Yap_inform_profiler_of_clause((char *)(i->code), (char *)NEXTOP(ptr,l), ap, GPROF_INDEX); Yap_inform_profiler_of_clause((char *)(i->code), (char *)NEXTOP(ptr,l), ap, GPROF_INDEX);
if (ap->PredFlags & UDIPredFlag) { if (ap->PredFlags & UDIPredFlag) {
Yap_new_udi_clause( ap, NULL, (Term)ip); Yap_new_udi_clause( ap, NULL, (Term)ip);

View File

@ -934,10 +934,10 @@ prof_alrm(int signo, siginfo_t *si, void *scv)
if (oop == _call_cpred || oop == _call_usercpred) { if (oop == _call_cpred || oop == _call_usercpred) {
/* doing C-code */ /* doing C-code */
current_p = PREVOP(P,Osbpp)->u.Osbpp.p->CodeOfPred; current_p = PREVOP(P,Osbpp)->y_u.Osbpp.p->CodeOfPred;
} else if ((oop = Yap_op_from_opcode(P->opc)) == _execute_cpred) { } else if ((oop = Yap_op_from_opcode(P->opc)) == _execute_cpred) {
/* doing C-code */ /* doing C-code */
current_p = P->u.pp.p->CodeOfPred; current_p = P->y_u.pp.p->CodeOfPred;
} else { } else {
current_p = P; current_p = P;
} }

View File

@ -1419,13 +1419,18 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
int res; int res;
int blob_overflow = (NOfBlobs > NOfBlobsMax); int blob_overflow = (NOfBlobs > NOfBlobsMax);
#if (THREADS) || YAPOR LOCK(GLOBAL_ThreadHandlesLock);
res = FALSE; // make sure that we cannot have more than a thread life
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) { if (Yap_NOfThreads() > 1) {
Yap_undo_signal( YAP_CDOVF_SIGNAL ); UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE; res = FALSE;
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
Yap_undo_signal( YAP_CDOVF_SIGNAL );
UNLOCK(LOCAL_SignalLock);
return TRUE;
}
} }
#else // don't release the MTHREAD lock in case we're running from the C-interface.
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) { if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
UInt n = NOfAtoms; UInt n = NOfAtoms;
if (GLOBAL_AGcThreshold) if (GLOBAL_AGcThreshold)
@ -1438,11 +1443,14 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res = growatomtable( PASS_REGS1 ); res = growatomtable( PASS_REGS1 );
} else { } else {
Yap_undo_signal( YAP_CDOVF_SIGNAL ); Yap_undo_signal( YAP_CDOVF_SIGNAL );
UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE; return TRUE;
} }
LeaveGrowMode(GrowHeapMode); LeaveGrowMode(GrowHeapMode);
if (res) if (res) {
UNLOCK(GLOBAL_ThreadHandlesLock);
return res; return res;
}
} }
#if USE_SYSTEM_MALLOC #if USE_SYSTEM_MALLOC
P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed"); P = Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"malloc failed");
@ -1451,7 +1459,7 @@ Yap_locked_growheap(int fix_code, size_t in_size, void *cip)
res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS); res=do_growheap(fix_code, in_size, (struct intermediates *)cip, NULL, NULL, NULL PASS_REGS);
#endif #endif
LeaveGrowMode(GrowHeapMode); LeaveGrowMode(GrowHeapMode);
#endif UNLOCK(GLOBAL_ThreadHandlesLock);
return res; return res;
} }

View File

@ -169,11 +169,13 @@ PUSH_POINTER(CELL *v USES_REGS) {
*LOCAL_iptop++ = v; *LOCAL_iptop++ = v;
} }
#ifdef EASY_SHUNTING
inline static void inline static void
POP_POINTER( USES_REGS1 ) { POP_POINTER( USES_REGS1 ) {
if (LOCAL_iptop >= (CELL_PTR *)ASP) return; if (LOCAL_iptop >= (CELL_PTR *)ASP) return;
--LOCAL_iptop; --LOCAL_iptop;
} }
#endif
inline static void inline static void
POPSWAP_POINTER(CELL_PTR *vp, CELL_PTR v USES_REGS) { POPSWAP_POINTER(CELL_PTR *vp, CELL_PTR v USES_REGS) {
@ -451,7 +453,7 @@ push_registers(Int num_regs, yamop *nextop USES_REGS)
/* push any live registers we might have hanging around */ /* push any live registers we might have hanging around */
if (nextop->opc == Yap_opcode(_move_back) || if (nextop->opc == Yap_opcode(_move_back) ||
nextop->opc == Yap_opcode(_skip)) { nextop->opc == Yap_opcode(_skip)) {
CELL *lab = (CELL *)(nextop->u.l.l); CELL *lab = (CELL *)(nextop->y_u.l.l);
CELL max = lab[0]; CELL max = lab[0];
Int curr = lab[1]; Int curr = lab[1];
lab += 2; lab += 2;
@ -547,7 +549,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS)
/* pop any live registers we might have hanging around */ /* pop any live registers we might have hanging around */
if (nextop->opc == Yap_opcode(_move_back) || if (nextop->opc == Yap_opcode(_move_back) ||
nextop->opc == Yap_opcode(_skip)) { nextop->opc == Yap_opcode(_skip)) {
CELL *lab = (CELL *)(nextop->u.l.l); CELL *lab = (CELL *)(nextop->y_u.l.l);
CELL max = lab[0]; CELL max = lab[0];
Int curr = lab[1]; Int curr = lab[1];
lab += 2; lab += 2;
@ -1524,21 +1526,6 @@ mark_external_reference(CELL *ptr USES_REGS) {
} }
} }
static void inline
mark_external_reference2(CELL *ptr USES_REGS) {
CELL *next = GET_NEXT(*ptr);
if (ONHEAP(next)) {
#ifdef HYBRID_SCHEME
CELL_PTR *old = LOCAL_iptop;
#endif
mark_variable(ptr PASS_REGS);
POPSWAP_POINTER(old, ptr PASS_REGS);
} else {
mark_code(ptr,next PASS_REGS);
}
}
/* /*
* mark all heap objects accessible from the trail (which includes the active * mark all heap objects accessible from the trail (which includes the active
* general purpose registers) * general purpose registers)
@ -2055,8 +2042,8 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
if (opnum == _or_else || opnum == _or_last) { if (opnum == _or_else || opnum == _or_last) {
/* ; choice point */ /* ; choice point */
mark_environments((CELL_PTR) (gc_B->cp_a1), mark_environments((CELL_PTR) (gc_B->cp_a1),
-gc_B->cp_cp->u.Osblp.s / ((OPREG)sizeof(CELL)), -gc_B->cp_cp->y_u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->u.Osblp.bmap gc_B->cp_cp->y_u.Osblp.bmap
PASS_REGS); PASS_REGS);
} else { } else {
/* choicepoint with arguments */ /* choicepoint with arguments */
@ -2107,10 +2094,10 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
} }
B = old_b; B = old_b;
} }
nargs = rtp->u.OtapFs.s+rtp->u.OtapFs.extra; nargs = rtp->y_u.OtapFs.s+rtp->y_u.OtapFs.extra;
break; break;
case _jump: case _jump:
rtp = rtp->u.l.l; rtp = rtp->y_u.l.l;
op = rtp->opc; op = rtp->opc;
opnum = Yap_op_from_opcode(op); opnum = Yap_op_from_opcode(op);
goto restart_cp; goto restart_cp;
@ -2144,7 +2131,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
{ {
CELL *vars_ptr, vars; CELL *vars_ptr, vars;
vars_ptr = (CELL *)(GEN_CP(gc_B) + 1); vars_ptr = (CELL *)(GEN_CP(gc_B) + 1);
nargs = rtp->u.Otapl.s; nargs = rtp->y_u.Otapl.s;
while (nargs--) { while (nargs--) {
mark_external_reference(vars_ptr PASS_REGS); mark_external_reference(vars_ptr PASS_REGS);
vars_ptr++; vars_ptr++;
@ -2307,15 +2294,15 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim on the other hand it's the only way we can be sure we can reclaim
space space
*/ */
yamop *end = rtp->u.OtaLl.n; yamop *end = rtp->y_u.OtaLl.n;
while (end->opc != trust_lu && while (end->opc != trust_lu &&
end->opc != count_trust_lu && end->opc != count_trust_lu &&
end->opc != profiled_trust_lu ) end->opc != profiled_trust_lu )
end = end->u.OtaLl.n; end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS); mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
} }
/* mark timestamp */ /* mark timestamp */
nargs = rtp->u.OtaLl.s+1; nargs = rtp->y_u.OtaLl.s+1;
break; break;
case _count_retry_logical: case _count_retry_logical:
{ {
@ -2324,13 +2311,13 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim on the other hand it's the only way we can be sure we can reclaim
space space
*/ */
yamop *end = rtp->u.OtaLl.n; yamop *end = rtp->y_u.OtaLl.n;
while (Yap_op_from_opcode(end->opc) != _count_trust_logical) while (Yap_op_from_opcode(end->opc) != _count_trust_logical)
end = end->u.OtaLl.n; end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS); mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
} }
/* mark timestamp */ /* mark timestamp */
nargs = rtp->u.OtaLl.s+1; nargs = rtp->y_u.OtaLl.s+1;
break; break;
case _profiled_retry_logical: case _profiled_retry_logical:
{ {
@ -2339,28 +2326,28 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
on the other hand it's the only way we can be sure we can reclaim on the other hand it's the only way we can be sure we can reclaim
space space
*/ */
yamop *end = rtp->u.OtaLl.n; yamop *end = rtp->y_u.OtaLl.n;
while (Yap_op_from_opcode(end->opc) != _profiled_trust_logical) while (Yap_op_from_opcode(end->opc) != _profiled_trust_logical)
end = end->u.OtaLl.n; end = end->y_u.OtaLl.n;
mark_ref_in_use((DBRef)end->u.OtILl.block PASS_REGS); mark_ref_in_use((DBRef)end->y_u.OtILl.block PASS_REGS);
} }
/* mark timestamp */ /* mark timestamp */
nargs = rtp->u.OtaLl.s+1; nargs = rtp->y_u.OtaLl.s+1;
break; break;
case _trust_logical: case _trust_logical:
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
/* mark timestamp */ /* mark timestamp */
mark_ref_in_use((DBRef)rtp->u.OtILl.block PASS_REGS); mark_ref_in_use((DBRef)rtp->y_u.OtILl.block PASS_REGS);
nargs = rtp->u.OtILl.d->ClPred->ArityOfPE+1; nargs = rtp->y_u.OtILl.d->ClPred->ArityOfPE+1;
break; break;
case _retry_exo: case _retry_exo:
case _retry_exo_udi: case _retry_exo_udi:
case _retry_all_exo: case _retry_all_exo:
nargs = rtp->u.lp.p->ArityOfPE; nargs = rtp->y_u.lp.p->ArityOfPE;
break; break;
case _retry_udi: case _retry_udi:
nargs = rtp->u.p.p->ArityOfPE; nargs = rtp->y_u.p.p->ArityOfPE;
break; break;
#ifdef DEBUG #ifdef DEBUG
case _retry_me: case _retry_me:
@ -2375,14 +2362,14 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
fprintf(stderr,"OOPS in GC: gc not supported in this case!!!\n"); fprintf(stderr,"OOPS in GC: gc not supported in this case!!!\n");
exit(1); exit(1);
} }
nargs = rtp->u.Otapl.s; nargs = rtp->y_u.Otapl.s;
break; break;
default: default:
fprintf(stderr, "OOPS in GC: Unexpected opcode: %d\n", opnum); fprintf(stderr, "OOPS in GC: Unexpected opcode: %d\n", opnum);
nargs = 0; nargs = 0;
#else #else
default: default:
nargs = rtp->u.Otapl.s; nargs = rtp->y_u.Otapl.s;
#endif #endif
} }
@ -2399,8 +2386,8 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
pt->opc != count_trust_lu && pt->opc != count_trust_lu &&
pt->opc != profiled_trust_lu pt->opc != profiled_trust_lu
) )
pt = pt->u.OtaLl.n; pt = pt->y_u.OtaLl.n;
mark_ref_in_use((DBRef)pt->u.OtILl.block PASS_REGS); mark_ref_in_use((DBRef)pt->y_u.OtILl.block PASS_REGS);
} }
} }
/* for each saved register */ /* for each saved register */
@ -3050,8 +3037,8 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
case _or_last: case _or_last:
sweep_environments((CELL_PTR)(gc_B->cp_a1), sweep_environments((CELL_PTR)(gc_B->cp_a1),
-gc_B->cp_cp->u.Osblp.s / ((OPREG)sizeof(CELL)), -gc_B->cp_cp->y_u.Osblp.s / ((OPREG)sizeof(CELL)),
gc_B->cp_cp->u.Osblp.bmap gc_B->cp_cp->y_u.Osblp.bmap
PASS_REGS); PASS_REGS);
break; break;
case _retry_profiled: case _retry_profiled:
@ -3061,7 +3048,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
opnum = Yap_op_from_opcode(op); opnum = Yap_op_from_opcode(op);
goto restart_cp; goto restart_cp;
case _jump: case _jump:
rtp = rtp->u.l.l; rtp = rtp->y_u.l.l;
op = rtp->opc; op = rtp->opc;
opnum = Yap_op_from_opcode(op); opnum = Yap_op_from_opcode(op);
goto restart_cp; goto restart_cp;
@ -3094,7 +3081,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
CELL *vars_ptr, vars; CELL *vars_ptr, vars;
sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS); sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS);
vars_ptr = (CELL *)(GEN_CP(gc_B) + 1); vars_ptr = (CELL *)(GEN_CP(gc_B) + 1);
nargs = rtp->u.Otapl.s; nargs = rtp->y_u.Otapl.s;
while(nargs--) { while(nargs--) {
CELL cp_cell = *vars_ptr; CELL cp_cell = *vars_ptr;
if (MARKED_PTR(vars_ptr)) { if (MARKED_PTR(vars_ptr)) {
@ -3288,12 +3275,12 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
case _count_retry_logical: case _count_retry_logical:
case _profiled_retry_logical: case _profiled_retry_logical:
/* sweep timestamp */ /* sweep timestamp */
sweep_b(gc_B, rtp->u.OtaLl.s+1 PASS_REGS); sweep_b(gc_B, rtp->y_u.OtaLl.s+1 PASS_REGS);
break; break;
case _trust_logical: case _trust_logical:
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
sweep_b(gc_B, rtp->u.OtILl.d->ClPred->ArityOfPE+1 PASS_REGS); sweep_b(gc_B, rtp->y_u.OtILl.d->ClPred->ArityOfPE+1 PASS_REGS);
break; break;
case _retry2: case _retry2:
sweep_b(gc_B, 2 PASS_REGS); sweep_b(gc_B, 2 PASS_REGS);
@ -3305,12 +3292,12 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
sweep_b(gc_B, 4 PASS_REGS); sweep_b(gc_B, 4 PASS_REGS);
break; break;
case _retry_udi: case _retry_udi:
sweep_b(gc_B, rtp->u.p.p->ArityOfPE PASS_REGS); sweep_b(gc_B, rtp->y_u.p.p->ArityOfPE PASS_REGS);
break; break;
case _retry_exo: case _retry_exo:
case _retry_exo_udi: case _retry_exo_udi:
case _retry_all_exo: case _retry_all_exo:
sweep_b(gc_B, rtp->u.lp.p->ArityOfPE PASS_REGS); sweep_b(gc_B, rtp->y_u.lp.p->ArityOfPE PASS_REGS);
break; break;
case _retry_c: case _retry_c:
case _retry_userc: case _retry_userc:
@ -3318,8 +3305,8 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
register CELL_PTR saved_reg; register CELL_PTR saved_reg;
/* for each extra saved register */ /* for each extra saved register */
for (saved_reg = &(gc_B->cp_a1)+rtp->u.OtapFs.s; for (saved_reg = &(gc_B->cp_a1)+rtp->y_u.OtapFs.s;
saved_reg < &(gc_B->cp_a1)+rtp->u.OtapFs.s+rtp->u.OtapFs.extra; saved_reg < &(gc_B->cp_a1)+rtp->y_u.OtapFs.s+rtp->y_u.OtapFs.extra;
saved_reg++) { saved_reg++) {
CELL cp_cell = *saved_reg; CELL cp_cell = *saved_reg;
if (MARKED_PTR(saved_reg)) { if (MARKED_PTR(saved_reg)) {
@ -3332,7 +3319,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
} }
/* continue to clean environments and arguments */ /* continue to clean environments and arguments */
default: default:
sweep_b(gc_B,rtp->u.Otapl.s PASS_REGS); sweep_b(gc_B,rtp->y_u.Otapl.s PASS_REGS);
} }
/* link to prev choicepoint */ /* link to prev choicepoint */

812
C/index.c

File diff suppressed because it is too large Load Diff

View File

@ -483,22 +483,22 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, UInt flags)
p_code->opc = Yap_opcode(_call_usercpred); p_code->opc = Yap_opcode(_call_usercpred);
else else
p_code->opc = Yap_opcode(_call_cpred); p_code->opc = Yap_opcode(_call_cpred);
p_code->u.Osbpp.bmap = NULL; p_code->y_u.Osbpp.bmap = NULL;
p_code->u.Osbpp.s = -Signed(RealEnvSize); p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
p_code->u.Osbpp.p = p_code->y_u.Osbpp.p =
p_code->u.Osbpp.p0 = p_code->y_u.Osbpp.p0 =
pe; pe;
p_code = NEXTOP(p_code,Osbpp); p_code = NEXTOP(p_code,Osbpp);
if (!(flags & SafePredFlag)) { if (!(flags & SafePredFlag)) {
p_code->opc = Yap_opcode(_deallocate); p_code->opc = Yap_opcode(_deallocate);
p_code->u.p.p = pe; p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p); p_code = NEXTOP(p_code,p);
} }
p_code->opc = Yap_opcode(_procceed); p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe; p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p); p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop); p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode; p_code->y_u.l.l = cl->ClCode;
pe->OpcodeOfPred = pe->CodeOfPred->opc; pe->OpcodeOfPred = pe->CodeOfPred->opc;
} }
@ -567,17 +567,17 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, UInt flags)
pe->cs.d_code = cmp_code; pe->cs.d_code = cmp_code;
pe->ModuleOfPred = CurrentModule; pe->ModuleOfPred = CurrentModule;
p_code->opc = pe->OpcodeOfPred = Yap_opcode(_call_bfunc_xx); p_code->opc = pe->OpcodeOfPred = Yap_opcode(_call_bfunc_xx);
p_code->u.plxxs.p = pe; p_code->y_u.plxxs.p = pe;
p_code->u.plxxs.f = FAILCODE; p_code->y_u.plxxs.f = FAILCODE;
p_code->u.plxxs.x1 = Yap_emit_x(1); p_code->y_u.plxxs.x1 = Yap_emit_x(1);
p_code->u.plxxs.x2 = Yap_emit_x(2); p_code->y_u.plxxs.x2 = Yap_emit_x(2);
p_code->u.plxxs.flags = Yap_compile_cmp_flags(pe); p_code->y_u.plxxs.flags = Yap_compile_cmp_flags(pe);
p_code = NEXTOP(p_code,plxxs); p_code = NEXTOP(p_code,plxxs);
p_code->opc = Yap_opcode(_procceed); p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe; p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p); p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop); p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode; p_code->y_u.l.l = cl->ClCode;
} }
void void
@ -655,20 +655,20 @@ Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, UInt fl
p_code = NEXTOP(p_code,e); p_code = NEXTOP(p_code,e);
} }
p_code->opc = Yap_opcode(_call_cpred); p_code->opc = Yap_opcode(_call_cpred);
p_code->u.Osbpp.bmap = NULL; p_code->y_u.Osbpp.bmap = NULL;
p_code->u.Osbpp.s = -Signed(RealEnvSize); p_code->y_u.Osbpp.s = -Signed(RealEnvSize);
p_code->u.Osbpp.p = p_code->u.Osbpp.p0 = pe; p_code->y_u.Osbpp.p = p_code->y_u.Osbpp.p0 = pe;
p_code = NEXTOP(p_code,Osbpp); p_code = NEXTOP(p_code,Osbpp);
if (!(flags & SafePredFlag)) { if (!(flags & SafePredFlag)) {
p_code->opc = Yap_opcode(_deallocate); p_code->opc = Yap_opcode(_deallocate);
p_code->u.p.p = pe; p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p); p_code = NEXTOP(p_code,p);
} }
p_code->opc = Yap_opcode(_procceed); p_code->opc = Yap_opcode(_procceed);
p_code->u.p.p = pe; p_code->y_u.p.p = pe;
p_code = NEXTOP(p_code,p); p_code = NEXTOP(p_code,p);
p_code->opc = Yap_opcode(_Ystop); p_code->opc = Yap_opcode(_Ystop);
p_code->u.l.l = cl->ClCode; p_code->y_u.l.l = cl->ClCode;
pe->OpcodeOfPred = pe->CodeOfPred->opc; pe->OpcodeOfPred = pe->CodeOfPred->opc;
} else { } else {
pe->OpcodeOfPred = Yap_opcode(_undef_p); pe->OpcodeOfPred = Yap_opcode(_undef_p);
@ -689,7 +689,7 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
return; return;
} }
code = (yamop *)(pe->cs.p_code.FirstClause); code = (yamop *)(pe->cs.p_code.FirstClause);
code->u.OtapFs.p = pe; code->y_u.OtapFs.p = pe;
if (pe->PredFlags & UserCPredFlag) if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_try_userc); code->opc = Yap_opcode(_try_userc);
else else
@ -698,7 +698,7 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
INIT_YAMOP_LTT(code, 2); INIT_YAMOP_LTT(code, 2);
PUT_YAMOP_SEQ(code); PUT_YAMOP_SEQ(code);
#endif /* YAPOR */ #endif /* YAPOR */
code->u.OtapFs.f = Start; code->y_u.OtapFs.f = Start;
code = NEXTOP(code,OtapFs); code = NEXTOP(code,OtapFs);
if (pe->PredFlags & UserCPredFlag) if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_retry_userc); code->opc = Yap_opcode(_retry_userc);
@ -708,14 +708,14 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
INIT_YAMOP_LTT(code, 1); INIT_YAMOP_LTT(code, 1);
PUT_YAMOP_SEQ(code); PUT_YAMOP_SEQ(code);
#endif /* YAPOR */ #endif /* YAPOR */
code->u.OtapFs.f = Cont; code->y_u.OtapFs.f = Cont;
code = NEXTOP(code,OtapFs); code = NEXTOP(code,OtapFs);
if (pe->PredFlags & UserCPredFlag) if (pe->PredFlags & UserCPredFlag)
code->opc = Yap_opcode(_cut_c); code->opc = Yap_opcode(_cut_c);
else else
code->opc = Yap_opcode(_cut_userc); code->opc = Yap_opcode(_cut_userc);
code->u.OtapFs.p = pe; code->y_u.OtapFs.p = pe;
code->u.OtapFs.f = Cut; code->y_u.OtapFs.f = Cut;
} }
void void
@ -805,10 +805,10 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_userc); pe->OpcodeOfPred = code->opc = Yap_opcode(_try_userc);
else else
pe->OpcodeOfPred = code->opc = Yap_opcode(_try_c); pe->OpcodeOfPred = code->opc = Yap_opcode(_try_c);
code->u.OtapFs.f = Start; code->y_u.OtapFs.f = Start;
code->u.OtapFs.p = pe; code->y_u.OtapFs.p = pe;
code->u.OtapFs.s = Arity; code->y_u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra; code->y_u.OtapFs.extra = Extra;
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(code, 2); INIT_YAMOP_LTT(code, 2);
PUT_YAMOP_SEQ(code); PUT_YAMOP_SEQ(code);
@ -818,10 +818,10 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
code->opc = Yap_opcode(_retry_userc); code->opc = Yap_opcode(_retry_userc);
else else
code->opc = Yap_opcode(_retry_c); code->opc = Yap_opcode(_retry_c);
code->u.OtapFs.f = Cont; code->y_u.OtapFs.f = Cont;
code->u.OtapFs.p = pe; code->y_u.OtapFs.p = pe;
code->u.OtapFs.s = Arity; code->y_u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra; code->y_u.OtapFs.extra = Extra;
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(code, 1); INIT_YAMOP_LTT(code, 1);
PUT_YAMOP_SEQ(code); PUT_YAMOP_SEQ(code);
@ -831,13 +831,13 @@ Yap_InitCPredBack_(const char *Name, UInt Arity,
code->opc = Yap_opcode(_cut_userc); code->opc = Yap_opcode(_cut_userc);
else else
code->opc = Yap_opcode(_cut_c); code->opc = Yap_opcode(_cut_c);
code->u.OtapFs.f = Cut; code->y_u.OtapFs.f = Cut;
code->u.OtapFs.p = pe; code->y_u.OtapFs.p = pe;
code->u.OtapFs.s = Arity; code->y_u.OtapFs.s = Arity;
code->u.OtapFs.extra = Extra; code->y_u.OtapFs.extra = Extra;
code = NEXTOP(code,OtapFs); code = NEXTOP(code,OtapFs);
code->opc = Yap_opcode(_Ystop); code->opc = Yap_opcode(_Ystop);
code->u.l.l = cl->ClCode; code->y_u.l.l = cl->ClCode;
} }
} }
@ -898,10 +898,10 @@ InitEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
/* make it look like the instruction is preceeded by a call instruction */ /* make it look like the instruction is preceeded by a call instruction */
ipc->opc = Yap_opcode(_call); ipc->opc = Yap_opcode(_call);
ipc->u.Osbpp.s = -Signed(RealEnvSize); ipc->y_u.Osbpp.s = -Signed(RealEnvSize);
ipc->u.Osbpp.bmap = NULL; ipc->y_u.Osbpp.bmap = NULL;
ipc->u.Osbpp.p = pred; ipc->y_u.Osbpp.p = pred;
ipc->u.Osbpp.p0 = pred; ipc->y_u.Osbpp.p0 = pred;
ipc = NEXTOP(ipc, Osbpp); ipc = NEXTOP(ipc, Osbpp);
ipc->opc = Yap_opcode(opc); ipc->opc = Yap_opcode(opc);
*instp = ipc; *instp = ipc;
@ -914,14 +914,14 @@ InitOtaplInst(yamop start[1], OPCODE opc, PredEntry *pe)
/* this is a place holder, it should not really be used */ /* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc); ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0; ipc->y_u.Otapl.s = 0;
ipc->u.Otapl.p = pe; ipc->y_u.Otapl.p = pe;
ipc->u.Otapl.d = NULL; ipc->y_u.Otapl.d = NULL;
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(ipc, 1); INIT_YAMOP_LTT(ipc, 1);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef TABLING #ifdef TABLING
ipc->u.Otapl.te = NULL; ipc->y_u.Otapl.te = NULL;
#endif /* TABLING */ #endif /* TABLING */
} }
@ -1182,8 +1182,8 @@ InitCodes(void)
modp->PredFlags |= MetaPredFlag; modp->PredFlags |= MetaPredFlag;
} }
#ifdef YAPOR #ifdef YAPOR
Yap_heap_regs->getwork_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE)); Yap_heap_regs->getwork_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
Yap_heap_regs->getwork_seq_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE)); Yap_heap_regs->getwork_seq_code->y_u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
#endif /* YAPOR */ #endif /* YAPOR */
} }

View File

@ -484,7 +484,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
{ {
CACHE_REGS CACHE_REGS
TokEntry *tokstart; TokEntry *tokstart;
Term t, v; Term t;
Term OCurrentModule = CurrentModule, tmod, tpos; Term OCurrentModule = CurrentModule, tmod, tpos;
int store_comments = rd->comments; int store_comments = rd->comments;
@ -614,6 +614,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments PASS_REGS))) if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments PASS_REGS)))
return FALSE; return FALSE;
if (rd->varnames) { if (rd->varnames) {
Term v;
while (TRUE) { while (TRUE) {
CELL *old_H = HR; CELL *old_H = HR;
@ -638,6 +639,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
} }
if (rd->variables) { if (rd->variables) {
Term v;
while (TRUE) { while (TRUE) {
CELL *old_H = HR; CELL *old_H = HR;
@ -661,6 +663,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
return FALSE; return FALSE;
} }
if (rd->singles) { if (rd->singles) {
Term v;
while (TRUE) { while (TRUE) {
CELL *old_H = HR; CELL *old_H = HR;
@ -955,8 +958,6 @@ p_write_string( USES_REGS1 )
int encoding; int encoding;
char buf[256]; char buf[256];
if ((s = Yap_TermToString( in, NULL, 0, &length, &encoding, 0)))
fprintf(stderr,"%ld %s\n",length, s);
if ((s = Yap_TermToString( in, buf, 256, &length, &encoding, 0))) if ((s = Yap_TermToString( in, buf, 256, &length, &encoding, 0)))
fprintf(stderr,"%ld %s\n",length, s); fprintf(stderr,"%ld %s\n",length, s);
return TRUE; return TRUE;

View File

@ -8,17 +8,11 @@
#include "Yatom.h" #include "Yatom.h"
#include "pl-incl.h" #include "pl-incl.h"
#include "YapText.h" #include "YapText.h"
#include "yapio.h"
#if HAVE_MATH_H #if HAVE_MATH_H
#include <math.h> #include <math.h>
#endif #endif
#define Quote_illegal_f 1
#define Ignore_ops_f 2
#define Handle_vars_f 4
#define Use_portray_f 8
#define To_heap_f 16
#define Unfold_cyclics_f 32
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#endif #endif
@ -649,7 +643,7 @@ numberVars(term_t t, nv_options *opts, int n ARG_LD) {
* PROMOTION * * PROMOTION *
*******************************/ *******************************/
static int int
check_float(double f) check_float(double f)
{ {
#ifdef HAVE_FPCLASSIFY #ifdef HAVE_FPCLASSIFY
@ -856,8 +850,6 @@ PL_get_chars(term_t t, char **s, unsigned flags)
{ return PL_get_nchars(t, NULL, s, flags); { return PL_get_nchars(t, NULL, s, flags);
} }
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags);
char * char *
Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags) Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags)
{ {
@ -921,6 +913,42 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
return NULL; return NULL;
} }
char *
Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags)
{
CACHE_REGS
char *r, buf[4096];
int64_t size;
IOSTREAM *fd;
r = buf;
fd = Sopenmem(&r, &sz, "w");
fd->encoding = ENC_UTF8;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0+%s=(%p) %p", l, buf, LCL0, &LCL0 ); }
if ( PL_write_term(fd, l, 1200, flags) &&
Sputcode(EOS, fd) >= 0 &&
Sflush(fd) >= 0 )
{
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%s=(%p) %p", buf, LCL0, &LCL0 ); }
size = Stell64(fd);
*length = size-1;
char *bf = malloc(*length+1);
if (!bf)
return NULL;
strncpy(bf,buf,*length+1);
Sclose(fd);
r = bf;
return r;
}
/* failed */
if ( r != buf ) {
Sfree(r);
}
return NULL;
}
X_API int X_API int
PL_ttymode(IOSTREAM *s) PL_ttymode(IOSTREAM *s)

View File

@ -16,8 +16,8 @@
* * * *
*************************************************************************/ *************************************************************************/
#include <SWI-Stream.h>
#include "absmi.h" #include "absmi.h"
#include <SWI-Stream.h>
#include "Foreign.h" #include "Foreign.h"
#include "alloc.h" #include "alloc.h"
#include "yapio.h" #include "yapio.h"
@ -1082,6 +1082,7 @@ Yap_Restore(char *s, char *lib_dir)
IOSTREAM *stream = Yap_OpenRestore(s, lib_dir); IOSTREAM *stream = Yap_OpenRestore(s, lib_dir);
if (!stream) if (!stream)
return -1; return -1;
__android_log_print(ANDROID_LOG_INFO, "qlyr.c", "loading startup %p", stream);
GLOBAL_RestoreFile = s; GLOBAL_RestoreFile = s;
read_module(stream); read_module(stream);
Sclose( stream ); Sclose( stream );

View File

@ -16,8 +16,8 @@
* * * *
*************************************************************************/ *************************************************************************/
#include <SWI-Stream.h>
#include "absmi.h" #include "absmi.h"
#include <SWI-Stream.h>
#include "Foreign.h" #include "Foreign.h"
#include "alloc.h" #include "alloc.h"
#include "yapio.h" #include "yapio.h"

View File

@ -19,6 +19,7 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#endif #endif
#include "config.h" #include "config.h"
#include "absmi.h"
#include "SWI-Stream.h" #include "SWI-Stream.h"
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)
#if HAVE_WINSOCK2_H #if HAVE_WINSOCK2_H
@ -27,7 +28,6 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#include <windows.h> #include <windows.h>
#include <psapi.h> #include <psapi.h>
#endif #endif
#include "absmi.h"
#include "alloc.h" #include "alloc.h"
#if USE_DL_MALLOC #if USE_DL_MALLOC
#include "dlmalloc.h" #include "dlmalloc.h"
@ -247,6 +247,22 @@ open_file(char *my_file, int flag)
{ {
int splfild; int splfild;
#if __ANDROID__
if (strstr(my_file, "/assets/") == my_file) {
if (flag == O_RDONLY) {
extern AAssetManager *assetManager;
my_file += strlen("/assets/");
__android_log_print(ANDROID_LOG_ERROR, "save.c", "open_file %p %s", assetManager, my_file);
AAsset* asset = AAssetManager_open(assetManager, my_file, AASSET_MODE_UNKNOWN);
if (!asset)
return -1;
__android_log_print(ANDROID_LOG_ERROR, "save.c", "open_file %p", asset);
AAsset_close( asset );
return 0; // usually the file will be compressed, so there is no point in actually trying to open it.
}
return -1;
}
#endif
#ifdef M_WILLIAMS #ifdef M_WILLIAMS
if (flag & O_CREAT) if (flag & O_CREAT)
splfild = creat(my_file, flag); splfild = creat(my_file, flag);
@ -1453,6 +1469,11 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
int mode = FAIL_RESTORE; int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1]; char save_buffer[YAP_FILENAME_MAX+1];
#if __ANDROID__
if (!inpf)
inpf = YAPSTARTUP;
#endif
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %s", inpf);
save_buffer[0] = '\0'; save_buffer[0] = '\0';
// LOCAL_ErrorMessage = NULL; // LOCAL_ErrorMessage = NULL;
if (inpf == NULL) { if (inpf == NULL) {
@ -1473,10 +1494,13 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1); strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1); strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} else { } else {
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1); strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} }
if (inpf != NULL && !((splfild = open_file(inpf, O_RDONLY)) < 0)) { if (inpf != NULL &&
!((splfild = open_file(inpf, O_RDONLY)) < 0))
{
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) { if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", *streamp);
return mode; return mode;
} }
} }
@ -1517,7 +1541,7 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
} }
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)
if ((inpf = Yap_RegistryGetString("startup"))) { if ((inpf = Yap_RegistryGetString("startup"))) {
if (!((splfild = open_file(inpf, O_RDONLY)) < 0)) { if (!((splfild = Sopen_file(inpf, "r")) < 0)) {
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) { if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode; return mode;
} }
@ -1582,6 +1606,7 @@ Yap_OpenRestore(char *inpf, char *YapLibDir)
IOSTREAM *stream = NULL; IOSTREAM *stream = NULL;
OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream); OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream);
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", stream);
return stream; return stream;
} }

View File

@ -1805,32 +1805,9 @@ Yap_volume_header(char *file)
} }
int Yap_getcwd(const char *buf, int len) char * Yap_getcwd(const char *cwd, size_t cwdlen)
{ {
CACHE_REGS return PL_cwd(cwd, cwdlen);
#if __simplescalar__
/* does not implement getcwd */
strncpy(Yap_buf,GLOBAL_pwd,len);
#elif HAVE_GETCWD
if (getcwd ((char *)buf, len) == NULL) {
#if HAVE_STRERROR
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in getcwd/1", strerror(errno));
#else
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "error %d in getcwd/1", errno);
#endif
return FALSE;
}
#else
if (getwd (buf) == NULL) {
#if HAVE_STRERROR
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "%s in getcwd/1", strerror(errno));
#else
Yap_Error(OPERATING_SYSTEM_ERROR, ARG1, "in getcwd/1");
#endif
return FALSE;
}
#endif
return TRUE;
} }
/****** /******
@ -2743,7 +2720,11 @@ p_yap_paths( USES_REGS1 ) {
out3 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_BINDIR)); out3 = MkAtomTerm(Yap_LookupAtom(DESTDIR "/" YAP_BINDIR));
} else { } else {
out1 = MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR)); out1 = MkAtomTerm(Yap_LookupAtom(YAP_LIBDIR));
#if __ANDROID__
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share"));
#else
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR)); out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
#endif
out3 = MkAtomTerm(Yap_LookupAtom(YAP_BINDIR)); out3 = MkAtomTerm(Yap_LookupAtom(YAP_BINDIR));
} }
return(Yap_unify(out1,ARG1) && return(Yap_unify(out1,ARG1) &&

View File

@ -90,6 +90,12 @@ Yap_ThreadID( void )
return -1; return -1;
} }
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
return GLOBAL_NOfThreads;
}
static int static int
allocate_new_tid(void) allocate_new_tid(void)
{ {
@ -694,11 +700,15 @@ p_thread_set_concurrency( USES_REGS1 )
Yap_Error(TYPE_ERROR_INTEGER,tnew,"thread_set_concurrency/2"); Yap_Error(TYPE_ERROR_INTEGER,tnew,"thread_set_concurrency/2");
return(FALSE); return(FALSE);
} }
#if HAVE_PTHREAD_GETCONCURRENCY
cur = MkIntegerTerm(pthread_getconcurrency()); cur = MkIntegerTerm(pthread_getconcurrency());
if (pthread_setconcurrency(newc) != 0) { if (pthread_setconcurrency(newc) != 0) {
return FALSE; return FALSE;
} }
return Yap_unify(ARG1, MkIntegerTerm(cur)); return Yap_unify(ARG1, MkIntegerTerm(cur));
#else
return FALSE;
#endif
} }
static Int static Int
@ -1090,6 +1100,17 @@ void Yap_InitThreadPreds(void)
#else #else
int
Yap_NOfThreads(void) {
// GLOBAL_ThreadHandlesLock is held
#ifdef YAPOR
return 2;
#else
return 1;
#endif
}
static Int static Int
p_no_threads(void) p_no_threads(void)
{ /* '$thread_signal'(+P) */ { /* '$thread_signal'(+P) */

View File

@ -146,7 +146,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
// if (!worker_id) return; // if (!worker_id) return;
LOCK(Yap_heap_regs->low_level_trace_lock); LOCK(Yap_heap_regs->low_level_trace_lock);
sc = Yap_heap_regs; sc = Yap_heap_regs;
if (vsc_count == 161862) jmp_deb(1); //if (vsc_count == 161862) jmp_deb(1);
// Sfprintf(stderr,"B=%p ", B); // Sfprintf(stderr,"B=%p ", B);
#ifdef THREADS #ifdef THREADS
LOCAL_ThreadHandle.thread_inst_count++; LOCAL_ThreadHandle.thread_inst_count++;

View File

@ -1618,6 +1618,40 @@ p_term_variables( USES_REGS1 ) /* variables in term t */
return Yap_unify(ARG2,out); return Yap_unify(ARG2,out);
} }
/**
* Exports a nil-terminated list with all the variables in a term.
* @param[in] the term
* @param[in] the arity of the calling predicate (required for exact garbage collection).
*/
Term
Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */
{
Term out;
do {
t = Deref(t);
if (IsVarTerm(t)) {
return MkPairTerm(t, TermNil);
} else if (IsPrimitiveTerm(t)) {
return TermNil;
} else if (IsPairTerm(t)) {
out = vars_in_complex_term(RepPair(t)-1,
RepPair(t)+1, TermNil PASS_REGS);
}
else {
Functor f = FunctorOfTerm(t);
out = vars_in_complex_term(RepAppl(t),
RepAppl(t)+
ArityOfFunctor(f), TermNil PASS_REGS);
}
if (out == 0L) {
if (!expand_vts( arity PASS_REGS ))
return FALSE;
}
} while (out == 0L);
return out;
}
static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp USES_REGS) static Term attvars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp USES_REGS)
{ {

View File

@ -317,7 +317,7 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
size_t l1 = strlen((const char *)decimalpoint+1); size_t l1 = strlen((const char *)decimalpoint+1);
#else #else
const unsigned char *decimalpoint = "."; const unsigned char *decimalpoint = ".";
l1 = 0; size_t l1 = 0;
#endif #endif
if (lastw == symbol || lastw == alphanum) { if (lastw == symbol || lastw == alphanum) {
@ -574,11 +574,12 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
wtype atom_or_symbol; wtype atom_or_symbol;
wrf stream = wglb->stream; wrf stream = wglb->stream;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AA LCL0=(%p) %p", LCL0, &LCL0 ); }
if (IsBlob(atom)) { if (IsBlob(atom)) {
wrputblob(RepAtom(atom),Quote_illegal,wglb); wrputblob(RepAtom(atom),Quote_illegal,wglb);
return; return;
} }
if (IsWideAtom(atom)) { if (IsWideAtom(atom) ) {
wchar_t *ws = RepAtom(atom)->WStrOfAE; wchar_t *ws = RepAtom(atom)->WStrOfAE;
if (Quote_illegal) { if (Quote_illegal) {
@ -593,7 +594,11 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
} }
return; return;
} }
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %p", LCL0, &LCL0 ); }
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %p", LCL0, RepAtom(atom)->StrOfAE ); }
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %c", LCL0, RepAtom(atom)->StrOfAE[0]); }
s = (unsigned char *)RepAtom(atom)->StrOfAE; s = (unsigned char *)RepAtom(atom)->StrOfAE;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AC %s LCL0=(%p) %p", s, LCL0, &LCL0 ); }
/* #define CRYPT_FOR_STEVE 1*/ /* #define CRYPT_FOR_STEVE 1*/
#ifdef CRYPT_FOR_STEVE #ifdef CRYPT_FOR_STEVE
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) { if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
@ -886,14 +891,19 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (EX) if (EX)
return; return;
t = Deref(t); t = Deref(t);
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "V %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
write_var((CELL *)t, wglb, &nrwt); write_var((CELL *)t, wglb, &nrwt);
} else if (IsIntTerm(t)) { } else if (IsIntTerm(t)) {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
wrputn((Int) IntOfTerm(t),wglb); wrputn((Int) IntOfTerm(t),wglb);
} else if (IsAtomTerm(t)) { } else if (IsAtomTerm(t)) {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "A %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb); putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
} else if (IsPairTerm(t)) { } else if (IsPairTerm(t)) {
if (wglb->Ignore_ops) { if (wglb->Ignore_ops) {
wrputs("'.'(",wglb->stream); wrputs("'.'(",wglb->stream);
lastw = separator; lastw = separator;
writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
@ -909,29 +919,33 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
struct DB_TERM *old_EX = NULL; struct DB_TERM *old_EX = NULL;
Int sl = 0; Int sl = 0;
targs[0] = t; targs[0] = t;
Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil)); Yap_PutValue(AtomPortray, MkAtomTerm(AtomNil));
if (EX) old_EX = EX; if (EX) old_EX = EX;
sl = Yap_InitSlot(t PASS_REGS); sl = Yap_InitSlot(t PASS_REGS);
Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1); Yap_execute_goal(Yap_MkApplTerm(FunctorPortray, 1, targs), 0, 1);
t = Yap_GetFromSlot(sl PASS_REGS); t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1, sl PASS_REGS); Yap_RecoverSlots(1, sl PASS_REGS);
if (old_EX != NULL) EX = old_EX; if (old_EX != NULL) EX = old_EX;
if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue)) if (Yap_GetValue(AtomPortray) == MkAtomTerm(AtomTrue))
return; return;
} }
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) { if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) {
putString(t, wglb); putString(t, wglb);
} else { } else {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
wrputc('[', wglb->stream); wrputc('[', wglb->stream);
lastw = separator; lastw = separator;
/* we assume t was already saved in the stack */ /* we assume t was already saved in the stack */
write_list(t, 0, depth, wglb, rwt); { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
write_list(t, 0, depth, wglb, rwt);
wrputc(']', wglb->stream); wrputc(']', wglb->stream);
lastw = separator; { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "III II%d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
lastw = separator;
} }
} else { /* compound term */ } else { /* compound term */
Functor functor = FunctorOfTerm(t); { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
Functor functor = FunctorOfTerm(t);
int Arity; int Arity;
Atom atom; Atom atom;
int op, lp, rp; int op, lp, rp;
@ -1087,7 +1101,8 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
} else if (!wglb->Ignore_ops && } else if (!wglb->Ignore_ops &&
Arity == 2 && Yap_IsInfixOp(atom, &op, &lp, Arity == 2 && Yap_IsInfixOp(atom, &op, &lp,
&rp) ) { &rp) ) {
Term tleft = ArgOfTerm(1, t); { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
Term tleft = ArgOfTerm(1, t);
Term tright = ArgOfTerm(2, t); Term tright = ArgOfTerm(2, t);
int bracket_left = int bracket_left =
!IsVarTerm(tleft) && IsAtomTerm(tleft) && !IsVarTerm(tleft) && IsAtomTerm(tleft) &&
@ -1104,7 +1119,9 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
if (bracket_left) { if (bracket_left) {
wropen_bracket(wglb, TRUE); wropen_bracket(wglb, TRUE);
} }
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "III %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt); writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "IV %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
t = AbsAppl(restore_from_write(&nrwt, wglb)-1); t = AbsAppl(restore_from_write(&nrwt, wglb)-1);
if (bracket_left) { if (bracket_left) {
wrclose_bracket(wglb, TRUE); wrclose_bracket(wglb, TRUE);
@ -1239,6 +1256,7 @@ Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority)
wglb.Ignore_ops = flags & Ignore_ops_f; wglb.Ignore_ops = flags & Ignore_ops_f;
wglb.Write_strings = flags & BackQuote_String_f; wglb.Write_strings = flags & BackQuote_String_f;
/* protect slots for portray */ /* protect slots for portray */
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt); writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt);
restore_from_write(&rwt, &wglb); restore_from_write(&rwt, &wglb);
} }

View File

@ -2,413 +2,629 @@
#define YAP_CPP_INTERFACE 1 #define YAP_CPP_INTERFACE 1
#include "yapi.hh" #include "yapi.hh"
#include "SWI-Stream.h"
YAPAtomTerm::YAPAtomTerm(char *s) { // build string YAPAtomTerm::YAPAtomTerm(char *s) { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.c = s; inp.val.c = s;
inp.type = YAP_STRING_CHARS; inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM; out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a); mk ( MkAtomTerm(out.val.a) );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.c = s; inp.val.c = s;
inp.type = YAP_STRING_CHARS; inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len; out.sz = len;
out.max = len; out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a); mk ( MkAtomTerm(out.val.a) );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.w = s; inp.val.w = s;
inp.type = YAP_STRING_WCHARS; inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM; out.type = YAP_STRING_ATOM;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a); mk ( MkAtomTerm(out.val.a) );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string YAPAtomTerm::YAPAtomTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.w = s; inp.val.w = s;
inp.type = YAP_STRING_WCHARS; inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len; out.sz = len;
out.max = len; out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = MkAtomTerm(out.val.a); mk ( MkAtomTerm(out.val.a) );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPStringTerm::YAPStringTerm(char *s) { // build string YAPStringTerm::YAPStringTerm(char *s) { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.c = s; inp.val.c = s;
inp.type = YAP_STRING_CHARS; inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING; out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t; mk ( out.val.t );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string YAPStringTerm::YAPStringTerm(char *s, size_t len) { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.c = s; inp.val.c = s;
inp.type = YAP_STRING_CHARS; inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len; out.sz = len;
out.max = len; out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t; mk ( out.val.t );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPStringTerm::YAPStringTerm(wchar_t *s): YAPTerm() { // build string YAPStringTerm::YAPStringTerm(wchar_t *s): YAPTerm() { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.w = s; inp.val.w = s;
inp.type = YAP_STRING_WCHARS; inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING; out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t; mk ( out.val.t );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build string YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.w = s; inp.val.w = s;
inp.type = YAP_STRING_WCHARS; inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC;
out.sz = len; out.sz = len;
out.max = len; out.max = len;
if (Yap_CVT_Text(&inp, &out PASS_REGS)) if (Yap_CVT_Text(&inp, &out PASS_REGS))
t = out.val.t; mk ( out.val.t );
else t = 0L; else t = 0L;
RECOVER_H(); RECOVER_H();
} }
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() { YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f); UInt arity = ArityOfFunctor(f.f);
t = Yap_MkApplTerm( f.f, arity, (Term *)ts); mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) );
} }
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() { YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
UInt arity = ArityOfFunctor(f.f); UInt arity = ArityOfFunctor(f.f);
t = Yap_MkNewApplTerm( f.f, arity); mk ( Yap_MkNewApplTerm( f.f, arity) );
} }
YAPTerm YAPApplTerm::getArg(unsigned int arg) { YAPTerm YAPApplTerm::getArg(int arg) {
return YAPTerm( ArgOfTerm(arg, t) ); return YAPTerm( ArgOfTerm(arg, gt() ) );
} }
YAPFunctor YAPApplTerm::getFunctor() { YAPFunctor YAPApplTerm::getFunctor() {
return YAPFunctor( FunctorOfTerm(t) ); return YAPFunctor( FunctorOfTerm( gt( )) );
} }
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() { YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
CACHE_REGS CACHE_REGS
t = MkPairTerm( th.t, tl.t); mk ( MkPairTerm( th.term(), tl.term() ) );
} }
YAPPairTerm::YAPPairTerm() : YAPTerm() { YAPPairTerm::YAPPairTerm() : YAPTerm() {
t = Yap_MkNewPairTerm( ); t = Yap_MkNewPairTerm( );
} }
YAP_tag_t YAPTerm::tag() { void YAPTerm::mk(Term t0) { CACHE_REGS t = Yap_InitSlot( t0 PASS_REGS); }
if (IsVarTerm(t)) {
CELL *pt = VarOfTerm(t);
if (IsUnboundVar(pt)) {
CACHE_REGS
if (IsAttVar(pt))
return YAP_TAG_ATT;
return YAP_TAG_UNBOUND;
}
return YAP_TAG_REF;
}
if (IsPairTerm(t))
return YAP_TAG_PAIR;
if (IsAtomOrIntTerm(t)) {
if (IsAtomTerm(t))
return YAP_TAG_ATOM;
return YAP_TAG_INT;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) { Term YAPTerm::gt() { CACHE_REGS return Yap_GetFromSlot( t PASS_REGS); }
if (f == FunctorDBRef) {
return YAP_TAG_DBREF; YAP_tag_t YAPTerm::tag() {
} Term tt = gt( );
if (f == FunctorLongInt) { if (IsVarTerm(tt)) {
return YAP_TAG_LONG_INT; CELL *pt = VarOfTerm(tt);
} if (IsUnboundVar(pt)) {
if (f == FunctorBigInt) { CACHE_REGS
big_blob_type bt = (big_blob_type)RepAppl(t)[1]; if (IsAttVar(pt))
switch (bt) { return YAP_TAG_ATT;
case BIG_INT: return YAP_TAG_UNBOUND;
return YAP_TAG_BIG_INT; }
case BIG_RATIONAL: return YAP_TAG_REF;
return YAP_TAG_RATIONAL; }
default: if (IsPairTerm(tt))
return YAP_TAG_OPAQUE; return YAP_TAG_PAIR;
} if (IsAtomOrIntTerm(tt)) {
} if (IsAtomTerm(tt))
} return YAP_TAG_ATOM;
return YAP_TAG_APPL; return YAP_TAG_INT;
} } else {
Functor f = FunctorOfTerm(tt);
if (IsExtensionFunctor(f)) {
if (f == FunctorDBRef) {
return YAP_TAG_DBREF;
}
if (f == FunctorLongInt) {
return YAP_TAG_LONG_INT;
}
if (f == FunctorBigInt) {
big_blob_type bt = (big_blob_type)RepAppl(tt)[1];
switch (bt) {
case BIG_INT:
return YAP_TAG_BIG_INT;
case BIG_RATIONAL:
return YAP_TAG_RATIONAL;
default:
return YAP_TAG_OPAQUE;
}
}
}
return YAP_TAG_APPL;
}
} }
YAPTerm YAPTerm::deepCopy() { YAPTerm YAPTerm::deepCopy() {
Term tn; Term tn;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
tn = Yap_CopyTerm(t); tn = Yap_CopyTerm( gt() );
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return new YAPTerm( tn ); return new YAPTerm( tn );
} }
bool YAPTerm::exactlyEqual(YAPTerm t1) { bool YAPTerm::exactlyEqual(YAPTerm t1) {
int out; int out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
out = Yap_eq(Deref(t), Deref(t1.t)); out = Yap_eq(gt(), t1.term());
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
bool YAPTerm::unify(YAPTerm t1) { bool YAPTerm::unify(YAPTerm t1) {
int out; int out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
out = Yap_unify(Deref(t), Deref(t1.t)); out = Yap_unify(gt(), t1.term());
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
bool YAPTerm::unifiable(YAPTerm t1) { bool YAPTerm::unifiable(YAPTerm t1) {
int out; int out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
out = Yap_Unifiable(Deref(t), Deref(t1.t)); out = Yap_Unifiable(gt(), t1.term());
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
bool YAPTerm::variant(YAPTerm t1) { bool YAPTerm::variant(YAPTerm t1) {
int out; int out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
out = Yap_Variant(Deref(t), Deref(t1.t)); out = Yap_Variant(gt(), t1.term());
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
intptr_t YAPTerm::hash(size_t sz, size_t depth, bool variant) { intptr_t YAPTerm::hash(size_t sz, size_t depth, bool variant) {
Int out; intptr_t out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
out = Yap_TermHash(t, sz, depth, variant); out = Yap_TermHash(gt(), sz, depth, variant) ;
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return out; return out;
} }
char *YAPTerm::text(void) {
size_t sze = 4096, length;
char *os;
int enc;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%p/t=(%d) %x", LCL0, t, LCL0[-15]) ; }
BACKUP_MACHINE_REGS();
if (!(os = Yap_HandleToString(t, sze, &length, &enc, 0))) {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "IIa LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; }
RECOVER_MACHINE_REGS();
return NULL;
}
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; }
RECOVER_MACHINE_REGS();
return os;
}
bool YAPListTerm::nil() {
CACHE_REGS
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "t=%d LCL0+t=(%p)", t, LCL0+t) ;
return gt() == TermNil;
}
YAPIntegerTerm::YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
/*
YAPTerm *YAPTerm::vars()
{
BACKUP_MACHINE_REGS();
CACHE_REGS
YAPPairTerm lv = YAPPairTerm(Yap_TermVariables(gt(), 0 PASS_REGS));
RECOVER_MACHINE_REGS();
return lv;
}
*/
YAPTerm::YAPTerm(void *ptr) { CACHE_REGS mk( MkIntegerTerm( (Int)ptr ) );}
YAPTerm::YAPTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
YAPTerm YAPListTerm::car()
{
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "t=%d LCL0+t=(%p)", t, LCL0+t) ; }
Term to = gt();
if (IsPairTerm(to))
return YAPTerm(HeadOfTerm(to));
else
return MkIntTerm(-1);
}
YAPVarTerm::YAPVarTerm() { CACHE_REGS mk( MkVarTerm( ) ); }
char *YAPAtom::name(void) { char *YAPAtom::name(void) {
if (IsWideAtom(a)) { if (IsWideAtom(a)) {
// return an UTF-8 version // return an UTF-8 version
size_t sz = 512; size_t sz = 512;
wchar_t * ptr = a->WStrOfAE; wchar_t * ptr = a->WStrOfAE;
int ch = -1; int ch = -1;
char *s = new char[sz], *op = s; char *s = new char[sz], *op = s;
while (ch) { while (ch) {
ch = *ptr++; ch = *ptr++;
utf8_put_char( op, ch ); utf8_put_char( op, ch );
} }
sz = strlen(s)+1; sz = strlen(s)+1;
char *os = new char[sz]; char *os = new char[sz];
memcpy(os, s, sz); memcpy(os, s, sz);
delete s; delete s;
return os; return os;
} else if (IsBlob(a)) { } else if (IsBlob(a)) {
PL_blob_t *type = RepBlobProp(a->PropsOfAE)->blob_t; PL_blob_t *type = RepBlobProp(a->PropsOfAE)->blob_t;
size_t sz = 512; size_t sz = 512;
if (type->write) { if (type->write) {
char *s = new char[sz]; char *s = new char[sz];
IOSTREAM *stream = Sopenmem(&s, &sz, "w"); IOSTREAM *stream = Sopenmem(&s, &sz, "w");
stream->encoding = ENC_UTF8; stream->encoding = ENC_UTF8;
atom_t at = YAP_SWIAtomFromAtom(AbsAtom(a)); atom_t at = YAP_SWIAtomFromAtom(AbsAtom(a));
type->write(stream, at, 0); type->write(stream, at, 0);
Sclose(stream); Sclose(stream);
popOutputContext(); popOutputContext();
sz = strlen(s)+1; sz = strlen(s)+1;
char *os = new char[sz]; char *os = new char[sz];
memcpy(os, s, sz); memcpy(os, s, sz);
delete s; delete s;
return os; return os;
} else { } else {
char *s = new char[sz]; char *s = new char[sz];
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
snprintf(s, sz, "'%s'(%p)", AtomSWIStream->StrOfAE, a); snprintf(s, sz, "'%s'(%p)", AtomSWIStream->StrOfAE, a);
#else #else
snprintf(s, sz, "'%s'(0x%p)", AtomSWIStream->StrOfAE, a); snprintf(s, sz, "'%s'(0x%p)", AtomSWIStream->StrOfAE, a);
#endif #endif
char *os = new char[sz]; char *os = new char[sz];
memcpy(os, s, sz); memcpy(os, s, sz);
delete s; delete s;
return os; return os;
} }
} else { } else {
return a->StrOfAE; return a->StrOfAE;
} }
} }
void YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) {
YAPQuery::initQuery( Term *t ) CACHE_REGS
{ vnames = Yap_NewSlots(1 PASS_REGS);
CACHE_REGS Term t = Yap_StringToTerm(s, strlen(s)+1, vnames);
ap = getPred( t, outp );
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; }
}
this->oq = (YAPQuery *)LOCAL_execution; YAPPredicate::YAPPredicate(YAPAtom at) {
LOCAL_execution = (struct open_query_struct *)this; CACHE_REGS
this->q_open=1; ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
this->q_state=0; }
this->q_flags = 0;
this->q_g = t; YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,CurrentModule));
} else {
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
}
}
/// auxiliary routine to find a predicate in the current module.
PredEntry *YAPPredicate::getPred( Term t, Term **outp ) {
CACHE_REGS
Term m = CurrentModule ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) {
ap = NULL;
if (outp) *outp = NULL;
}
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
if (outp) *outp = NULL;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE));
if (outp) *outp = HR;
HR[0] = RepPair(t)[0];
HR[1] = m;
HR+=2;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
ap = NULL;
if (outp) *outp = NULL;
}
ap = RepPredProp(PredPropByFunc(f, m));
if (outp) *outp = RepAppl(t)+1;
}
return ap;
}
YAPPredicate::YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
}
void
YAPQuery::initQuery( Term *ts )
{
CACHE_REGS
this->oq = (YAPQuery *)LOCAL_execution;
LOCAL_execution = (struct open_query_struct *)this;
this->q_open=1;
this->q_state=0;
this->q_flags = 0;
this->q_g = ts;
}
void
YAPQuery::initQuery( YAPTerm t[], arity_t arity )
{
Term *ts = new Term[arity];
for (arity_t i = 0; i < arity; i++)
ts[i] = t[i].term();
return initQuery( ts );
} }
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]): YAPPredicate(f, mod) YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]): YAPPredicate(f, mod)
{ {
/* ignore flags for now */ /* ignore flags for now */
initQuery( (Term *)t ); initQuery( t , f.arity());
} }
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm t[]): YAPPredicate(f) YAPQuery::YAPQuery(YAPFunctor f, YAPTerm t[]): YAPPredicate(f)
{ {
/* ignore flags for now */ /* ignore flags for now */
initQuery( (Term *)t ); initQuery( t , f.arity());
} }
YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap) YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap)
{ {
initQuery( (Term *)t ); initQuery( t , p.ap->ArityOfPE);
} }
YAPQuery::YAPQuery(char *s): YAPPredicate(s, &this->q_g) YAPListTerm YAPQuery::namedVars() {
{ { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "vnames=%d LCL0=%p %x", vnames, LCL0, LCL0[vnames]) ; }
Term *t = this->q_g; CACHE_REGS
Term o = Yap_GetFromSlot( vnames PASS_REGS );
initQuery( t ); return YAPListTerm( o );
} }
bool YAPQuery::next()
int YAPQuery::next()
{ {
CACHE_REGS CACHE_REGS
int result; int result;
if (this->q_open != 1) return 0; { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, " CALL vnames=%d ap=%p LCL0=%p %x", vnames, ap, LCL0, LCL0[vnames]) ; }
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env)) if (this->q_open != 1) return false;
return 0; if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
// don't forget, on success these guys must create slots return false;
if (this->q_state == 0) { // don't forget, on success these guys must create slots
result = YAP_EnterGoal((YAP_PredEntryPtr)this->ap, this->q_g, &this->q_h); if (this->q_state == 0) {
} else { extern void toggle_low_level_trace(void);
LOCAL_AllowRestart = this->q_open; //toggle_low_level_trace();
result = YAP_RetryGoal(&this->q_h); result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)this->ap, this->q_g, &this->q_h);
} } else {
this->q_state = 1; LOCAL_AllowRestart = this->q_open;
if (result == 0) { result = (bool)YAP_RetryGoal(&this->q_h);
YAP_LeaveGoal(FALSE, &this->q_h); }
this->q_open = 0; this->q_state = 1;
} { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "FAIL vnames=%d %d LCL0=(%p) %x", vnames, result, LCL0, LCL0[vnames]) ; }
return result; if (!result) {
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
}
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "SUCCESS vnames=%d ap=%p LCL0=(%p) %x", vnames, ap, LCL0, LCL0[vnames]) ; }
return result;
} }
void YAPQuery::cut() void YAPQuery::cut()
{ {
CACHE_REGS CACHE_REGS
if (this->q_open != 1 || this->q_state == 0) return; if (this->q_open != 1 || this->q_state == 0) return;
YAP_LeaveGoal(FALSE, &this->q_h); YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0; this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq; LOCAL_execution = (struct open_query_struct *)this->oq;
} }
void YAPQuery::close() void YAPQuery::close()
{ {
CACHE_REGS CACHE_REGS
if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) { if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) {
EX = NULL; EX = NULL;
} }
/* need to implement backtracking here */ /* need to implement backtracking here */
if (this->q_open != 1 || this->q_state == 0) { if (this->q_open != 1 || this->q_state == 0) {
return; return;
} }
YAP_LeaveGoal(FALSE, &this->q_h); YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0; this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq; LOCAL_execution = (struct open_query_struct *)this->oq;
} }
int YAPPredicate::call(YAPTerm t[]) int YAPPredicate::call(YAPTerm t[])
{ {
YAPQuery q = YAPQuery(*this, t); YAPQuery q = YAPQuery(*this, t);
int ret = q.next(); int ret = q.next();
q.cut(); q.cut();
q.close(); q.close();
return ret; return ret;
} }
YAPEngine::YAPEngine(YAPParams const& params) static YAPEngine *curren;
{ YAP_Init( (YAP_init_args *)&params.init_args ); }
#if __ANDROID__
#include <jni.h>
#include <string.h>
extern AAssetManager *assetManager;
extern char *Yap_AndroidBufp;
static size_t Yap_AndroidMax, Yap_AndroidSz;
extern void(*Yap_DisplayWithJava)(int c);
static void
displayWithJava(int c)
{
char *ptr = Yap_AndroidBufp;
ptr[ Yap_AndroidSz++ ] = c;
if (Yap_AndroidMax-1 == Yap_AndroidSz) {
if (Yap_AndroidMax < 32*1024) {
Yap_AndroidMax *= 2;
} else {
Yap_AndroidMax += 32*1024;
}
Yap_AndroidBufp = (char *)realloc( ptr, Yap_AndroidMax);
}
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
if (c == '\n' ) {
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "after char %c:%s %p",c, Yap_AndroidBufp, curren);
curren->display(Yap_AndroidBufp);
Yap_AndroidSz = 0;
}
}
#endif
YAPEngine::YAPEngine( char *savedState,
size_t stackSize,
size_t trailSize,
size_t maxStackSize,
size_t maxTrailSize,
char *libDir,
char *bootFile,
char *goal,
char *topLevel,
bool script,
bool fastBoot,
YAPCallback *cb): _callback(0)
{ // a single engine can be active
#if __ANDROID__
if (assetManager == NULL)
return;
Yap_DisplayWithJava = displayWithJava;
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
Yap_AndroidBufp[0] = '\0';
Yap_AndroidSz = 0;
#endif
memset((void *)&init_args, 0, sizeof(init_args));
init_args.SavedState = savedState;
init_args.StackSize = stackSize;
init_args.TrailSize = trailSize;
init_args.MaxStackSize = maxStackSize;
init_args.MaxTrailSize = maxTrailSize;
init_args.YapLibDir = libDir;
init_args.YapPrologBootFile = bootFile;
init_args.YapPrologGoal = goal;
init_args.YapPrologTopLevelGoal = topLevel;
init_args.HaltAfterConsult = script;
init_args.FastBoot = fastBoot;
delYAPCallback();
if (cb) setYAPCallback(cb);
curren = this;
YAP_Init( &init_args );
}
YAPQuery *YAPEngine::query( char *s ) {
YAPQuery *n = new YAPQuery( s );
return n;
}

View File

@ -13,16 +13,26 @@
* with the swig interface language generator. It uses ideas from the old YAP * with the swig interface language generator. It uses ideas from the old YAP
* interface and from the SWI foreign language interface. * interface and from the SWI foreign language interface.
* *
* @{
*
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <config.h> #include <config.h>
extern "C" {
#ifdef __cplusplus
#define old_cplusplus __cplusplus
#undef __cplusplus
#endif
#if USE_GMP #if USE_GMP
#include <gmp.h> #include <gmp.h>
#endif #endif
#ifdef old_cplusplus
extern "C" { #define __cplusplus old_cplusplus
#undef old_cplusplus
#endif
#include "Yap.h" #include "Yap.h"
@ -60,373 +70,476 @@ extern "C" {
#include <windows.h> #include <windows.h>
#endif #endif
// taken from yap_structs.h // taken from yap_structs.h
#include "iopreds.h" #include "iopreds.h"
// we cannot consult YapInterface.h, that conflicts with what we declare, though extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
// it shouldn't
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
} }
//#include <vector> //#include <vector>
class YAPEngine; class YAPEngine;
class YAPTermHandle;
class YAPAtom; class YAPAtom;
class YAPFunctor; class YAPFunctor;
class YAPApplTerm;
class YAPPairTerm;
class YAPQuery; class YAPQuery;
class TypeError {};
/** /**
* @brief Generic Prolog Term * @brief Generic Prolog Term
*/ */
class YAPTerm { class YAPTerm {
friend class YAPPredicate; friend class YAPPredicate;
friend class YAPTermHandle; friend class YAPApplTerm;
friend class YAPApplTerm; friend class YAPPairTerm;
friend class YAPPairTerm; friend class YAPListTerm;
protected: protected:
Term t; handle_t t;
void mk(Term t0);
Term gt();
YAPTerm(Term tn) { mk( tn ); }
public: public:
YAPTerm() { t = TermNil; } // do nothing constructor YAPTerm() { mk(TermNil); } // do nothing constructor
YAPTerm(void *ptr) { CACHE_REGS t = MkIntegerTerm( (Int)ptr ); } YAPTerm(intptr_t i);
YAPTerm(Term tn) { t = tn; } YAPTerm(void *ptr);
YAPTerm(char *s) { Term tp ; t = YAP_ReadBuffer(s,&tp); } YAPTerm(char *s) { Term tp ; mk( YAP_ReadBuffer(s,&tp) ); }
/*~YAPTerm(void) {
CACHE_REGS
Yap_RecoverSlots(1, t PASS_REGS);
}*/
Term term() { return gt(); }
YAP_tag_t tag();
YAPTerm deepCopy();
//const YAPTerm *vars();
bool exactlyEqual(YAPTerm t1);
bool unify(YAPTerm t1);
bool unifiable(YAPTerm t1);
bool variant(YAPTerm t1);
intptr_t hash(size_t sz, size_t depth, bool variant);
bool isVar() { return IsVarTerm( gt() ); }
bool isAtom() { return IsAtomTerm( gt() ); }
bool isInteger() { return IsIntegerTerm( gt() ); }
bool isFloat() { return IsFloatTerm( gt() ); }
bool isCompound() { return !(IsVarTerm( gt() ) || IsNumTerm( gt() )); }
bool isAppl() { return IsApplTerm( gt() ); }
bool isPair() { return IsPairTerm( gt() ); }
bool isGround() { return Yap_IsGroundTerm( gt() ); }
bool isList() { return Yap_IsListTerm( gt() ); }
bool isString() { return IsStringTerm( gt() ); }
YAP_tag_t tag(); inline YAPTerm getArg(int i) {
YAPTerm deepCopy(); Term t0 = gt();
bool exactlyEqual(YAPTerm t1); if (IsApplTerm(t0))
bool unify(YAPTerm t1); return YAPTerm(ArgOfTerm(i, t0));
bool unifiable(YAPTerm t1); else if (IsPairTerm(t0)) {
bool variant(YAPTerm t1); if (i==1)
intptr_t hash(size_t sz, size_t depth, bool variant); return YAPTerm(HeadOfTerm(t0));
bool isVar() { return IsVarTerm(t); } if (i==2)
bool isAtom() { return IsAtomTerm(t); } return YAPTerm(TailOfTerm(t0));
bool isInteger() { return IsIntegerTerm(t); } }
bool isFloat() { return IsFloatTerm(t); } return YAPTerm((Term)0);
bool isCompound() { return !(IsVarTerm(t) || IsNumTerm(t)); } }
bool isAppl() { return IsApplTerm(t); } char *text();
bool isPair() { return IsPairTerm(t); }
bool isGround() { return Yap_IsGroundTerm(t); }
bool isList() { return Yap_IsListTerm(t); }
bool isString() { return IsStringTerm(t); }
}; };
/** /**
* @brief Variable Term * @brief Variable Term
*/ */
class YAPVarTerm: private YAPTerm { class YAPVarTerm: public YAPTerm {
YAPVarTerm(Term t) { if (IsVarTerm(t)) mk( t ); }
public: public:
YAPVarTerm(): YAPTerm() { CACHE_REGS t = MkVarTerm(); } YAPVarTerm();
CELL *getVar() { return VarOfTerm(t); } CELL *getVar() { return VarOfTerm( gt() ); }
bool unbound() { return IsUnboundVar(VarOfTerm(t)); } bool unbound() { return IsUnboundVar(VarOfTerm( gt() )); }
}; };
/** /**
* @brief Compound Term * @brief Compound Term
*/ */
class YAPApplTerm: private YAPTerm { class YAPApplTerm: public YAPTerm {
friend class YAPTerm;
YAPApplTerm(Term t0) { mk(t0); }
public: public:
YAPApplTerm(YAPFunctor f, YAPTerm ts[]); YAPApplTerm(YAPTerm t0) { mk(t0.term()); }
YAPApplTerm(YAPFunctor f); YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
YAPFunctor getFunctor(); YAPApplTerm(YAPFunctor f);
YAPTerm getArg(unsigned int i); YAPFunctor getFunctor();
YAPTerm getArg(int i);
}; };
/** /**
* @brief List Constructor Term * @brief List Constructor Term
*/ */
class YAPPairTerm: private YAPTerm { class YAPPairTerm: public YAPTerm {
friend class YAPTerm;
YAPPairTerm(Term t0) { if (IsPairTerm(t0)) mk( t0 ); else mk(0); }
public: public:
YAPPairTerm(YAPTerm hd, YAPTerm tl); YAPPairTerm(YAPTerm hd, YAPTerm tl);
YAPPairTerm(); YAPPairTerm();
YAPTerm getHead() { return YAPTerm(HeadOfTerm(t)); } YAPTerm getHead() { return YAPTerm(HeadOfTerm( gt() )); }
YAPTerm getTail() { return YAPTerm(TailOfTerm(t)); } YAPTerm getTail() { return YAPTerm(TailOfTerm( gt() )); }
}; };
/** /**
* @brief Integer Term * @brief Integer Term
*/ */
class YAPIntegerTerm: private YAPTerm { class YAPIntegerTerm: public YAPTerm {
public: public:
YAPIntegerTerm(intptr_t i) { CACHE_REGS t = MkIntegerTerm( i ); } YAPIntegerTerm(intptr_t i);
intptr_t getInteger(YAPIntegerTerm t) { return IntegerOfTerm(t.t); } intptr_t getInteger() { return IntegerOfTerm( gt() ); }
bool isTagged(YAPIntegerTerm i) { return IsIntTerm( t ); } bool isTagged() { return IsIntTerm( gt() ); }
}; };
/* class YAPListTerm: public YAPTerm {
class YAPListTerm: private YAPPairTerm {
public: public:
YAPListTerm(YAPTerm ts[], size_t n); /// Create a list term out of a standard term. Check if a valid operation.
YAPListTerm(Term ts[], size_t n); ///
YAPListTerm( vector<YAPTerm> v ); /// @param[in] the term
size_t length() { Term *tailp; return Yap_SkipList(&t, &tailp); } YAPListTerm(Term t0) { mk(t0); /* else type_error */ }
vector<YAPTerm> toVector(); /* /// Create a list term out of an array of terms.
///
/// @param[in] the array of terms
/// @param[in] the length of the array
YAPListTerm(YAPTerm ts[], size_t n);
*/
// YAPListTerm( vector<YAPTerm> v );
/// Return the number of elements in a list term.
size_t length() { Term *tailp; Term t1 = gt(); return Yap_SkipList(&t1, &tailp); }
/// Extract the first element of a list.
///
/// @param[in] the list
YAPTerm car();
/// Extract the tail elements of a list.
///
/// @param[in] the list
YAPListTerm cdr()
{
Term to = gt();
if (IsPairTerm( to ))
return YAPListTerm(TailOfTerm( to ));
else
return MkIntTerm(-1);
}
/// Check if the list is empty.
///
/// @param[in] the list
bool nil();
}; };
*/
/** /**
* @brief Atom * @brief Atom
*/ */
class YAPAtom { class YAPAtom {
friend class YAPPredicate; friend class YAPPredicate;
friend class YAPFunctor; friend class YAPFunctor;
friend class YAPAtomTerm; friend class YAPAtomTerm;
Atom a; Atom a;
public: public:
YAPAtom( Atom at ) { a = at; } YAPAtom( Atom at ) { a = at; }
YAPAtom( char * s) { a = Yap_LookupAtom( s ); } YAPAtom( char * s) { a = Yap_LookupAtom( s ); }
YAPAtom( wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); } YAPAtom( wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
YAPAtom( char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); } YAPAtom( char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
YAPAtom( wchar_t * s, size_t len) { a = Yap_LookupMaybeWideAtomWithLength( s, len ); } YAPAtom( wchar_t * s, size_t len) { a = Yap_LookupMaybeWideAtomWithLength( s, len ); }
char *name(void); char *name(void);
}; };
/** /**
* @brief String Term * @brief String Term
*/ */
class YAPStringTerm: private YAPTerm { class YAPStringTerm: public YAPTerm {
public: public:
YAPStringTerm(char *s) ; YAPStringTerm(char *s) ;
YAPStringTerm(char *s, size_t len); YAPStringTerm(char *s, size_t len);
YAPStringTerm(wchar_t *s) ; YAPStringTerm(wchar_t *s) ;
YAPStringTerm(wchar_t *s, size_t len); YAPStringTerm(wchar_t *s, size_t len);
const char *getString() { return StringOfTerm(t); } const char *getString() { return StringOfTerm( gt() ); }
}; };
/** /**
* @brief Atom Term * @brief Atom Term
*/ */
class YAPAtomTerm: private YAPTerm { class YAPAtomTerm: public YAPTerm {
public: public:
YAPAtomTerm(YAPAtom a): YAPTerm() { t = MkAtomTerm(a.a); } YAPAtomTerm(YAPAtom a): YAPTerm() { mk( MkAtomTerm(a.a) ); }
YAPAtomTerm(Atom a): YAPTerm() { t = MkAtomTerm(a); } YAPAtomTerm(Atom a): YAPTerm() { mk( MkAtomTerm(a) ); }
YAPAtomTerm(char *s) ; YAPAtomTerm(char *s) ;
YAPAtomTerm(char *s, size_t len); YAPAtomTerm(char *s, size_t len);
YAPAtomTerm(wchar_t *s) ; YAPAtomTerm(wchar_t *s) ;
YAPAtomTerm(wchar_t *s, size_t len); YAPAtomTerm(wchar_t *s, size_t len);
YAPAtom getAtom() { return YAPAtom(AtomOfTerm(t)); } YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
}; };
/** /**
* @brief Functor * @brief YAPFunctor represents Prolog functors Name/Arity
*/ */
class YAPFunctor { class YAPFunctor {
friend class YAPApplTerm; friend class YAPApplTerm;
friend class YAPPredicate; friend class YAPPredicate;
Functor f; Functor f;
/// Constructor: receives Prolog functor and casts it to YAPFunctor
///
/// Notice that this is designed for internal use only.
YAPFunctor( Functor ff) { f = ff; }
public: public:
YAPFunctor( char * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); } /// Constructor: receives name as a string plus arity
YAPFunctor( wchar_t * s, unsigned int arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ); } ///
YAPFunctor( YAPAtom at, unsigned int arity) { f = Yap_MkFunctor( at.a, arity ); } /// Notice that this is designed for ISO-LATIN-1 right now
YAPFunctor( Functor ff) { f = ff; } YAPFunctor( char * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupAtom( s ), arity ); }
/// Constructor: receives name as a wide string plus arity
///
/// Notice that this is designed for UNICODE right now
YAPFunctor( wchar_t * s, arity_t arity) { f = Yap_MkFunctor( Yap_LookupWideAtom( s ), arity ); }
/// Constructor: receives name as an atom, plus arity
///
/// This is the default method, and the most popi;at
YAPFunctor( YAPAtom at, arity_t arity) { f = Yap_MkFunctor( at.a, arity ); }
Atom name(void) { /// Getter: extract name of functor as an atom
return NameOfFunctor( f ); ///
} /// this is for external usage.
YAPAtom name(void) {
return YAPAtom( NameOfFunctor( f ) );
}
unsigned int arity(void) { /// Getter: extract arity of functor as an unsigned integer
return ArityOfFunctor( f ); ///
} /// this is for external usage.
arity_t arity(void) {
return ArityOfFunctor( f );
}
}; };
/** /**
* @brief Term Handle * @brief Predicates
*/ *
class YAPTermHandle { * This class interfaces with PredEntry in Yatom.g
long int handle;
public:
YAPTermHandle(Term t) {
CACHE_REGS
handle = Yap_InitSlot(t PASS_REGS);
}
~YAPTermHandle(void) {
CACHE_REGS
Yap_RecoverSlots(1, handle PASS_REGS);
}
YAPTerm get() {
CACHE_REGS
return new YAPTerm( Yap_GetFromSlot(handle PASS_REGS) );
}
void set(YAPTerm t) {
CACHE_REGS
Yap_PutInSlot(handle, t.t PASS_REGS);
}
};
/**
* @brief Predicate
*/ */
class YAPPredicate { class YAPPredicate {
friend class YAPQuery; friend class YAPQuery;
PredEntry *ap;
// trick to communicate t[] back to yapquery private:
YAPPredicate(char *s, Term **th) { PredEntry *ap;
CACHE_REGS
Term t, tp, m = CurrentModule ; /// auxiliary routine to find a predicate in the current module.
t = YAP_ReadBuffer(s,&tp); PredEntry *getPred( Term t, Term **outp ) ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) /// String constructor for predicates
ap = NULL; ///
if (IsAtomTerm(t)) { /// It also communicates the array of arguments t[] abd the array of variables
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m)); /// back to yapquery
*th = NULL; YAPPredicate(const char *s, Term **outp, handle_t& vnames );
} else if (IsApplTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m)); /// Term constructor for predicates
*th = RepAppl(t)+1; ///
} else { /// It is just a call to getPred
ap = NULL; inline YAPPredicate(Term t) {
} ap = getPred( t , NULL );
} }
/// Cast constructor for predicates,
/// if we have the implementation data.
///
inline YAPPredicate(PredEntry *pe) {
ap = pe;
}
public: public:
YAPPredicate(PredEntry *pe) {
ap = pe; /// Functor constructor for predicates
} ///
YAPPredicate(YAPFunctor f) { /// Asssumes that we use the current module.
CACHE_REGS YAPPredicate(YAPFunctor f);
ap = RepPredProp(PredPropByFunc(f.f,CurrentModule));
} /// Functor constructor for predicates, is given a specific module.
YAPPredicate(YAPFunctor f, YAPTerm mod) { ///
ap = RepPredProp(PredPropByFunc(f.f,mod.t)); inline YAPPredicate(YAPFunctor f, YAPTerm mod) {
} ap = RepPredProp(PredPropByFunc(f.f,mod.t));
YAPPredicate(YAPAtom at, YAPTerm mod) { }
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
} /// Name/arity constructor for predicates.
YAPPredicate(YAPAtom at) { ///
CACHE_REGS inline YAPPredicate(YAPAtom at, YAPTerm mod) {
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule)); ap = RepPredProp(PredPropByAtom(at.a,mod.t));
} }
YAPPredicate(YAPAtom at, unsigned int arity, YAPTerm mod) {
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity); /// Name/0 constructor for predicates.
ap = RepPredProp(PredPropByFunc(f,mod.t)); ///
} else { YAPPredicate(YAPAtom at);
ap = RepPredProp(PredPropByAtom(at.a,mod.t));
} /// Mod:Name/Arity constructor for predicates.
} ///
YAPPredicate(YAPAtom at, unsigned int arity) { inline YAPPredicate(YAPAtom at, arity_t arity, YAPTerm mod) {
CACHE_REGS if (arity) {
if (arity) { Functor f = Yap_MkFunctor(at.a, arity);
Functor f = Yap_MkFunctor(at.a, arity); ap = RepPredProp(PredPropByFunc(f,mod.t));
ap = RepPredProp(PredPropByFunc(f,CurrentModule)); } else {
} else { ap = RepPredProp(PredPropByAtom(at.a,mod.t));
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule)); }
} }
}
YAPPredicate(char *s) { /// Atom/Arity constructor for predicates.
CACHE_REGS ///
Term t, tp, m = CurrentModule ; YAPPredicate(YAPAtom at, arity_t arity);
t = YAP_ReadBuffer(s,&tp);
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) /// String constructor for predicates.
ap = NULL; ///
if (IsAtomTerm(t)) { /// String is a Prolog term, we extract the main functor after considering the module qualifiers.
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m)); inline YAPPredicate(char *s) {
} else { Term t, tp;
ap = RepPredProp(PredPropByFunc(FunctorOfTerm(t), m)); t = YAP_ReadBuffer(s,&tp);
} ap = getPred( t, NULL );
} }
int call(YAPTerm ts[]);
/// String constructor for predicates, also keeps arguments in tp[]
///
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
inline YAPPredicate(char *s, Term **outp) {
Term t, tp;
t = YAP_ReadBuffer(s,&tp);
ap = getPred( t, NULL );
}
/// meta-call this predicate, with arguments ts[]
///
int call(YAPTerm ts[]);
/// module of a predicate
///
/// notice that modules are currently treated as atoms, this should change.
YAPAtom module() {
if (ap->ModuleOfPred == PROLOG_MODULE)
return YAPAtom(AtomProlog);
else
return YAPAtom(AtomOfTerm(ap->ModuleOfPred));
}
/// name of predicate
///
/// notice that we return the atom, not a string.
YAPAtom name() { if (ap->ArityOfPE)
return YAPAtom((Atom)ap->FunctorOfPred);
else
return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
}
/// arity of predicate
///
/// we return a positive number.
arity_t getArity() { return ap->ArityOfPE; }
}; };
/** /**
* @brief Term Handle * @brief Queries
* *
* interface to a YAP Query; * interface to a YAP Query;
* uses an SWI-like status info internally. * uses an SWI-like status info internally.
*/ */
class YAPQuery: private YAPPredicate { class YAPQuery: public YAPPredicate {
int q_open; int q_open;
int q_state; int q_state;
Term *q_g; Term *q_g;
yamop *q_p, *q_cp; yamop *q_p, *q_cp;
jmp_buf q_env; jmp_buf q_env;
int q_flags; int q_flags;
YAP_dogoalinfo q_h; YAP_dogoalinfo q_h;
YAPQuery *oq; YAPQuery *oq;
void initQuery( Term *t ); handle_t vnames;
void initQuery( Term ts[] );
void initQuery( YAPTerm t[], arity_t arity );
public: public:
/// full constructor, is given a functor, module, and an array of terms that must hav at least /// main constructor, uses a predicate and an array of terms
/// the same arity as the functor. ///
YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]); /// It is given a YAPPredicate _p_ , and an array of terms that must have at least
YAPQuery(YAPFunctor f, YAPTerm t[]); /// the same arity as the functor.
YAPQuery(YAPPredicate p, YAPTerm t[]); YAPQuery(YAPPredicate p, YAPTerm t[]);
YAPQuery(char *s); /// full constructor,
// YAPQuery(YAPTerm t); ///
int next(); /// It is given a functor, module, and an array of terms that must have at least
void cut(); /// the same arity as the functor.
void close(); YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]);
/// functor/term constructor,
///
/// It is given a functor, and an array of terms that must have at least
/// the same arity as the functor. Works within the current module.
YAPQuery(YAPFunctor f, YAPTerm t[]);
/// string constructor with varnames
///
/// It is given a string, calls the parser and obtains a Prolog term that should be a callable
/// goal and a list of variables. Useful for top-level simulation. Works within the current module.
inline YAPQuery(char *s): YAPPredicate(s, &this->q_g, vnames)
{
Term *ts = this->q_g;
initQuery( ts );
}
/// first query
///
/// actually implemented by calling the next();
inline bool first() { return next(); }
/// ask for the next solution of the current query
/// same call for every solution
bool next();
/// remove alternatives in the current search space, and finish the current query
void cut();
/// finish the current query: undo all bindings.
void close();
/// query variables.
YAPListTerm namedVars();
}; };
class YAPParams; // Java support
// This class implements a callback Prolog-side
class YAPCallback {
public:
virtual ~YAPCallback() { printf("~YAPCallback\n"); }
virtual void run() { __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "callback"); }
virtual void displayInWindow(char *s) { }
};
/** /**
* @brief YAP Constructor * @brief YAP Engine: takes care of constructing an execution environment where we can go executing goals
* *
*/ */
class YAPEngine { class YAPEngine {
private:
YAPCallback *_callback;
char **buf;
YAP_init_args init_args;
public: public:
YAPEngine(YAPParams const& params); /// construct a new engine YAPEngine(char *savedState = NULL,
YAPQuery *query( char *s ) { return new YAPQuery( s ); } /// build a query on the engine size_t stackSize = 0,
size_t trailSize = 0,
size_t maxStackSize = 0,
size_t maxTrailSize = 0,
char *libDir = NULL,
char *bootFile = NULL,
char *goal = NULL,
char *topLevel = NULL,
bool script = FALSE,
bool fastBoot = FALSE,
YAPCallback *callback=NULL); /// construct a new engine, including aaccess to callbacks
~YAPEngine() { delYAPCallback(); } /// kill engine
void delYAPCallback() { _callback = 0; } /// remove current callback
void setYAPCallback(YAPCallback *cb) { delYAPCallback(); _callback = cb; __android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %p",cb); } /// set a new callback
void call() { if (_callback) _callback->run(); } /// execute the callback.
void display( char *s) { __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "bef calling disp %s %p",s, _callback); if (_callback) _callback->displayInWindow(s); } /// execute the callback.
YAPQuery *query( char *s ); /// build a query on the engine
}; };
/** /*
* @brief Parameters for YAP Constructor * @}
* *
*/ */
class YAPParams {
friend class YAPEngine;
YAP_init_args init_args;
public:
YAPParams();
// sets all the default values for each data member
YAPParams& savedState( char * f);
YAPParams& stackSize(size_t sz);
YAPParams& trailSize(size_t sz);
YAPParams& maxStackSize(size_t sz);
YAPParams& maxTrailSize(size_t sz);
YAPParams& libDir(char *p);
YAPParams& bootFile(char *f);
YAPParams& goal(char *g);
YAPParams& topLevel(char *g);
YAPParams& script(bool v);
YAPParams& fastBoot(bool v);
};
inline YAPParams::YAPParams()
{ Yap_InitDefaults( &init_args, NULL ); }
inline YAPParams& YAPParams::savedState( char * f)
{ init_args.SavedState = f; return *this; }
inline YAPParams& YAPParams::stackSize(size_t sz)
{ init_args.StackSize = sz; return *this; }
inline YAPParams& YAPParams::trailSize(size_t sz)
{ init_args.TrailSize = sz; return *this; }
inline YAPParams& YAPParams::maxStackSize(size_t sz)
{ init_args.MaxStackSize = sz; return *this; }
inline YAPParams& YAPParams::maxTrailSize(size_t sz)
{ init_args.MaxTrailSize = sz; return *this; }
inline YAPParams& YAPParams::libDir(char *p)
{ init_args.YapLibDir = p; return *this; }
inline YAPParams& YAPParams::bootFile(char *f)
{ init_args.YapPrologBootFile = f; return *this; }
inline YAPParams& YAPParams::goal(char *g)
{ init_args.YapPrologGoal = g; return *this; }
inline YAPParams& YAPParams::topLevel(char *g)
{ init_args.YapPrologTopLevelGoal = g; return *this; }
inline YAPParams& YAPParams::script(bool v)
{ init_args.HaltAfterConsult = v; return *this; }
inline YAPParams& YAPParams::fastBoot(bool v)
{ init_args.FastBoot = v; return *this; }

View File

@ -107,6 +107,7 @@ typedef struct PropEntryStruct
#define MaxArity 255 #define MaxArity 255
typedef CELL arity_t;
#define FunctorProperty ((PropFlags)(0xbb00)) #define FunctorProperty ((PropFlags)(0xbb00))
@ -115,7 +116,7 @@ typedef struct FunctorEntryStruct
{ {
Prop NextOfPE; /* used to chain properties */ Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */ PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */ arity_t ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */ Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */ Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)

View File

@ -691,6 +691,33 @@ INLINE_ONLY EXTERN inline void restore_B(void) {
#define BBREG BB #define BBREG BB
#endif /* YAPOR_SBA || TABLING */ #endif /* YAPOR_SBA || TABLING */
// define how to handle frozen segments in tabling, etv.
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define PROTECT_FROZEN_H(CPTR) \
((Unsigned((Int)((CPTR)->cp_h)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR)->cp_h : H_FZ)
#define PROTECT_FROZEN_B(CPTR) \
((Unsigned((Int)(CPTR)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR) : B_FZ)
/*
#define PROTECT_FROZEN_H(CPTR) ((CPTR)->cp_h > H_FZ && (CPTR)->cp_h < (CELL *)B_FZ ? (CPTR)->cp_h : H_FZ )
#define PROTECT_FROZEN_B(CPTR) ((CPTR) < B_FZ && (CPTR) > (choiceptr)H_FZ ? (CPTR) : B_FZ )
*/
#else /* TABLING */
#define PROTECT_FROZEN_B(CPTR) (YOUNGER_CP(CPTR, B_FZ) ? CPTR : B_FZ)
#define PROTECT_FROZEN_H(CPTR) (((CPTR)->cp_h > H_FZ) ? (CPTR)->cp_h : H_FZ)
#endif /* YAPOR_SBA */
#else
#define PROTECT_FROZEN_B(CPTR) (CPTR)
#define PROTECT_FROZEN_H(CPTR) (CPTR)->cp_h
#endif /* FROZEN_STACKS */
#if !defined(THREADS) #if !defined(THREADS)
/* use actual addresses for regs */ /* use actual addresses for regs */
#define PRECOMPUTE_REGADDRESS 1 #define PRECOMPUTE_REGADDRESS 1

15
H/Yap.h
View File

@ -49,6 +49,13 @@
/* bzero */ /* bzero */
#include <strings.h> #include <strings.h>
#endif #endif
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* /*
@ -86,6 +93,10 @@
#define TERM_EXTENSIONS 1 #define TERM_EXTENSIONS 1
#endif /* COROUTINING && !TERM_EXTENSIONS */ #endif /* COROUTINING && !TERM_EXTENSIONS */
/* truth-values */
#define TRUE 1
#define FALSE 0
/* Microsoft's Visual C++ Compiler */ /* Microsoft's Visual C++ Compiler */
#ifdef _MSC_VER /* adjust a config.h from mingw32 to work with vc++ */ #ifdef _MSC_VER /* adjust a config.h from mingw32 to work with vc++ */
#ifdef HAVE_GCC #ifdef HAVE_GCC
@ -155,10 +166,6 @@
#define EXTERN #define EXTERN
#endif /* ADTDEFS_C */ #endif /* ADTDEFS_C */
/* truth-values */
#define TRUE 1
#define FALSE 0
/* null pointer */ /* null pointer */
#define NIL 0 #define NIL 0

View File

@ -28,13 +28,13 @@ hence providing a way to access terms without being exposed to stack shifts or g
of a function. Hence, slots should always be used as local variables. of a function. Hence, slots should always be used as local variables.
Slots are organized as follows: Slots are organized as follows:
---- Offset of next pointer in chain (tagged as an Int) ---- Offset of next pointer in chain (tagged as an handle_t)
---- Number of entries (tagged as Int), in the example TAG(INT,4) ---- Number of entries (tagged as handle_t), in the example TAG(INT,4)
Entry Entry
Entry Entry
Entry Entry
Entry Entry
---- Number of entries (tagged as Int), in the example TAG(INT,4) ---- Number of entries (tagged as handle_t), in the example TAG(INT,4)
Slots are not known to the yaam. Instead, A new set of slots is created when the emulator calls user C-code. Slots are not known to the yaam. Instead, A new set of slots is created when the emulator calls user C-code.
(see YAP_Execute* functions). They are also created: (see YAP_Execute* functions). They are also created:
@ -49,9 +49,9 @@ This section lists the main internal functions for slot management. These functi
*************************************************************************************************/ *************************************************************************************************/
/// @brief start a new set of slots, linking them to the last active slots (who may, or not, be active). /// @brief start a new set of slots, linking them to the last active slots (who may, or not, be active).
static inline Int static inline handle_t
Yap_StartSlots( USES_REGS1 ) { Yap_StartSlots( USES_REGS1 ) {
Int CurSlot = LOCAL_CurSlot; handle_t CurSlot = LOCAL_CurSlot;
// if (CurSlot == LCL0-(ASP+(IntOfTerm(ASP[0])+2))) // if (CurSlot == LCL0-(ASP+(IntOfTerm(ASP[0])+2)))
// return CurSlot; // return CurSlot;
/* new slot */ /* new slot */
@ -65,56 +65,56 @@ Yap_StartSlots( USES_REGS1 ) {
/// @brief reset slots to a well-known position in the stack /// @brief reset slots to a well-known position in the stack
static inline void static inline void
Yap_CloseSlots( Int slot USES_REGS ) { Yap_CloseSlots( handle_t slot USES_REGS ) {
LOCAL_CurSlot = slot; LOCAL_CurSlot = slot;
} }
/// @brief report the current position of the slots, assuming that they occupy the top of the stack. /// @brief report the current position of the slots, assuming that they occupy the top of the stack.
static inline Int static inline handle_t
Yap_CurrentSlot( USES_REGS1 ) { Yap_CurrentSlot( USES_REGS1 ) {
return IntOfTerm(ASP[0]); return IntOfTerm(ASP[0]);
} }
/// @brief read from a slot. /// @brief read from a slot.
static inline Term static inline Term
Yap_GetFromSlot(Int slot USES_REGS) Yap_GetFromSlot(handle_t slot USES_REGS)
{ {
return(Deref(LCL0[slot])); return(Deref(LCL0[slot]));
} }
/// @brief read from a slot. but does not try to dereference the slot. /// @brief read from a slot. but does not try to dereference the slot.
static inline Term static inline Term
Yap_GetDerefedFromSlot(Int slot USES_REGS) Yap_GetDerefedFromSlot(handle_t slot USES_REGS)
{ {
return LCL0[slot]; return LCL0[slot];
} }
/// @brief read the object in a slot. but do not try to dereference the slot. /// @brief read the object in a slot. but do not try to dereference the slot.
static inline Term static inline Term
Yap_GetPtrFromSlot(Int slot USES_REGS) Yap_GetPtrFromSlot(handle_t slot USES_REGS)
{ {
return(LCL0[slot]); return(LCL0[slot]);
} }
/// @brief get the memory address of a slot /// @brief get the memory address of a slot
static inline Term * static inline Term *
Yap_AddressFromSlot(Int slot USES_REGS) Yap_AddressFromSlot(handle_t slot USES_REGS)
{ {
return(LCL0+slot); return(LCL0+slot);
} }
/// @brief store term in a slot /// @brief store term in a slot
static inline void static inline void
Yap_PutInSlot(Int slot, Term t USES_REGS) Yap_PutInSlot(handle_t slot, Term t USES_REGS)
{ {
LCL0[slot] = t; LCL0[slot] = t;
} }
/// @brief allocate n empty new slots /// @brief allocate n empty new slots
static inline Int static inline handle_t
Yap_NewSlots(int n USES_REGS) Yap_NewSlots(int n USES_REGS)
{ {
Int old_slots = IntOfTerm(ASP[0]), oldn = n; handle_t old_slots = IntOfTerm(ASP[0]), oldn = n;
while (n > 0) { while (n > 0) {
RESET_VARIABLE(ASP); RESET_VARIABLE(ASP);
ASP--; ASP--;
@ -128,7 +128,7 @@ Yap_NewSlots(int n USES_REGS)
static inline Int static inline Int
Yap_InitSlot(Term t USES_REGS) Yap_InitSlot(Term t USES_REGS)
{ {
Int old_slots = IntOfTerm(ASP[0]); handle_t old_slots = IntOfTerm(ASP[0]);
*ASP = t; *ASP = t;
ASP--; ASP--;
ASP[old_slots+2] = ASP[0] = MkIntTerm(old_slots+1); ASP[old_slots+2] = ASP[0] = MkIntTerm(old_slots+1);
@ -137,9 +137,9 @@ Yap_InitSlot(Term t USES_REGS)
/// @brief Succeeds if it is to recover the space allocated for $n$ contiguos slots starting at topSlot. /// @brief Succeeds if it is to recover the space allocated for $n$ contiguos slots starting at topSlot.
static inline int static inline int
Yap_RecoverSlots(int n, Int topSlot USES_REGS) Yap_RecoverSlots(int n, handle_t topSlot USES_REGS)
{ {
Int old_slots = IntOfTerm(ASP[0]); handle_t old_slots = IntOfTerm(ASP[0]);
if (old_slots < n) { if (old_slots < n) {
return FALSE; return FALSE;
} }

View File

@ -16,6 +16,13 @@
#ifndef YAP_H #ifndef YAP_H
#include "YapTermConfig.h" #include "YapTermConfig.h"
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
typedef void *Functor; typedef void *Functor;
typedef void *Atom; typedef void *Atom;
@ -31,11 +38,12 @@ typedef void *Atom;
/* defines integer types Int and UInt (unsigned) with the same size as a ptr /* defines integer types Int and UInt (unsigned) with the same size as a ptr
** and integer types Short and UShort with half the size of a ptr */ ** and integer types Short and UShort with half the size of a ptr */
/* */ typedef intptr_t Int;
/* */ typedef uintptr_t UInt;
#if SIZEOF_INT_P==4 #if SIZEOF_INT_P==4
#if SIZEOF_INT==4 #if SIZEOF_INT==4
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#define Int_FORMAT "%d" #define Int_FORMAT "%d"
#define UInt_FORMAT "%u" #define UInt_FORMAT "%u"
@ -62,23 +70,17 @@ typedef void *Atom;
#elif SIZEOF_INT_P==8 #elif SIZEOF_INT_P==8
#if SIZEOF_INT==8 #if SIZEOF_INT==8
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#define Int_FORMAT "%d" #define Int_FORMAT "%d"
#define UInt_FORMAT "%u" #define UInt_FORMAT "%u"
#elif SIZEOF_LONG_INT==8 #elif SIZEOF_LONG_INT==8
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
#define Int_FORMAT "%ld" #define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu" #define UInt_FORMAT "%lu"
# elif SIZEOF_LONG_LONG_INT==8 # elif SIZEOF_LONG_LONG_INT==8
/* */ typedef long long int Int; /
/* */ typedef unsigned long long int UInt;
#define Int_FORMAT "%I64d" #define Int_FORMAT "%I64d"
#define UInt_FORMAT "%I64u" #define UInt_FORMAT "%I64u"
@ -129,6 +131,8 @@ typedef UInt BITS32;
typedef CELL Term; typedef CELL Term;
typedef Int handle_t;
/* */ typedef double Float; /* */ typedef double Float;
#if SIZEOF_INT<SIZEOF_INT_P #if SIZEOF_INT<SIZEOF_INT_P

View File

@ -369,7 +369,7 @@ int Yap_signal_index(const char *);
#ifdef MAC #ifdef MAC
void Yap_SetTextFile(char *); void Yap_SetTextFile(char *);
#endif #endif
int Yap_getcwd(const char *, int); char *Yap_getcwd(const char *, size_t);
void Yap_cputime_interval(Int *,Int *); void Yap_cputime_interval(Int *,Int *);
void Yap_systime_interval(Int *,Int *); void Yap_systime_interval(Int *,Int *);
void Yap_walltime_interval(Int *,Int *); void Yap_walltime_interval(Int *,Int *);
@ -387,6 +387,7 @@ void Yap_WinError(char *);
void Yap_InitThreadPreds(void); void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(void); void Yap_InitFirstWorkerThreadHandle(void);
int Yap_ThreadID( void ); int Yap_ThreadID( void );
int Yap_NOfThreads( void );
#if THREADS #if THREADS
int Yap_InitThread(int); int Yap_InitThread(int);
#endif #endif
@ -427,6 +428,7 @@ int Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void); void Yap_InitUtilCPreds(void);
Int Yap_TermHash(Term, Int, Int, int); Int Yap_TermHash(Term, Int, Int, int);
Int Yap_NumberVars(Term, Int, int); Int Yap_NumberVars(Term, Int, int);
Term Yap_TermVariables( Term t, UInt arity USES_REGS );
Term Yap_UnNumberTerm(Term, int); Term Yap_UnNumberTerm(Term, int);
Int Yap_SkipList(Term *, Term **); Int Yap_SkipList(Term *, Term **);
/* yap.c */ /* yap.c */

View File

@ -379,7 +379,7 @@ restore_absmi_regs(REGSTORE * old_regs)
#define DO_PREFETCH(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->opc) #define DO_PREFETCH(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->opc)
#define DO_PREFETCH_W(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->u.o.opcw) #define DO_PREFETCH_W(TYPE) to_go = (void *)(NEXTOP(PREG,TYPE)->y_u.o.opcw)
#if LIMITED_PREFETCH||USE_PREFETCH #if LIMITED_PREFETCH||USE_PREFETCH
@ -466,7 +466,7 @@ restore_absmi_regs(REGSTORE * old_regs)
JMP((void *)(PREG->opc)) JMP((void *)(PREG->opc))
#define JMPNextW() \ #define JMPNextW() \
JMP((void *)(PREG->u.o.opcw)) JMP((void *)(PREG->y_u.o.opcw))
#if USE_THREADED_CODE && (LIMITED_PREFETCH || USE_PREFETCH) #if USE_THREADED_CODE && (LIMITED_PREFETCH || USE_PREFETCH)

View File

@ -65,30 +65,6 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifdef FROZEN_STACKS
#ifdef YAPOR_SBA
#define PROTECT_FROZEN_H(CPTR) \
((Unsigned((Int)((CPTR)->cp_h)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR)->cp_h : H_FZ)
#define PROTECT_FROZEN_B(CPTR) \
((Unsigned((Int)(CPTR)-(Int)(H_FZ)) < \
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) ? \
(CPTR) : B_FZ)
/*
#define PROTECT_FROZEN_H(CPTR) ((CPTR)->cp_h > H_FZ && (CPTR)->cp_h < (CELL *)B_FZ ? (CPTR)->cp_h : H_FZ )
#define PROTECT_FROZEN_B(CPTR) ((CPTR) < B_FZ && (CPTR) > (choiceptr)H_FZ ? (CPTR) : B_FZ )
*/
#else /* TABLING */
#define PROTECT_FROZEN_B(CPTR) (YOUNGER_CP(CPTR, B_FZ) ? CPTR : B_FZ)
#define PROTECT_FROZEN_H(CPTR) (((CPTR)->cp_h > H_FZ) ? (CPTR)->cp_h : H_FZ)
#endif /* YAPOR_SBA */
#else
#define PROTECT_FROZEN_B(CPTR) (CPTR)
#define PROTECT_FROZEN_H(CPTR) (CPTR)->cp_h
#endif /* FROZEN_STACKS */
#if ALIGN_LONGS #if ALIGN_LONGS
/* */ typedef Int DISPREG; /* */ typedef Int DISPREG;
/* */ typedef CELL SMALLUNSGN; /* */ typedef CELL SMALLUNSGN;
@ -882,7 +858,7 @@ typedef struct yami {
Term c; Term c;
CELL next; CELL next;
} yxc; } yxc;
} u; } y_u;
} yamop; } yamop;
typedef yamop yamopp; typedef yamop yamopp;
@ -891,7 +867,7 @@ typedef yamop yamopp;
#define OPCW u.ox.opcw #define OPCW u.ox.opcw
#define NEXTOP(V,TYPE) ((yamop *)(&((V)->u.TYPE.next))) #define NEXTOP(V,TYPE) ((yamop *)(&((V)->y_u.TYPE.next)))
#define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE))) #define PREVOP(V,TYPE) ((yamop *)((CODEADDR)(V)-(CELL)NEXTOP((yamop *)NULL,TYPE)))
@ -1072,13 +1048,13 @@ CELL *ENV_Parent(CELL *env)
static inline static inline
UInt ENV_Size(yamop *cp) UInt ENV_Size(yamop *cp)
{ {
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.s); return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.s);
} }
static inline static inline
struct pred_entry *ENV_ToP(yamop *cp) struct pred_entry *ENV_ToP(yamop *cp)
{ {
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p); return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p);
} }
static inline static inline
@ -1096,13 +1072,13 @@ UInt EnvSize(yamop *cp)
static inline static inline
CELL *EnvBMap(yamop *p) CELL *EnvBMap(yamop *p)
{ {
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.bmap); return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
} }
static inline static inline
struct pred_entry *EnvPreg(yamop *p) struct pred_entry *EnvPreg(yamop *p)
{ {
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->u.Osbpp.p0); return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p0);
} }
/* access to instructions */ /* access to instructions */

View File

@ -33,7 +33,7 @@ typedef union CONSULT_OBJ {
#define ASSEMBLING_INDEX 1 #define ASSEMBLING_INDEX 1
#define ASSEMBLING_EINDEX 2 #define ASSEMBLING_EINDEX 2
#define NextDynamicClause(X) (((yamop *)X)->u.Otapl.d) #define NextDynamicClause(X) (((yamop *)X)->y_u.Otapl.d)
#define PredFirstClause 0 #define PredFirstClause 0
#define PredMiddleClause 1 #define PredMiddleClause 1

View File

@ -18,11 +18,11 @@ struct cut_c_str{
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL))) #define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
#define EXTRA_CBACK_CUT_ARG(Type,Offset) \ #define EXTRA_CBACK_CUT_ARG(Type,Offset) \
((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.OtapFs.extra)) + (Offset-1))) ((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->y_u.OtapFs.extra)) + (Offset-1)))
#define CUT_C_PUSH(YAMOP,S_YREG) \ #define CUT_C_PUSH(YAMOP,S_YREG) \
{ \ { \
if ((YAMOP)->u.OtapFs.f){ \ if ((YAMOP)->y_u.OtapFs.f){ \
S_YREG = S_YREG - CUT_C_STR_SIZE; \ S_YREG = S_YREG - CUT_C_STR_SIZE; \
cut_c_str_ptr new_top = (cut_c_str_ptr) S_YREG; \ cut_c_str_ptr new_top = (cut_c_str_ptr) S_YREG; \
new_top->try_userc_cut_yamop = YAMOP; \ new_top->try_userc_cut_yamop = YAMOP; \
@ -37,8 +37,8 @@ struct cut_c_str{
#define POP_EXECUTE() \ #define POP_EXECUTE() \
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \ cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \ CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \ PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \
YAP_ExecuteOnCut(pred, func, TOP); \ YAP_ExecuteOnCut(pred, func, TOP); \
cut_c_pop(); cut_c_pop();

File diff suppressed because it is too large Load Diff

View File

@ -14,195 +14,195 @@
break; break;
case _get_2atoms: case _get_2atoms:
if (iarg == Yap_regnotoreg(1)) { if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cc.c1)) { if (IsApplTerm(cl->y_u.cc.c1)) {
CELL *pt = RepAppl(cl->u.cc.c1); CELL *pt = RepAppl(cl->y_u.cc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cc.c1; clause->ucd.t_ptr = cl->y_u.cc.c1;
} else } else
clause->Tag = cl->u.cc.c1; clause->Tag = cl->y_u.cc.c1;
return; return;
} }
if (iarg == Yap_regnotoreg(2)) { if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cc.c2)) { if (IsApplTerm(cl->y_u.cc.c2)) {
CELL *pt = RepAppl(cl->u.cc.c2); CELL *pt = RepAppl(cl->y_u.cc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cc.c2; clause->ucd.t_ptr = cl->y_u.cc.c2;
} else } else
clause->Tag = cl->u.cc.c2; clause->Tag = cl->y_u.cc.c2;
return; return;
} }
cl = NEXTOP(cl,cc); cl = NEXTOP(cl,cc);
break; break;
case _get_3atoms: case _get_3atoms:
if (iarg == Yap_regnotoreg(1)) { if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.ccc.c1)) { if (IsApplTerm(cl->y_u.ccc.c1)) {
CELL *pt = RepAppl(cl->u.ccc.c1); CELL *pt = RepAppl(cl->y_u.ccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c1; clause->ucd.t_ptr = cl->y_u.ccc.c1;
} else } else
clause->Tag = cl->u.ccc.c1; clause->Tag = cl->y_u.ccc.c1;
return; return;
} }
if (iarg == Yap_regnotoreg(2)) { if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.ccc.c2)) { if (IsApplTerm(cl->y_u.ccc.c2)) {
CELL *pt = RepAppl(cl->u.ccc.c2); CELL *pt = RepAppl(cl->y_u.ccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c2; clause->ucd.t_ptr = cl->y_u.ccc.c2;
} else } else
clause->Tag = cl->u.ccc.c2; clause->Tag = cl->y_u.ccc.c2;
return; return;
} }
if (iarg == Yap_regnotoreg(3)) { if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.ccc.c3)) { if (IsApplTerm(cl->y_u.ccc.c3)) {
CELL *pt = RepAppl(cl->u.ccc.c3); CELL *pt = RepAppl(cl->y_u.ccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccc.c3; clause->ucd.t_ptr = cl->y_u.ccc.c3;
} else } else
clause->Tag = cl->u.ccc.c3; clause->Tag = cl->y_u.ccc.c3;
return; return;
} }
cl = NEXTOP(cl,ccc); cl = NEXTOP(cl,ccc);
break; break;
case _get_4atoms: case _get_4atoms:
if (iarg == Yap_regnotoreg(1)) { if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cccc.c1)) { if (IsApplTerm(cl->y_u.cccc.c1)) {
CELL *pt = RepAppl(cl->u.cccc.c1); CELL *pt = RepAppl(cl->y_u.cccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c1; clause->ucd.t_ptr = cl->y_u.cccc.c1;
} else } else
clause->Tag = cl->u.cccc.c1; clause->Tag = cl->y_u.cccc.c1;
return; return;
} }
if (iarg == Yap_regnotoreg(2)) { if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cccc.c2)) { if (IsApplTerm(cl->y_u.cccc.c2)) {
CELL *pt = RepAppl(cl->u.cccc.c2); CELL *pt = RepAppl(cl->y_u.cccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c2; clause->ucd.t_ptr = cl->y_u.cccc.c2;
} else } else
clause->Tag = cl->u.cccc.c2; clause->Tag = cl->y_u.cccc.c2;
return; return;
} }
if (iarg == Yap_regnotoreg(3)) { if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.cccc.c3)) { if (IsApplTerm(cl->y_u.cccc.c3)) {
CELL *pt = RepAppl(cl->u.cccc.c3); CELL *pt = RepAppl(cl->y_u.cccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c3; clause->ucd.t_ptr = cl->y_u.cccc.c3;
} else } else
clause->Tag = cl->u.cccc.c3; clause->Tag = cl->y_u.cccc.c3;
return; return;
} }
if (iarg == Yap_regnotoreg(4)) { if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.cccc.c4)) { if (IsApplTerm(cl->y_u.cccc.c4)) {
CELL *pt = RepAppl(cl->u.cccc.c4); CELL *pt = RepAppl(cl->y_u.cccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccc.c4; clause->ucd.t_ptr = cl->y_u.cccc.c4;
} else } else
clause->Tag = cl->u.cccc.c4; clause->Tag = cl->y_u.cccc.c4;
return; return;
} }
cl = NEXTOP(cl,cccc); cl = NEXTOP(cl,cccc);
break; break;
case _get_5atoms: case _get_5atoms:
if (iarg == Yap_regnotoreg(1)) { if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.ccccc.c1)) { if (IsApplTerm(cl->y_u.ccccc.c1)) {
CELL *pt = RepAppl(cl->u.ccccc.c1); CELL *pt = RepAppl(cl->y_u.ccccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c1; clause->ucd.t_ptr = cl->y_u.ccccc.c1;
} else } else
clause->Tag = cl->u.ccccc.c1; clause->Tag = cl->y_u.ccccc.c1;
return; return;
} }
if (iarg == Yap_regnotoreg(2)) { if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.ccccc.c2)) { if (IsApplTerm(cl->y_u.ccccc.c2)) {
CELL *pt = RepAppl(cl->u.ccccc.c2); CELL *pt = RepAppl(cl->y_u.ccccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c2; clause->ucd.t_ptr = cl->y_u.ccccc.c2;
} else } else
clause->Tag = cl->u.ccccc.c2; clause->Tag = cl->y_u.ccccc.c2;
return; return;
} }
if (iarg == Yap_regnotoreg(3)) { if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.ccccc.c3)) { if (IsApplTerm(cl->y_u.ccccc.c3)) {
CELL *pt = RepAppl(cl->u.ccccc.c3); CELL *pt = RepAppl(cl->y_u.ccccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c3; clause->ucd.t_ptr = cl->y_u.ccccc.c3;
} else } else
clause->Tag = cl->u.ccccc.c3; clause->Tag = cl->y_u.ccccc.c3;
return; return;
} }
if (iarg == Yap_regnotoreg(4)) { if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.ccccc.c4)) { if (IsApplTerm(cl->y_u.ccccc.c4)) {
CELL *pt = RepAppl(cl->u.ccccc.c4); CELL *pt = RepAppl(cl->y_u.ccccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c4; clause->ucd.t_ptr = cl->y_u.ccccc.c4;
} else } else
clause->Tag = cl->u.ccccc.c4; clause->Tag = cl->y_u.ccccc.c4;
return; return;
} }
if (iarg == Yap_regnotoreg(5)) { if (iarg == Yap_regnotoreg(5)) {
if (IsApplTerm(cl->u.ccccc.c5)) { if (IsApplTerm(cl->y_u.ccccc.c5)) {
CELL *pt = RepAppl(cl->u.ccccc.c5); CELL *pt = RepAppl(cl->y_u.ccccc.c5);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.ccccc.c5; clause->ucd.t_ptr = cl->y_u.ccccc.c5;
} else } else
clause->Tag = cl->u.ccccc.c5; clause->Tag = cl->y_u.ccccc.c5;
return; return;
} }
cl = NEXTOP(cl,ccccc); cl = NEXTOP(cl,ccccc);
break; break;
case _get_6atoms: case _get_6atoms:
if (iarg == Yap_regnotoreg(1)) { if (iarg == Yap_regnotoreg(1)) {
if (IsApplTerm(cl->u.cccccc.c1)) { if (IsApplTerm(cl->y_u.cccccc.c1)) {
CELL *pt = RepAppl(cl->u.cccccc.c1); CELL *pt = RepAppl(cl->y_u.cccccc.c1);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c1; clause->ucd.t_ptr = cl->y_u.cccccc.c1;
} else } else
clause->Tag = cl->u.cccccc.c1; clause->Tag = cl->y_u.cccccc.c1;
return; return;
} }
if (iarg == Yap_regnotoreg(2)) { if (iarg == Yap_regnotoreg(2)) {
if (IsApplTerm(cl->u.cccccc.c2)) { if (IsApplTerm(cl->y_u.cccccc.c2)) {
CELL *pt = RepAppl(cl->u.cccccc.c2); CELL *pt = RepAppl(cl->y_u.cccccc.c2);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c2; clause->ucd.t_ptr = cl->y_u.cccccc.c2;
} else } else
clause->Tag = cl->u.cccccc.c2; clause->Tag = cl->y_u.cccccc.c2;
return; return;
} }
if (iarg == Yap_regnotoreg(3)) { if (iarg == Yap_regnotoreg(3)) {
if (IsApplTerm(cl->u.cccccc.c3)) { if (IsApplTerm(cl->y_u.cccccc.c3)) {
CELL *pt = RepAppl(cl->u.cccccc.c3); CELL *pt = RepAppl(cl->y_u.cccccc.c3);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c3; clause->ucd.t_ptr = cl->y_u.cccccc.c3;
} else } else
clause->Tag = cl->u.cccccc.c3; clause->Tag = cl->y_u.cccccc.c3;
return; return;
} }
if (iarg == Yap_regnotoreg(4)) { if (iarg == Yap_regnotoreg(4)) {
if (IsApplTerm(cl->u.cccccc.c4)) { if (IsApplTerm(cl->y_u.cccccc.c4)) {
CELL *pt = RepAppl(cl->u.cccccc.c4); CELL *pt = RepAppl(cl->y_u.cccccc.c4);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c4; clause->ucd.t_ptr = cl->y_u.cccccc.c4;
} else } else
clause->Tag = cl->u.cccccc.c4; clause->Tag = cl->y_u.cccccc.c4;
return; return;
} }
if (iarg == Yap_regnotoreg(5)) { if (iarg == Yap_regnotoreg(5)) {
if (IsApplTerm(cl->u.cccccc.c5)) { if (IsApplTerm(cl->y_u.cccccc.c5)) {
CELL *pt = RepAppl(cl->u.cccccc.c5); CELL *pt = RepAppl(cl->y_u.cccccc.c5);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c5; clause->ucd.t_ptr = cl->y_u.cccccc.c5;
} else } else
clause->Tag = cl->u.cccccc.c5; clause->Tag = cl->y_u.cccccc.c5;
return; return;
} }
if (iarg == Yap_regnotoreg(6)) { if (iarg == Yap_regnotoreg(6)) {
if (IsApplTerm(cl->u.cccccc.c6)) { if (IsApplTerm(cl->y_u.cccccc.c6)) {
CELL *pt = RepAppl(cl->u.cccccc.c6); CELL *pt = RepAppl(cl->y_u.cccccc.c6);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.cccccc.c6; clause->ucd.t_ptr = cl->y_u.cccccc.c6;
} else } else
clause->Tag = cl->u.cccccc.c6; clause->Tag = cl->y_u.cccccc.c6;
return; return;
} }
cl = NEXTOP(cl,cccccc); cl = NEXTOP(cl,cccccc);
@ -383,28 +383,28 @@
cl = NEXTOP(cl,ou); cl = NEXTOP(cl,ou);
break; break;
case _save_appl_x: case _save_appl_x:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _save_appl_x_write: case _save_appl_x_write:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _save_pair_x: case _save_pair_x:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _save_pair_x_write: case _save_pair_x_write:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
@ -423,14 +423,14 @@
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _unify_l_x_var: case _unify_l_x_var:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _unify_l_x_var_write: case _unify_l_x_var_write:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
@ -449,58 +449,58 @@
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _unify_x_var: case _unify_x_var:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _unify_x_var_write: case _unify_x_var_write:
if (iarg == cl->u.ox.x) { if (iarg == cl->y_u.ox.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,ox); cl = NEXTOP(cl,ox);
break; break;
case _unify_l_x_var2: case _unify_l_x_var2:
if (iarg == cl->u.oxx.xl) { if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (iarg == cl->u.oxx.xr) { if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,oxx); cl = NEXTOP(cl,oxx);
break; break;
case _unify_l_x_var2_write: case _unify_l_x_var2_write:
if (iarg == cl->u.oxx.xl) { if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (iarg == cl->u.oxx.xr) { if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,oxx); cl = NEXTOP(cl,oxx);
break; break;
case _unify_x_var2: case _unify_x_var2:
if (iarg == cl->u.oxx.xl) { if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (iarg == cl->u.oxx.xr) { if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,oxx); cl = NEXTOP(cl,oxx);
break; break;
case _unify_x_var2_write: case _unify_x_var2_write:
if (iarg == cl->u.oxx.xl) { if (iarg == cl->y_u.oxx.xl) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (iarg == cl->u.oxx.xr) { if (iarg == cl->y_u.oxx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
@ -558,7 +558,7 @@
cl = NEXTOP(cl,s); cl = NEXTOP(cl,s);
break; break;
case _get_list: case _get_list:
if (iarg == cl->u.x.x) { if (iarg == cl->y_u.x.x) {
clause->Tag = AbsPair(NULL); clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = NEXTOP(cl,x); clause->ucd.WorkPC = NEXTOP(cl,x);
return; return;
@ -566,21 +566,21 @@
cl = NEXTOP(cl,x); cl = NEXTOP(cl,x);
break; break;
case _put_list: case _put_list:
if (iarg == cl->u.x.x) { if (iarg == cl->y_u.x.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,x); cl = NEXTOP(cl,x);
break; break;
case _put_dbterm: case _put_dbterm:
if (iarg == cl->u.xD.x) { if (iarg == cl->y_u.xD.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xD); cl = NEXTOP(cl,xD);
break; break;
case _get_bigint: case _get_bigint:
if (iarg == cl->u.xN.x) { if (iarg == cl->y_u.xN.x) {
clause->Tag = AbsAppl((CELL *)FunctorBigInt); clause->Tag = AbsAppl((CELL *)FunctorBigInt);
clause->ucd.t_ptr = (CELL)NULL; clause->ucd.t_ptr = (CELL)NULL;
return; return;
@ -588,78 +588,78 @@
cl = NEXTOP(cl,xN); cl = NEXTOP(cl,xN);
break; break;
case _put_bigint: case _put_bigint:
if (iarg == cl->u.xN.x) { if (iarg == cl->y_u.xN.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xN); cl = NEXTOP(cl,xN);
break; break;
case _get_atom: case _get_atom:
if (iarg == cl->u.xc.x) { if (iarg == cl->y_u.xc.x) {
if (IsApplTerm(cl->u.xc.c)) { if (IsApplTerm(cl->y_u.xc.c)) {
CELL *pt = RepAppl(cl->u.xc.c); CELL *pt = RepAppl(cl->y_u.xc.c);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
clause->ucd.t_ptr = cl->u.xc.c; clause->ucd.t_ptr = cl->y_u.xc.c;
} else } else
clause->Tag = cl->u.xc.c; clause->Tag = cl->y_u.xc.c;
return; return;
} }
cl = NEXTOP(cl,xc); cl = NEXTOP(cl,xc);
break; break;
case _put_atom: case _put_atom:
if (iarg == cl->u.xc.x) { if (iarg == cl->y_u.xc.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xc); cl = NEXTOP(cl,xc);
break; break;
case _get_float: case _get_float:
if (iarg == cl->u.xd.x) { if (iarg == cl->y_u.xd.x) {
clause->Tag = AbsAppl((CELL *)FunctorDouble); clause->Tag = AbsAppl((CELL *)FunctorDouble);
clause->ucd.t_ptr = AbsAppl(cl->u.xd.d); clause->ucd.t_ptr = AbsAppl(cl->y_u.xd.d);
return; return;
} }
cl = NEXTOP(cl,xd); cl = NEXTOP(cl,xd);
break; break;
case _put_float: case _put_float:
if (iarg == cl->u.xd.x) { if (iarg == cl->y_u.xd.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xd); cl = NEXTOP(cl,xd);
break; break;
case _get_struct: case _get_struct:
if (iarg == cl->u.xfa.x) { if (iarg == cl->y_u.xfa.x) {
clause->Tag = AbsAppl((CELL *)cl->u.xfa.f); clause->Tag = AbsAppl((CELL *)cl->y_u.xfa.f);
clause->ucd.WorkPC = NEXTOP(cl,xfa); clause->ucd.WorkPC = NEXTOP(cl,xfa);
return; return;
} }
cl = NEXTOP(cl,xfa); cl = NEXTOP(cl,xfa);
break; break;
case _put_struct: case _put_struct:
if (iarg == cl->u.xfa.x) { if (iarg == cl->y_u.xfa.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xfa); cl = NEXTOP(cl,xfa);
break; break;
case _get_longint: case _get_longint:
if (iarg == cl->u.xi.x) { if (iarg == cl->y_u.xi.x) {
clause->Tag = AbsAppl((CELL *)FunctorLongInt); clause->Tag = AbsAppl((CELL *)FunctorLongInt);
clause->ucd.t_ptr = AbsAppl(cl->u.xi.i); clause->ucd.t_ptr = AbsAppl(cl->y_u.xi.i);
return; return;
} }
cl = NEXTOP(cl,xi); cl = NEXTOP(cl,xi);
break; break;
case _put_longint: case _put_longint:
if (iarg == cl->u.xi.x) { if (iarg == cl->y_u.xi.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xi); cl = NEXTOP(cl,xi);
break; break;
case _get_string: case _get_string:
if (iarg == cl->u.xu.x) { if (iarg == cl->y_u.xu.x) {
clause->Tag = AbsAppl((CELL *)FunctorString); clause->Tag = AbsAppl((CELL *)FunctorString);
clause->ucd.t_ptr = (CELL)NULL; clause->ucd.t_ptr = (CELL)NULL;
return; return;
@ -667,23 +667,23 @@
cl = NEXTOP(cl,xu); cl = NEXTOP(cl,xu);
break; break;
case _get_x_val: case _get_x_val:
if (cl->u.xx.xl == iarg || if (cl->y_u.xx.xl == iarg ||
cl->u.xx.xr == iarg) { cl->y_u.xx.xr == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _get_x_var: case _get_x_var:
if (cl->u.xx.xr == iarg || if (cl->y_u.xx.xr == iarg ||
cl->u.xx.xl == iarg) { cl->y_u.xx.xl == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _gl_void_valx: case _gl_void_valx:
if (iarg == cl->u.xx.xl) { if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL); clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl; clause->ucd.WorkPC = cl;
return; return;
@ -691,19 +691,19 @@
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _gl_void_varx: case _gl_void_varx:
if (iarg == cl->u.xx.xl) { if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL); clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl; clause->ucd.WorkPC = cl;
return; return;
} }
if (iarg == cl->u.xx.xr) { if (iarg == cl->y_u.xx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _glist_valx: case _glist_valx:
if (iarg == cl->u.xx.xl) { if (iarg == cl->y_u.xx.xl) {
clause->Tag = AbsPair(NULL); clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl; clause->ucd.WorkPC = cl;
return; return;
@ -711,46 +711,46 @@
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _put_x_val: case _put_x_val:
if (cl->u.xx.xl == iarg || if (cl->y_u.xx.xl == iarg ||
cl->u.xx.xr == iarg) { cl->y_u.xx.xr == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _put_x_var: case _put_x_var:
if (iarg == cl->u.xx.xl) { if (iarg == cl->y_u.xx.xl) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (iarg == cl->u.xx.xr) { if (iarg == cl->y_u.xx.xr) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xx); cl = NEXTOP(cl,xx);
break; break;
case _put_xx_val: case _put_xx_val:
if (cl->u.xxxx.xl1 == iarg || if (cl->y_u.xxxx.xl1 == iarg ||
cl->u.xxxx.xr1 == iarg) { cl->y_u.xxxx.xr1 == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (cl->u.xxxx.xl2 == iarg || if (cl->y_u.xxxx.xl2 == iarg ||
cl->u.xxxx.xr2 == iarg) { cl->y_u.xxxx.xr2 == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,xxxx); cl = NEXTOP(cl,xxxx);
break; break;
case _get_y_val: case _get_y_val:
if (cl->u.yx.x == iarg) { if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _get_y_var: case _get_y_var:
if (cl->u.yx.x == iarg) { if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
@ -763,7 +763,7 @@
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _glist_valy: case _glist_valy:
if (iarg == cl->u.yx.x) { if (iarg == cl->y_u.yx.x) {
clause->Tag = AbsPair(NULL); clause->Tag = AbsPair(NULL);
clause->ucd.WorkPC = cl; clause->ucd.WorkPC = cl;
return; return;
@ -771,32 +771,32 @@
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _put_unsafe: case _put_unsafe:
if (cl->u.yx.x == iarg) { if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _put_y_val: case _put_y_val:
if (cl->u.yx.x == iarg) { if (cl->y_u.yx.x == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _put_y_var: case _put_y_var:
if (iarg == cl->u.yx.x) { if (iarg == cl->y_u.yx.x) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _get_yy_var: case _get_yy_var:
if (cl->u.yyxx.x1 == iarg) { if (cl->y_u.yyxx.x1 == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }
if (cl->u.yyxx.x2 == iarg) { if (cl->y_u.yyxx.x2 == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
} }

View File

@ -376,7 +376,7 @@
FunctorContext2 = Yap_MkFunctor(AtomContext,2); FunctorContext2 = Yap_MkFunctor(AtomContext,2);
FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1); FunctorConsistencyError = Yap_MkFunctor(AtomConsistencyError,1);
FunctorCreep = Yap_MkFunctor(AtomCreep,1); FunctorCreep = Yap_MkFunctor(AtomCreep,1);
FunctorCsult = Yap_MkFunctor(AtomCsult,1); FunctorCsult = Yap_MkFunctor(AtomCsult,2);
FunctorCurrentModule = Yap_MkFunctor(AtomCurrentModule,1); FunctorCurrentModule = Yap_MkFunctor(AtomCurrentModule,1);
FunctorCutBy = Yap_MkFunctor(AtomCutBy,1); FunctorCutBy = Yap_MkFunctor(AtomCutBy,1);
FunctorDBREF = Yap_MkFunctor(AtomDBREF,1); FunctorDBREF = Yap_MkFunctor(AtomDBREF,1);

View File

@ -28,6 +28,7 @@
#endif #endif
#endif #endif
// SWI Options // SWI Options
#define O_STRING 1 #define O_STRING 1
#define O_QUASIQUOTATIONS 1 #define O_QUASIQUOTATIONS 1
@ -383,5 +384,4 @@ CloseList(Term t0, Term tail)
} }
#endif /* PL_SHARED_INCLUDE */ #endif /* PL_SHARED_INCLUDE */

View File

@ -251,4 +251,6 @@ atom_t ATOM_;
intptr_t system_thread_id(PL_thread_info_t *info); intptr_t system_thread_id(PL_thread_info_t *info);
#endif #endif
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
#endif /* PL_YAP_H */ #endif /* PL_YAP_H */

View File

@ -18,56 +18,56 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
switch (op) { switch (op) {
/* instructions type D */ /* instructions type D */
case _write_dbterm: case _write_dbterm:
pc->u.D.D = DBGroundTermAdjust(pc->u.D.D); pc->y_u.D.D = DBGroundTermAdjust(pc->y_u.D.D);
pc = NEXTOP(pc,D); pc = NEXTOP(pc,D);
break; break;
/* instructions type Illss */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
pc->u.Illss.I = PtoLUIndexAdjust(pc->u.Illss.I); pc->y_u.Illss.I = PtoLUIndexAdjust(pc->y_u.Illss.I);
pc->u.Illss.l1 = PtoOpAdjust(pc->u.Illss.l1); pc->y_u.Illss.l1 = PtoOpAdjust(pc->y_u.Illss.l1);
pc->u.Illss.l2 = PtoOpAdjust(pc->u.Illss.l2); pc->y_u.Illss.l2 = PtoOpAdjust(pc->y_u.Illss.l2);
pc->u.Illss.s = ConstantAdjust(pc->u.Illss.s); pc->y_u.Illss.s = ConstantAdjust(pc->y_u.Illss.s);
pc->u.Illss.e = ConstantAdjust(pc->u.Illss.e); pc->y_u.Illss.e = ConstantAdjust(pc->y_u.Illss.e);
opc = NEXTOP(pc,Illss); opc = NEXTOP(pc,Illss);
pc = pc->u.Illss.l1; pc = pc->y_u.Illss.l1;
break; break;
/* instructions type L */ /* instructions type L */
case _alloc_for_logical_pred: case _alloc_for_logical_pred:
pc->u.L.ClBase = PtoLUClauseAdjust(pc->u.L.ClBase); pc->y_u.L.ClBase = PtoLUClauseAdjust(pc->y_u.L.ClBase);
pc = NEXTOP(pc,L); pc = NEXTOP(pc,L);
break; break;
/* instructions type N */ /* instructions type N */
case _write_bigint: case _write_bigint:
pc->u.N.b = BlobTermInCodeAdjust(pc->u.N.b); pc->y_u.N.b = BlobTermInCodeAdjust(pc->y_u.N.b);
pc = NEXTOP(pc,N); pc = NEXTOP(pc,N);
break; break;
/* instructions type Osblp */ /* instructions type Osblp */
case _either: case _either:
case _or_else: case _or_else:
OrArgAdjust(pc->u.Osblp.or_arg); OrArgAdjust(pc->y_u.Osblp.or_arg);
pc->u.Osblp.s = ConstantAdjust(pc->u.Osblp.s); pc->y_u.Osblp.s = ConstantAdjust(pc->y_u.Osblp.s);
pc->u.Osblp.bmap = CellPtoHeapAdjust(pc->u.Osblp.bmap); pc->y_u.Osblp.bmap = CellPtoHeapAdjust(pc->y_u.Osblp.bmap);
pc->u.Osblp.l = PtoOpAdjust(pc->u.Osblp.l); pc->y_u.Osblp.l = PtoOpAdjust(pc->y_u.Osblp.l);
pc->u.Osblp.p0 = PtoPredAdjust(pc->u.Osblp.p0); pc->y_u.Osblp.p0 = PtoPredAdjust(pc->y_u.Osblp.p0);
pc = NEXTOP(pc,Osblp); pc = NEXTOP(pc,Osblp);
break; break;
/* instructions type Osbmp */ /* instructions type Osbmp */
case _p_execute: case _p_execute:
case _p_execute_tail: case _p_execute_tail:
OrArgAdjust(pc->u.Osbmp.or_arg); OrArgAdjust(pc->y_u.Osbmp.or_arg);
pc->u.Osbmp.s = ConstantAdjust(pc->u.Osbmp.s); pc->y_u.Osbmp.s = ConstantAdjust(pc->y_u.Osbmp.s);
pc->u.Osbmp.bmap = CellPtoHeapAdjust(pc->u.Osbmp.bmap); pc->y_u.Osbmp.bmap = CellPtoHeapAdjust(pc->y_u.Osbmp.bmap);
pc->u.Osbmp.mod = ModuleAdjust(pc->u.Osbmp.mod); pc->y_u.Osbmp.mod = ModuleAdjust(pc->y_u.Osbmp.mod);
pc->u.Osbmp.p0 = PtoPredAdjust(pc->u.Osbmp.p0); pc->y_u.Osbmp.p0 = PtoPredAdjust(pc->y_u.Osbmp.p0);
pc = NEXTOP(pc,Osbmp); pc = NEXTOP(pc,Osbmp);
break; break;
/* instructions type Osbpa */ /* instructions type Osbpa */
case _ensure_space: case _ensure_space:
OrArgAdjust(pc->u.Osbpa.or_arg); OrArgAdjust(pc->y_u.Osbpa.or_arg);
pc->u.Osbpa.s = ConstantAdjust(pc->u.Osbpa.s); pc->y_u.Osbpa.s = ConstantAdjust(pc->y_u.Osbpa.s);
pc->u.Osbpa.bmap = CellPtoHeapAdjust(pc->u.Osbpa.bmap); pc->y_u.Osbpa.bmap = CellPtoHeapAdjust(pc->y_u.Osbpa.bmap);
pc->u.Osbpa.p = PtoPredAdjust(pc->u.Osbpa.p); pc->y_u.Osbpa.p = PtoPredAdjust(pc->y_u.Osbpa.p);
pc->u.Osbpa.i = ArityAdjust(pc->u.Osbpa.i); pc->y_u.Osbpa.i = ArityAdjust(pc->y_u.Osbpa.i);
pc = NEXTOP(pc,Osbpa); pc = NEXTOP(pc,Osbpa);
break; break;
/* instructions type Osbpp */ /* instructions type Osbpp */
@ -76,22 +76,22 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _call_usercpred: case _call_usercpred:
case _fcall: case _fcall:
case _p_execute2: case _p_execute2:
OrArgAdjust(pc->u.Osbpp.or_arg); OrArgAdjust(pc->y_u.Osbpp.or_arg);
pc->u.Osbpp.s = ConstantAdjust(pc->u.Osbpp.s); pc->y_u.Osbpp.s = ConstantAdjust(pc->y_u.Osbpp.s);
pc->u.Osbpp.bmap = CellPtoHeapAdjust(pc->u.Osbpp.bmap); pc->y_u.Osbpp.bmap = CellPtoHeapAdjust(pc->y_u.Osbpp.bmap);
pc->u.Osbpp.p = PtoPredAdjust(pc->u.Osbpp.p); pc->y_u.Osbpp.p = PtoPredAdjust(pc->y_u.Osbpp.p);
pc->u.Osbpp.p0 = PtoPredAdjust(pc->u.Osbpp.p0); pc->y_u.Osbpp.p0 = PtoPredAdjust(pc->y_u.Osbpp.p0);
pc = NEXTOP(pc,Osbpp); pc = NEXTOP(pc,Osbpp);
break; break;
/* instructions type OtILl */ /* instructions type OtILl */
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
case _trust_logical: case _trust_logical:
OrArgAdjust(pc->u.OtILl.or_arg); OrArgAdjust(pc->y_u.OtILl.or_arg);
TabEntryAdjust(pc->u.OtILl.te); TabEntryAdjust(pc->y_u.OtILl.te);
pc->u.OtILl.block = PtoLUIndexAdjust(pc->u.OtILl.block); pc->y_u.OtILl.block = PtoLUIndexAdjust(pc->y_u.OtILl.block);
pc->u.OtILl.d = PtoLUClauseAdjust(pc->u.OtILl.d); pc->y_u.OtILl.d = PtoLUClauseAdjust(pc->y_u.OtILl.d);
pc->u.OtILl.n = PtoOpAdjust(pc->u.OtILl.n); pc->y_u.OtILl.n = PtoOpAdjust(pc->y_u.OtILl.n);
pc = opc; pc = opc;
break; break;
/* instructions type OtaLl */ /* instructions type OtaLl */
@ -99,12 +99,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _profiled_retry_logical: case _profiled_retry_logical:
case _retry_logical: case _retry_logical:
case _try_logical: case _try_logical:
OrArgAdjust(pc->u.OtaLl.or_arg); OrArgAdjust(pc->y_u.OtaLl.or_arg);
TabEntryAdjust(pc->u.OtaLl.te); TabEntryAdjust(pc->y_u.OtaLl.te);
pc->u.OtaLl.s = ArityAdjust(pc->u.OtaLl.s); pc->y_u.OtaLl.s = ArityAdjust(pc->y_u.OtaLl.s);
pc->u.OtaLl.d = PtoLUClauseAdjust(pc->u.OtaLl.d); pc->y_u.OtaLl.d = PtoLUClauseAdjust(pc->y_u.OtaLl.d);
pc->u.OtaLl.n = PtoOpAdjust(pc->u.OtaLl.n); pc->y_u.OtaLl.n = PtoOpAdjust(pc->y_u.OtaLl.n);
pc = pc->u.OtaLl.n; pc = pc->y_u.OtaLl.n;
break; break;
/* instructions type OtapFs */ /* instructions type OtapFs */
case _cut_c: case _cut_c:
@ -113,12 +113,12 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _retry_userc: case _retry_userc:
case _try_c: case _try_c:
case _try_userc: case _try_userc:
OrArgAdjust(pc->u.OtapFs.or_arg); OrArgAdjust(pc->y_u.OtapFs.or_arg);
TabEntryAdjust(pc->u.OtapFs.te); TabEntryAdjust(pc->y_u.OtapFs.te);
pc->u.OtapFs.s = ArityAdjust(pc->u.OtapFs.s); pc->y_u.OtapFs.s = ArityAdjust(pc->y_u.OtapFs.s);
pc->u.OtapFs.p = PtoPredAdjust(pc->u.OtapFs.p); pc->y_u.OtapFs.p = PtoPredAdjust(pc->y_u.OtapFs.p);
pc->u.OtapFs.f = ExternalFunctionAdjust(pc->u.OtapFs.f); pc->y_u.OtapFs.f = ExternalFunctionAdjust(pc->y_u.OtapFs.f);
pc->u.OtapFs.extra = ConstantAdjust(pc->u.OtapFs.extra); pc->y_u.OtapFs.extra = ConstantAdjust(pc->y_u.OtapFs.extra);
pc = NEXTOP(pc,OtapFs); pc = NEXTOP(pc,OtapFs);
break; break;
/* instructions type Otapl */ /* instructions type Otapl */
@ -137,77 +137,77 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_and_mark: case _try_and_mark:
case _try_clause: case _try_clause:
case _try_me: case _try_me:
OrArgAdjust(pc->u.Otapl.or_arg); OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te); TabEntryAdjust(pc->y_u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s); pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p); pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d); pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type aFlp */ /* instructions type aFlp */
case _native_me: case _native_me:
pc->u.aFlp.n = ArityAdjust(pc->u.aFlp.n); pc->y_u.aFlp.n = ArityAdjust(pc->y_u.aFlp.n);
pc->u.aFlp.native = ExternalFunctionAdjust(pc->u.aFlp.native); pc->y_u.aFlp.native = ExternalFunctionAdjust(pc->y_u.aFlp.native);
pc->u.aFlp.native_next = PtoOpAdjust(pc->u.aFlp.native_next); pc->y_u.aFlp.native_next = PtoOpAdjust(pc->y_u.aFlp.native_next);
pc->u.aFlp.p = PtoPredAdjust(pc->u.aFlp.p); pc->y_u.aFlp.p = PtoPredAdjust(pc->y_u.aFlp.p);
pc = NEXTOP(pc,aFlp); pc = NEXTOP(pc,aFlp);
break; break;
/* instructions type c */ /* instructions type c */
case _write_atom: case _write_atom:
pc->u.c.c = ConstantTermAdjust(pc->u.c.c); pc->y_u.c.c = ConstantTermAdjust(pc->y_u.c.c);
pc = NEXTOP(pc,c); pc = NEXTOP(pc,c);
break; break;
/* instructions type cc */ /* instructions type cc */
case _get_2atoms: case _get_2atoms:
pc->u.cc.c1 = ConstantTermAdjust(pc->u.cc.c1); pc->y_u.cc.c1 = ConstantTermAdjust(pc->y_u.cc.c1);
pc->u.cc.c2 = ConstantTermAdjust(pc->u.cc.c2); pc->y_u.cc.c2 = ConstantTermAdjust(pc->y_u.cc.c2);
pc = NEXTOP(pc,cc); pc = NEXTOP(pc,cc);
break; break;
/* instructions type ccc */ /* instructions type ccc */
case _get_3atoms: case _get_3atoms:
pc->u.ccc.c1 = ConstantTermAdjust(pc->u.ccc.c1); pc->y_u.ccc.c1 = ConstantTermAdjust(pc->y_u.ccc.c1);
pc->u.ccc.c2 = ConstantTermAdjust(pc->u.ccc.c2); pc->y_u.ccc.c2 = ConstantTermAdjust(pc->y_u.ccc.c2);
pc->u.ccc.c3 = ConstantTermAdjust(pc->u.ccc.c3); pc->y_u.ccc.c3 = ConstantTermAdjust(pc->y_u.ccc.c3);
pc = NEXTOP(pc,ccc); pc = NEXTOP(pc,ccc);
break; break;
/* instructions type cccc */ /* instructions type cccc */
case _get_4atoms: case _get_4atoms:
pc->u.cccc.c1 = ConstantTermAdjust(pc->u.cccc.c1); pc->y_u.cccc.c1 = ConstantTermAdjust(pc->y_u.cccc.c1);
pc->u.cccc.c2 = ConstantTermAdjust(pc->u.cccc.c2); pc->y_u.cccc.c2 = ConstantTermAdjust(pc->y_u.cccc.c2);
pc->u.cccc.c3 = ConstantTermAdjust(pc->u.cccc.c3); pc->y_u.cccc.c3 = ConstantTermAdjust(pc->y_u.cccc.c3);
pc->u.cccc.c4 = ConstantTermAdjust(pc->u.cccc.c4); pc->y_u.cccc.c4 = ConstantTermAdjust(pc->y_u.cccc.c4);
pc = NEXTOP(pc,cccc); pc = NEXTOP(pc,cccc);
break; break;
/* instructions type ccccc */ /* instructions type ccccc */
case _get_5atoms: case _get_5atoms:
pc->u.ccccc.c1 = ConstantTermAdjust(pc->u.ccccc.c1); pc->y_u.ccccc.c1 = ConstantTermAdjust(pc->y_u.ccccc.c1);
pc->u.ccccc.c2 = ConstantTermAdjust(pc->u.ccccc.c2); pc->y_u.ccccc.c2 = ConstantTermAdjust(pc->y_u.ccccc.c2);
pc->u.ccccc.c3 = ConstantTermAdjust(pc->u.ccccc.c3); pc->y_u.ccccc.c3 = ConstantTermAdjust(pc->y_u.ccccc.c3);
pc->u.ccccc.c4 = ConstantTermAdjust(pc->u.ccccc.c4); pc->y_u.ccccc.c4 = ConstantTermAdjust(pc->y_u.ccccc.c4);
pc->u.ccccc.c5 = ConstantTermAdjust(pc->u.ccccc.c5); pc->y_u.ccccc.c5 = ConstantTermAdjust(pc->y_u.ccccc.c5);
pc = NEXTOP(pc,ccccc); pc = NEXTOP(pc,ccccc);
break; break;
/* instructions type cccccc */ /* instructions type cccccc */
case _get_6atoms: case _get_6atoms:
pc->u.cccccc.c1 = ConstantTermAdjust(pc->u.cccccc.c1); pc->y_u.cccccc.c1 = ConstantTermAdjust(pc->y_u.cccccc.c1);
pc->u.cccccc.c2 = ConstantTermAdjust(pc->u.cccccc.c2); pc->y_u.cccccc.c2 = ConstantTermAdjust(pc->y_u.cccccc.c2);
pc->u.cccccc.c3 = ConstantTermAdjust(pc->u.cccccc.c3); pc->y_u.cccccc.c3 = ConstantTermAdjust(pc->y_u.cccccc.c3);
pc->u.cccccc.c4 = ConstantTermAdjust(pc->u.cccccc.c4); pc->y_u.cccccc.c4 = ConstantTermAdjust(pc->y_u.cccccc.c4);
pc->u.cccccc.c5 = ConstantTermAdjust(pc->u.cccccc.c5); pc->y_u.cccccc.c5 = ConstantTermAdjust(pc->y_u.cccccc.c5);
pc->u.cccccc.c6 = ConstantTermAdjust(pc->u.cccccc.c6); pc->y_u.cccccc.c6 = ConstantTermAdjust(pc->y_u.cccccc.c6);
pc = NEXTOP(pc,cccccc); pc = NEXTOP(pc,cccccc);
break; break;
/* instructions type clll */ /* instructions type clll */
case _if_not_then: case _if_not_then:
pc->u.clll.c = ConstantTermAdjust(pc->u.clll.c); pc->y_u.clll.c = ConstantTermAdjust(pc->y_u.clll.c);
pc->u.clll.l1 = PtoOpAdjust(pc->u.clll.l1); pc->y_u.clll.l1 = PtoOpAdjust(pc->y_u.clll.l1);
pc->u.clll.l2 = PtoOpAdjust(pc->u.clll.l2); pc->y_u.clll.l2 = PtoOpAdjust(pc->y_u.clll.l2);
pc->u.clll.l3 = PtoOpAdjust(pc->u.clll.l3); pc->y_u.clll.l3 = PtoOpAdjust(pc->y_u.clll.l3);
pc = NEXTOP(pc,clll); pc = NEXTOP(pc,clll);
break; break;
/* instructions type d */ /* instructions type d */
case _write_float: case _write_float:
DoubleInCodeAdjust(pc->u.d.d); DoubleInCodeAdjust(pc->y_u.d.d);
pc = NEXTOP(pc,d); pc = NEXTOP(pc,d);
break; break;
/* instructions type e */ /* instructions type e */
@ -245,13 +245,13 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
/* instructions type fa */ /* instructions type fa */
case _write_l_struc: case _write_l_struc:
case _write_struct: case _write_struct:
pc->u.fa.f = FuncAdjust(pc->u.fa.f); pc->y_u.fa.f = FuncAdjust(pc->y_u.fa.f);
pc->u.fa.a = ArityAdjust(pc->u.fa.a); pc->y_u.fa.a = ArityAdjust(pc->y_u.fa.a);
pc = NEXTOP(pc,fa); pc = NEXTOP(pc,fa);
break; break;
/* instructions type i */ /* instructions type i */
case _write_longint: case _write_longint:
IntegerInCodeAdjust(pc->u.i.i); IntegerInCodeAdjust(pc->y_u.i.i);
pc = NEXTOP(pc,i); pc = NEXTOP(pc,i);
break; break;
/* instructions type l */ /* instructions type l */
@ -269,16 +269,16 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_clause3: case _try_clause3:
case _try_clause4: case _try_clause4:
case _try_in: case _try_in:
pc->u.l.l = PtoOpAdjust(pc->u.l.l); pc->y_u.l.l = PtoOpAdjust(pc->y_u.l.l);
if (op == _Ystop) return; if (op == _Ystop) return;
pc = NEXTOP(pc,l); pc = NEXTOP(pc,l);
break; break;
/* instructions type llll */ /* instructions type llll */
case _switch_on_type: case _switch_on_type:
pc->u.llll.l1 = PtoOpAdjust(pc->u.llll.l1); pc->y_u.llll.l1 = PtoOpAdjust(pc->y_u.llll.l1);
pc->u.llll.l2 = PtoOpAdjust(pc->u.llll.l2); pc->y_u.llll.l2 = PtoOpAdjust(pc->y_u.llll.l2);
pc->u.llll.l3 = PtoOpAdjust(pc->u.llll.l3); pc->y_u.llll.l3 = PtoOpAdjust(pc->y_u.llll.l3);
pc->u.llll.l4 = PtoOpAdjust(pc->u.llll.l4); pc->y_u.llll.l4 = PtoOpAdjust(pc->y_u.llll.l4);
pc = NEXTOP(pc,llll); pc = NEXTOP(pc,llll);
break; break;
/* instructions type lp */ /* instructions type lp */
@ -289,8 +289,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _try_exo: case _try_exo:
case _try_exo_udi: case _try_exo_udi:
case _user_switch: case _user_switch:
pc->u.lp.l = PtoOpAdjust(pc->u.lp.l); pc->y_u.lp.l = PtoOpAdjust(pc->y_u.lp.l);
pc->u.lp.p = PtoPredAdjust(pc->u.lp.p); pc->y_u.lp.p = PtoPredAdjust(pc->y_u.lp.p);
pc = NEXTOP(pc,lp); pc = NEXTOP(pc,lp);
break; break;
/* instructions type o */ /* instructions type o */
@ -302,21 +302,21 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_list_write: case _unify_list_write:
case _unify_void: case _unify_void:
case _unify_void_write: case _unify_void_write:
pc->u.o.opcw = OpcodeAdjust(pc->u.o.opcw); pc->y_u.o.opcw = OpcodeAdjust(pc->y_u.o.opcw);
pc = NEXTOP(pc,o); pc = NEXTOP(pc,o);
break; break;
/* instructions type oD */ /* instructions type oD */
case _unify_dbterm: case _unify_dbterm:
case _unify_l_dbterm: case _unify_l_dbterm:
pc->u.oD.opcw = OpcodeAdjust(pc->u.oD.opcw); pc->y_u.oD.opcw = OpcodeAdjust(pc->y_u.oD.opcw);
pc->u.oD.D = DBGroundTermAdjust(pc->u.oD.D); pc->y_u.oD.D = DBGroundTermAdjust(pc->y_u.oD.D);
pc = NEXTOP(pc,oD); pc = NEXTOP(pc,oD);
break; break;
/* instructions type oN */ /* instructions type oN */
case _unify_bigint: case _unify_bigint:
case _unify_l_bigint: case _unify_l_bigint:
pc->u.oN.opcw = OpcodeAdjust(pc->u.oN.opcw); pc->y_u.oN.opcw = OpcodeAdjust(pc->y_u.oN.opcw);
pc->u.oN.b = BlobTermInCodeAdjust(pc->u.oN.b); pc->y_u.oN.b = BlobTermInCodeAdjust(pc->y_u.oN.b);
pc = NEXTOP(pc,oN); pc = NEXTOP(pc,oN);
break; break;
/* instructions type oc */ /* instructions type oc */
@ -324,8 +324,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_atom_write: case _unify_atom_write:
case _unify_l_atom: case _unify_l_atom:
case _unify_l_atom_write: case _unify_l_atom_write:
pc->u.oc.opcw = OpcodeAdjust(pc->u.oc.opcw); pc->y_u.oc.opcw = OpcodeAdjust(pc->y_u.oc.opcw);
pc->u.oc.c = ConstantTermAdjust(pc->u.oc.c); pc->y_u.oc.c = ConstantTermAdjust(pc->y_u.oc.c);
pc = NEXTOP(pc,oc); pc = NEXTOP(pc,oc);
break; break;
/* instructions type od */ /* instructions type od */
@ -333,8 +333,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_float_write: case _unify_float_write:
case _unify_l_float: case _unify_l_float:
case _unify_l_float_write: case _unify_l_float_write:
pc->u.od.opcw = OpcodeAdjust(pc->u.od.opcw); pc->y_u.od.opcw = OpcodeAdjust(pc->y_u.od.opcw);
DoubleInCodeAdjust(pc->u.od.d); DoubleInCodeAdjust(pc->y_u.od.d);
pc = NEXTOP(pc,od); pc = NEXTOP(pc,od);
break; break;
/* instructions type ofa */ /* instructions type ofa */
@ -342,9 +342,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_struc_write: case _unify_l_struc_write:
case _unify_struct: case _unify_struct:
case _unify_struct_write: case _unify_struct_write:
pc->u.ofa.opcw = OpcodeAdjust(pc->u.ofa.opcw); pc->y_u.ofa.opcw = OpcodeAdjust(pc->y_u.ofa.opcw);
pc->u.ofa.f = FuncAdjust(pc->u.ofa.f); pc->y_u.ofa.f = FuncAdjust(pc->y_u.ofa.f);
pc->u.ofa.a = ArityAdjust(pc->u.ofa.a); pc->y_u.ofa.a = ArityAdjust(pc->y_u.ofa.a);
pc = NEXTOP(pc,ofa); pc = NEXTOP(pc,ofa);
break; break;
/* instructions type oi */ /* instructions type oi */
@ -352,17 +352,17 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_longint_write: case _unify_l_longint_write:
case _unify_longint: case _unify_longint:
case _unify_longint_write: case _unify_longint_write:
pc->u.oi.opcw = OpcodeAdjust(pc->u.oi.opcw); pc->y_u.oi.opcw = OpcodeAdjust(pc->y_u.oi.opcw);
IntegerInCodeAdjust(pc->u.oi.i); IntegerInCodeAdjust(pc->y_u.oi.i);
pc = NEXTOP(pc,oi); pc = NEXTOP(pc,oi);
break; break;
/* instructions type ollll */ /* instructions type ollll */
case _switch_list_nl: case _switch_list_nl:
pc->u.ollll.pop = OpcodeAdjust(pc->u.ollll.pop); pc->y_u.ollll.pop = OpcodeAdjust(pc->y_u.ollll.pop);
pc->u.ollll.l1 = PtoOpAdjust(pc->u.ollll.l1); pc->y_u.ollll.l1 = PtoOpAdjust(pc->y_u.ollll.l1);
pc->u.ollll.l2 = PtoOpAdjust(pc->u.ollll.l2); pc->y_u.ollll.l2 = PtoOpAdjust(pc->y_u.ollll.l2);
pc->u.ollll.l3 = PtoOpAdjust(pc->u.ollll.l3); pc->y_u.ollll.l3 = PtoOpAdjust(pc->y_u.ollll.l3);
pc->u.ollll.l4 = PtoOpAdjust(pc->u.ollll.l4); pc->y_u.ollll.l4 = PtoOpAdjust(pc->y_u.ollll.l4);
pc = NEXTOP(pc,ollll); pc = NEXTOP(pc,ollll);
break; break;
/* instructions type os */ /* instructions type os */
@ -373,23 +373,23 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_n_voids_write: case _unify_l_n_voids_write:
case _unify_n_voids: case _unify_n_voids:
case _unify_n_voids_write: case _unify_n_voids_write:
pc->u.os.opcw = OpcodeAdjust(pc->u.os.opcw); pc->y_u.os.opcw = OpcodeAdjust(pc->y_u.os.opcw);
pc->u.os.s = ConstantAdjust(pc->u.os.s); pc->y_u.os.s = ConstantAdjust(pc->y_u.os.s);
pc = NEXTOP(pc,os); pc = NEXTOP(pc,os);
break; break;
/* instructions type osc */ /* instructions type osc */
case _unify_n_atoms: case _unify_n_atoms:
case _unify_n_atoms_write: case _unify_n_atoms_write:
pc->u.osc.opcw = OpcodeAdjust(pc->u.osc.opcw); pc->y_u.osc.opcw = OpcodeAdjust(pc->y_u.osc.opcw);
pc->u.osc.s = ConstantAdjust(pc->u.osc.s); pc->y_u.osc.s = ConstantAdjust(pc->y_u.osc.s);
pc->u.osc.c = ConstantTermAdjust(pc->u.osc.c); pc->y_u.osc.c = ConstantTermAdjust(pc->y_u.osc.c);
pc = NEXTOP(pc,osc); pc = NEXTOP(pc,osc);
break; break;
/* instructions type ou */ /* instructions type ou */
case _unify_l_string: case _unify_l_string:
case _unify_string: case _unify_string:
pc->u.ou.opcw = OpcodeAdjust(pc->u.ou.opcw); pc->y_u.ou.opcw = OpcodeAdjust(pc->y_u.ou.opcw);
pc->u.ou.ut = BlobTermInCodeAdjust(pc->u.ou.ut); pc->y_u.ou.ut = BlobTermInCodeAdjust(pc->y_u.ou.ut);
pc = NEXTOP(pc,ou); pc = NEXTOP(pc,ou);
break; break;
/* instructions type ox */ /* instructions type ox */
@ -409,8 +409,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_x_val_write: case _unify_x_val_write:
case _unify_x_var: case _unify_x_var:
case _unify_x_var_write: case _unify_x_var_write:
pc->u.ox.opcw = OpcodeAdjust(pc->u.ox.opcw); pc->y_u.ox.opcw = OpcodeAdjust(pc->y_u.ox.opcw);
pc->u.ox.x = XAdjust(pc->u.ox.x); pc->y_u.ox.x = XAdjust(pc->y_u.ox.x);
pc = NEXTOP(pc,ox); pc = NEXTOP(pc,ox);
break; break;
/* instructions type oxx */ /* instructions type oxx */
@ -418,9 +418,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_l_x_var2_write: case _unify_l_x_var2_write:
case _unify_x_var2: case _unify_x_var2:
case _unify_x_var2_write: case _unify_x_var2_write:
pc->u.oxx.opcw = OpcodeAdjust(pc->u.oxx.opcw); pc->y_u.oxx.opcw = OpcodeAdjust(pc->y_u.oxx.opcw);
pc->u.oxx.xl = XAdjust(pc->u.oxx.xl); pc->y_u.oxx.xl = XAdjust(pc->y_u.oxx.xl);
pc->u.oxx.xr = XAdjust(pc->u.oxx.xr); pc->y_u.oxx.xr = XAdjust(pc->y_u.oxx.xr);
pc = NEXTOP(pc,oxx); pc = NEXTOP(pc,oxx);
break; break;
/* instructions type oy */ /* instructions type oy */
@ -440,8 +440,8 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _unify_y_val_write: case _unify_y_val_write:
case _unify_y_var: case _unify_y_var:
case _unify_y_var_write: case _unify_y_var_write:
pc->u.oy.opcw = OpcodeAdjust(pc->u.oy.opcw); pc->y_u.oy.opcw = OpcodeAdjust(pc->y_u.oy.opcw);
pc->u.oy.y = YAdjust(pc->u.oy.y); pc->y_u.oy.y = YAdjust(pc->y_u.oy.y);
pc = NEXTOP(pc,oy); pc = NEXTOP(pc,oy);
break; break;
/* instructions type p */ /* instructions type p */
@ -454,43 +454,43 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _retry_profiled: case _retry_profiled:
case _retry_udi: case _retry_udi:
case _try_udi: case _try_udi:
pc->u.p.p = PtoPredAdjust(pc->u.p.p); pc->y_u.p.p = PtoPredAdjust(pc->y_u.p.p);
pc = NEXTOP(pc,p); pc = NEXTOP(pc,p);
break; break;
/* instructions type plxxs */ /* instructions type plxxs */
case _call_bfunc_xx: case _call_bfunc_xx:
pc->u.plxxs.p = PtoPredAdjust(pc->u.plxxs.p); pc->y_u.plxxs.p = PtoPredAdjust(pc->y_u.plxxs.p);
pc->u.plxxs.f = PtoOpAdjust(pc->u.plxxs.f); pc->y_u.plxxs.f = PtoOpAdjust(pc->y_u.plxxs.f);
pc->u.plxxs.x1 = XAdjust(pc->u.plxxs.x1); pc->y_u.plxxs.x1 = XAdjust(pc->y_u.plxxs.x1);
pc->u.plxxs.x2 = XAdjust(pc->u.plxxs.x2); pc->y_u.plxxs.x2 = XAdjust(pc->y_u.plxxs.x2);
pc->u.plxxs.flags = ConstantAdjust(pc->u.plxxs.flags); pc->y_u.plxxs.flags = ConstantAdjust(pc->y_u.plxxs.flags);
pc = NEXTOP(pc,plxxs); pc = NEXTOP(pc,plxxs);
break; break;
/* instructions type plxys */ /* instructions type plxys */
case _call_bfunc_xy: case _call_bfunc_xy:
case _call_bfunc_yx: case _call_bfunc_yx:
pc->u.plxys.p = PtoPredAdjust(pc->u.plxys.p); pc->y_u.plxys.p = PtoPredAdjust(pc->y_u.plxys.p);
pc->u.plxys.f = PtoOpAdjust(pc->u.plxys.f); pc->y_u.plxys.f = PtoOpAdjust(pc->y_u.plxys.f);
pc->u.plxys.x = XAdjust(pc->u.plxys.x); pc->y_u.plxys.x = XAdjust(pc->y_u.plxys.x);
pc->u.plxys.y = YAdjust(pc->u.plxys.y); pc->y_u.plxys.y = YAdjust(pc->y_u.plxys.y);
pc->u.plxys.flags = ConstantAdjust(pc->u.plxys.flags); pc->y_u.plxys.flags = ConstantAdjust(pc->y_u.plxys.flags);
pc = NEXTOP(pc,plxys); pc = NEXTOP(pc,plxys);
break; break;
/* instructions type plyys */ /* instructions type plyys */
case _call_bfunc_yy: case _call_bfunc_yy:
pc->u.plyys.p = PtoPredAdjust(pc->u.plyys.p); pc->y_u.plyys.p = PtoPredAdjust(pc->y_u.plyys.p);
pc->u.plyys.f = PtoOpAdjust(pc->u.plyys.f); pc->y_u.plyys.f = PtoOpAdjust(pc->y_u.plyys.f);
pc->u.plyys.y1 = YAdjust(pc->u.plyys.y1); pc->y_u.plyys.y1 = YAdjust(pc->y_u.plyys.y1);
pc->u.plyys.y2 = YAdjust(pc->u.plyys.y2); pc->y_u.plyys.y2 = YAdjust(pc->y_u.plyys.y2);
pc->u.plyys.flags = ConstantAdjust(pc->u.plyys.flags); pc->y_u.plyys.flags = ConstantAdjust(pc->y_u.plyys.flags);
pc = NEXTOP(pc,plyys); pc = NEXTOP(pc,plyys);
break; break;
/* instructions type pp */ /* instructions type pp */
case _dexecute: case _dexecute:
case _execute: case _execute:
case _execute_cpred: case _execute_cpred:
pc->u.pp.p = PtoPredAdjust(pc->u.pp.p); pc->y_u.pp.p = PtoPredAdjust(pc->y_u.pp.p);
pc->u.pp.p0 = PtoPredAdjust(pc->u.pp.p0); pc->y_u.pp.p0 = PtoPredAdjust(pc->y_u.pp.p0);
pc = NEXTOP(pc,pp); pc = NEXTOP(pc,pp);
break; break;
/* instructions type s */ /* instructions type s */
@ -499,29 +499,29 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _cut_t: case _cut_t:
case _pop_n: case _pop_n:
case _write_n_voids: case _write_n_voids:
pc->u.s.s = ConstantAdjust(pc->u.s.s); pc->y_u.s.s = ConstantAdjust(pc->y_u.s.s);
pc = NEXTOP(pc,s); pc = NEXTOP(pc,s);
break; break;
/* instructions type sc */ /* instructions type sc */
case _write_n_atoms: case _write_n_atoms:
pc->u.sc.s = ConstantAdjust(pc->u.sc.s); pc->y_u.sc.s = ConstantAdjust(pc->y_u.sc.s);
pc->u.sc.c = ConstantTermAdjust(pc->u.sc.c); pc->y_u.sc.c = ConstantTermAdjust(pc->y_u.sc.c);
pc = NEXTOP(pc,sc); pc = NEXTOP(pc,sc);
break; break;
/* instructions type sllll */ /* instructions type sllll */
case _switch_on_sub_arg_type: case _switch_on_sub_arg_type:
pc->u.sllll.s = ConstantAdjust(pc->u.sllll.s); pc->y_u.sllll.s = ConstantAdjust(pc->y_u.sllll.s);
pc->u.sllll.l1 = PtoOpAdjust(pc->u.sllll.l1); pc->y_u.sllll.l1 = PtoOpAdjust(pc->y_u.sllll.l1);
pc->u.sllll.l2 = PtoOpAdjust(pc->u.sllll.l2); pc->y_u.sllll.l2 = PtoOpAdjust(pc->y_u.sllll.l2);
pc->u.sllll.l3 = PtoOpAdjust(pc->u.sllll.l3); pc->y_u.sllll.l3 = PtoOpAdjust(pc->y_u.sllll.l3);
pc->u.sllll.l4 = PtoOpAdjust(pc->u.sllll.l4); pc->y_u.sllll.l4 = PtoOpAdjust(pc->y_u.sllll.l4);
pc = NEXTOP(pc,sllll); pc = NEXTOP(pc,sllll);
break; break;
/* instructions type slp */ /* instructions type slp */
case _call_c_wfail: case _call_c_wfail:
pc->u.slp.s = ConstantAdjust(pc->u.slp.s); pc->y_u.slp.s = ConstantAdjust(pc->y_u.slp.s);
pc->u.slp.l = PtoOpAdjust(pc->u.slp.l); pc->y_u.slp.l = PtoOpAdjust(pc->y_u.slp.l);
pc->u.slp.p = PtoPredAdjust(pc->u.slp.p); pc->y_u.slp.p = PtoPredAdjust(pc->y_u.slp.p);
pc = NEXTOP(pc,slp); pc = NEXTOP(pc,slp);
break; break;
/* instructions type sssl */ /* instructions type sssl */
@ -531,21 +531,21 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _if_func: case _if_func:
case _switch_on_cons: case _switch_on_cons:
case _switch_on_func: case _switch_on_func:
pc->u.sssl.s = ConstantAdjust(pc->u.sssl.s); pc->y_u.sssl.s = ConstantAdjust(pc->y_u.sssl.s);
pc->u.sssl.e = ConstantAdjust(pc->u.sssl.e); pc->y_u.sssl.e = ConstantAdjust(pc->y_u.sssl.e);
pc->u.sssl.w = ConstantAdjust(pc->u.sssl.w); pc->y_u.sssl.w = ConstantAdjust(pc->y_u.sssl.w);
pc->u.sssl.l = PtoOpAdjust(pc->u.sssl.l); pc->y_u.sssl.l = PtoOpAdjust(pc->y_u.sssl.l);
AdjustSwitchTable(op, pc->u.sssl.l, pc->u.sssl.s); AdjustSwitchTable(op, pc->y_u.sssl.l, pc->y_u.sssl.s);
pc = NEXTOP(pc,sssl); pc = NEXTOP(pc,sssl);
break; break;
/* instructions type sssllp */ /* instructions type sssllp */
case _expand_clauses: case _expand_clauses:
pc->u.sssllp.s1 = ConstantAdjust(pc->u.sssllp.s1); pc->y_u.sssllp.s1 = ConstantAdjust(pc->y_u.sssllp.s1);
pc->u.sssllp.s2 = ConstantAdjust(pc->u.sssllp.s2); pc->y_u.sssllp.s2 = ConstantAdjust(pc->y_u.sssllp.s2);
pc->u.sssllp.s3 = ConstantAdjust(pc->u.sssllp.s3); pc->y_u.sssllp.s3 = ConstantAdjust(pc->y_u.sssllp.s3);
pc->u.sssllp.sprev = PtoOpAdjust(pc->u.sssllp.sprev); pc->y_u.sssllp.sprev = PtoOpAdjust(pc->y_u.sssllp.sprev);
pc->u.sssllp.snext = PtoOpAdjust(pc->u.sssllp.snext); pc->y_u.sssllp.snext = PtoOpAdjust(pc->y_u.sssllp.snext);
pc->u.sssllp.p = PtoPredAdjust(pc->u.sssllp.p); pc->y_u.sssllp.p = PtoPredAdjust(pc->y_u.sssllp.p);
pc = NEXTOP(pc,sssllp); pc = NEXTOP(pc,sssllp);
break; break;
/* instructions type x */ /* instructions type x */
@ -556,50 +556,50 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _write_x_loc: case _write_x_loc:
case _write_x_val: case _write_x_val:
case _write_x_var: case _write_x_var:
pc->u.x.x = XAdjust(pc->u.x.x); pc->y_u.x.x = XAdjust(pc->y_u.x.x);
pc = NEXTOP(pc,x); pc = NEXTOP(pc,x);
break; break;
/* instructions type xD */ /* instructions type xD */
case _get_dbterm: case _get_dbterm:
case _put_dbterm: case _put_dbterm:
pc->u.xD.x = XAdjust(pc->u.xD.x); pc->y_u.xD.x = XAdjust(pc->y_u.xD.x);
pc->u.xD.D = DBGroundTermAdjust(pc->u.xD.D); pc->y_u.xD.D = DBGroundTermAdjust(pc->y_u.xD.D);
pc = NEXTOP(pc,xD); pc = NEXTOP(pc,xD);
break; break;
/* instructions type xN */ /* instructions type xN */
case _get_bigint: case _get_bigint:
case _put_bigint: case _put_bigint:
pc->u.xN.x = XAdjust(pc->u.xN.x); pc->y_u.xN.x = XAdjust(pc->y_u.xN.x);
pc->u.xN.b = BlobTermInCodeAdjust(pc->u.xN.b); pc->y_u.xN.b = BlobTermInCodeAdjust(pc->y_u.xN.b);
pc = NEXTOP(pc,xN); pc = NEXTOP(pc,xN);
break; break;
/* instructions type xc */ /* instructions type xc */
case _get_atom: case _get_atom:
case _put_atom: case _put_atom:
pc->u.xc.x = XAdjust(pc->u.xc.x); pc->y_u.xc.x = XAdjust(pc->y_u.xc.x);
pc->u.xc.c = ConstantTermAdjust(pc->u.xc.c); pc->y_u.xc.c = ConstantTermAdjust(pc->y_u.xc.c);
pc = NEXTOP(pc,xc); pc = NEXTOP(pc,xc);
break; break;
/* instructions type xd */ /* instructions type xd */
case _get_float: case _get_float:
case _put_float: case _put_float:
pc->u.xd.x = XAdjust(pc->u.xd.x); pc->y_u.xd.x = XAdjust(pc->y_u.xd.x);
DoubleInCodeAdjust(pc->u.xd.d); DoubleInCodeAdjust(pc->y_u.xd.d);
pc = NEXTOP(pc,xd); pc = NEXTOP(pc,xd);
break; break;
/* instructions type xfa */ /* instructions type xfa */
case _get_struct: case _get_struct:
case _put_struct: case _put_struct:
pc->u.xfa.x = XAdjust(pc->u.xfa.x); pc->y_u.xfa.x = XAdjust(pc->y_u.xfa.x);
pc->u.xfa.f = FuncAdjust(pc->u.xfa.f); pc->y_u.xfa.f = FuncAdjust(pc->y_u.xfa.f);
pc->u.xfa.a = ArityAdjust(pc->u.xfa.a); pc->y_u.xfa.a = ArityAdjust(pc->y_u.xfa.a);
pc = NEXTOP(pc,xfa); pc = NEXTOP(pc,xfa);
break; break;
/* instructions type xi */ /* instructions type xi */
case _get_longint: case _get_longint:
case _put_longint: case _put_longint:
pc->u.xi.x = XAdjust(pc->u.xi.x); pc->y_u.xi.x = XAdjust(pc->y_u.xi.x);
IntegerInCodeAdjust(pc->u.xi.i); IntegerInCodeAdjust(pc->y_u.xi.i);
pc = NEXTOP(pc,xi); pc = NEXTOP(pc,xi);
break; break;
/* instructions type xl */ /* instructions type xl */
@ -613,37 +613,37 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_number_x: case _p_number_x:
case _p_primitive_x: case _p_primitive_x:
case _p_var_x: case _p_var_x:
pc->u.xl.x = XAdjust(pc->u.xl.x); pc->y_u.xl.x = XAdjust(pc->y_u.xl.x);
pc->u.xl.F = PtoOpAdjust(pc->u.xl.F); pc->y_u.xl.F = PtoOpAdjust(pc->y_u.xl.F);
pc = NEXTOP(pc,xl); pc = NEXTOP(pc,xl);
break; break;
/* instructions type xll */ /* instructions type xll */
case _jump_if_nonvar: case _jump_if_nonvar:
pc->u.xll.x = XAdjust(pc->u.xll.x); pc->y_u.xll.x = XAdjust(pc->y_u.xll.x);
pc->u.xll.l1 = PtoOpAdjust(pc->u.xll.l1); pc->y_u.xll.l1 = PtoOpAdjust(pc->y_u.xll.l1);
pc->u.xll.l2 = PtoOpAdjust(pc->u.xll.l2); pc->y_u.xll.l2 = PtoOpAdjust(pc->y_u.xll.l2);
pc = NEXTOP(pc,xll); pc = NEXTOP(pc,xll);
break; break;
/* instructions type xllll */ /* instructions type xllll */
case _switch_on_arg_type: case _switch_on_arg_type:
pc->u.xllll.x = XAdjust(pc->u.xllll.x); pc->y_u.xllll.x = XAdjust(pc->y_u.xllll.x);
pc->u.xllll.l1 = PtoOpAdjust(pc->u.xllll.l1); pc->y_u.xllll.l1 = PtoOpAdjust(pc->y_u.xllll.l1);
pc->u.xllll.l2 = PtoOpAdjust(pc->u.xllll.l2); pc->y_u.xllll.l2 = PtoOpAdjust(pc->y_u.xllll.l2);
pc->u.xllll.l3 = PtoOpAdjust(pc->u.xllll.l3); pc->y_u.xllll.l3 = PtoOpAdjust(pc->y_u.xllll.l3);
pc->u.xllll.l4 = PtoOpAdjust(pc->u.xllll.l4); pc->y_u.xllll.l4 = PtoOpAdjust(pc->y_u.xllll.l4);
pc = NEXTOP(pc,xllll); pc = NEXTOP(pc,xllll);
break; break;
/* instructions type xps */ /* instructions type xps */
case _commit_b_x: case _commit_b_x:
pc->u.xps.x = XAdjust(pc->u.xps.x); pc->y_u.xps.x = XAdjust(pc->y_u.xps.x);
pc->u.xps.p0 = PtoPredAdjust(pc->u.xps.p0); pc->y_u.xps.p0 = PtoPredAdjust(pc->y_u.xps.p0);
pc->u.xps.s = ConstantAdjust(pc->u.xps.s); pc->y_u.xps.s = ConstantAdjust(pc->y_u.xps.s);
pc = NEXTOP(pc,xps); pc = NEXTOP(pc,xps);
break; break;
/* instructions type xu */ /* instructions type xu */
case _get_string: case _get_string:
pc->u.xu.x = XAdjust(pc->u.xu.x); pc->y_u.xu.x = XAdjust(pc->y_u.xu.x);
pc->u.xu.ut = BlobTermInCodeAdjust(pc->u.xu.ut); pc->y_u.xu.ut = BlobTermInCodeAdjust(pc->y_u.xu.ut);
pc = NEXTOP(pc,xu); pc = NEXTOP(pc,xu);
break; break;
/* instructions type xx */ /* instructions type xx */
@ -654,15 +654,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _glist_valx: case _glist_valx:
case _put_x_val: case _put_x_val:
case _put_x_var: case _put_x_var:
pc->u.xx.xl = XAdjust(pc->u.xx.xl); pc->y_u.xx.xl = XAdjust(pc->y_u.xx.xl);
pc->u.xx.xr = XAdjust(pc->u.xx.xr); pc->y_u.xx.xr = XAdjust(pc->y_u.xx.xr);
pc = NEXTOP(pc,xx); pc = NEXTOP(pc,xx);
break; break;
/* instructions type xxc */ /* instructions type xxc */
case _p_func2s_cv: case _p_func2s_cv:
pc->u.xxc.x = XAdjust(pc->u.xxc.x); pc->y_u.xxc.x = XAdjust(pc->y_u.xxc.x);
pc->u.xxc.xi = XAdjust(pc->u.xxc.xi); pc->y_u.xxc.xi = XAdjust(pc->y_u.xxc.xi);
pc->u.xxc.c = ConstantTermAdjust(pc->u.xxc.c); pc->y_u.xxc.c = ConstantTermAdjust(pc->y_u.xxc.c);
pc = NEXTOP(pc,xxc); pc = NEXTOP(pc,xxc);
break; break;
/* instructions type xxn */ /* instructions type xxn */
@ -679,9 +679,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_slr_cv: case _p_slr_cv:
case _p_slr_vc: case _p_slr_vc:
case _p_times_vc: case _p_times_vc:
pc->u.xxn.x = XAdjust(pc->u.xxn.x); pc->y_u.xxn.x = XAdjust(pc->y_u.xxn.x);
pc->u.xxn.xi = XAdjust(pc->u.xxn.xi); pc->y_u.xxn.xi = XAdjust(pc->y_u.xxn.xi);
pc->u.xxn.c = IntegerAdjust(pc->u.xxn.c); pc->y_u.xxn.c = IntegerAdjust(pc->y_u.xxn.c);
pc = NEXTOP(pc,xxn); pc = NEXTOP(pc,xxn);
break; break;
/* instructions type xxx */ /* instructions type xxx */
@ -696,24 +696,24 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_sll_vv: case _p_sll_vv:
case _p_slr_vv: case _p_slr_vv:
case _p_times_vv: case _p_times_vv:
pc->u.xxx.x = XAdjust(pc->u.xxx.x); pc->y_u.xxx.x = XAdjust(pc->y_u.xxx.x);
pc->u.xxx.x1 = XAdjust(pc->u.xxx.x1); pc->y_u.xxx.x1 = XAdjust(pc->y_u.xxx.x1);
pc->u.xxx.x2 = XAdjust(pc->u.xxx.x2); pc->y_u.xxx.x2 = XAdjust(pc->y_u.xxx.x2);
pc = NEXTOP(pc,xxx); pc = NEXTOP(pc,xxx);
break; break;
/* instructions type xxxx */ /* instructions type xxxx */
case _put_xx_val: case _put_xx_val:
pc->u.xxxx.xl1 = XAdjust(pc->u.xxxx.xl1); pc->y_u.xxxx.xl1 = XAdjust(pc->y_u.xxxx.xl1);
pc->u.xxxx.xl2 = XAdjust(pc->u.xxxx.xl2); pc->y_u.xxxx.xl2 = XAdjust(pc->y_u.xxxx.xl2);
pc->u.xxxx.xr1 = XAdjust(pc->u.xxxx.xr1); pc->y_u.xxxx.xr1 = XAdjust(pc->y_u.xxxx.xr1);
pc->u.xxxx.xr2 = XAdjust(pc->u.xxxx.xr2); pc->y_u.xxxx.xr2 = XAdjust(pc->y_u.xxxx.xr2);
pc = NEXTOP(pc,xxxx); pc = NEXTOP(pc,xxxx);
break; break;
/* instructions type xxy */ /* instructions type xxy */
case _p_func2f_xy: case _p_func2f_xy:
pc->u.xxy.x = XAdjust(pc->u.xxy.x); pc->y_u.xxy.x = XAdjust(pc->y_u.xxy.x);
pc->u.xxy.x1 = XAdjust(pc->u.xxy.x1); pc->y_u.xxy.x1 = XAdjust(pc->y_u.xxy.x1);
pc->u.xxy.y2 = YAdjust(pc->u.xxy.y2); pc->y_u.xxy.y2 = YAdjust(pc->y_u.xxy.y2);
pc = NEXTOP(pc,xxy); pc = NEXTOP(pc,xxy);
break; break;
/* instructions type y */ /* instructions type y */
@ -721,7 +721,7 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _write_y_loc: case _write_y_loc:
case _write_y_val: case _write_y_val:
case _write_y_var: case _write_y_var:
pc->u.y.y = YAdjust(pc->u.y.y); pc->y_u.y.y = YAdjust(pc->y_u.y.y);
pc = NEXTOP(pc,y); pc = NEXTOP(pc,y);
break; break;
/* instructions type yl */ /* instructions type yl */
@ -735,15 +735,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_number_y: case _p_number_y:
case _p_primitive_y: case _p_primitive_y:
case _p_var_y: case _p_var_y:
pc->u.yl.y = YAdjust(pc->u.yl.y); pc->y_u.yl.y = YAdjust(pc->y_u.yl.y);
pc->u.yl.F = PtoOpAdjust(pc->u.yl.F); pc->y_u.yl.F = PtoOpAdjust(pc->y_u.yl.F);
pc = NEXTOP(pc,yl); pc = NEXTOP(pc,yl);
break; break;
/* instructions type yps */ /* instructions type yps */
case _commit_b_y: case _commit_b_y:
pc->u.yps.y = YAdjust(pc->u.yps.y); pc->y_u.yps.y = YAdjust(pc->y_u.yps.y);
pc->u.yps.p0 = PtoPredAdjust(pc->u.yps.p0); pc->y_u.yps.p0 = PtoPredAdjust(pc->y_u.yps.p0);
pc->u.yps.s = ConstantAdjust(pc->u.yps.s); pc->y_u.yps.s = ConstantAdjust(pc->y_u.yps.s);
pc = NEXTOP(pc,yps); pc = NEXTOP(pc,yps);
break; break;
/* instructions type yx */ /* instructions type yx */
@ -755,15 +755,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _put_unsafe: case _put_unsafe:
case _put_y_val: case _put_y_val:
case _put_y_var: case _put_y_var:
pc->u.yx.y = YAdjust(pc->u.yx.y); pc->y_u.yx.y = YAdjust(pc->y_u.yx.y);
pc->u.yx.x = XAdjust(pc->u.yx.x); pc->y_u.yx.x = XAdjust(pc->y_u.yx.x);
pc = NEXTOP(pc,yx); pc = NEXTOP(pc,yx);
break; break;
/* instructions type yxc */ /* instructions type yxc */
case _p_func2s_y_cv: case _p_func2s_y_cv:
pc->u.yxc.y = YAdjust(pc->u.yxc.y); pc->y_u.yxc.y = YAdjust(pc->y_u.yxc.y);
pc->u.yxc.xi = XAdjust(pc->u.yxc.xi); pc->y_u.yxc.xi = XAdjust(pc->y_u.yxc.xi);
pc->u.yxc.c = ConstantTermAdjust(pc->u.yxc.c); pc->y_u.yxc.c = ConstantTermAdjust(pc->y_u.yxc.c);
pc = NEXTOP(pc,yxc); pc = NEXTOP(pc,yxc);
break; break;
/* instructions type yxn */ /* instructions type yxn */
@ -780,9 +780,9 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_slr_y_cv: case _p_slr_y_cv:
case _p_slr_y_vc: case _p_slr_y_vc:
case _p_times_y_vc: case _p_times_y_vc:
pc->u.yxn.y = YAdjust(pc->u.yxn.y); pc->y_u.yxn.y = YAdjust(pc->y_u.yxn.y);
pc->u.yxn.xi = XAdjust(pc->u.yxn.xi); pc->y_u.yxn.xi = XAdjust(pc->y_u.yxn.xi);
pc->u.yxn.c = IntegerAdjust(pc->u.yxn.c); pc->y_u.yxn.c = IntegerAdjust(pc->y_u.yxn.c);
pc = NEXTOP(pc,yxn); pc = NEXTOP(pc,yxn);
break; break;
/* instructions type yxx */ /* instructions type yxx */
@ -797,25 +797,25 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _p_sll_y_vv: case _p_sll_y_vv:
case _p_slr_y_vv: case _p_slr_y_vv:
case _p_times_y_vv: case _p_times_y_vv:
pc->u.yxx.y = YAdjust(pc->u.yxx.y); pc->y_u.yxx.y = YAdjust(pc->y_u.yxx.y);
pc->u.yxx.x1 = XAdjust(pc->u.yxx.x1); pc->y_u.yxx.x1 = XAdjust(pc->y_u.yxx.x1);
pc->u.yxx.x2 = XAdjust(pc->u.yxx.x2); pc->y_u.yxx.x2 = XAdjust(pc->y_u.yxx.x2);
pc = NEXTOP(pc,yxx); pc = NEXTOP(pc,yxx);
break; break;
/* instructions type yyx */ /* instructions type yyx */
case _p_func2f_yy: case _p_func2f_yy:
pc->u.yyx.y1 = YAdjust(pc->u.yyx.y1); pc->y_u.yyx.y1 = YAdjust(pc->y_u.yyx.y1);
pc->u.yyx.y2 = YAdjust(pc->u.yyx.y2); pc->y_u.yyx.y2 = YAdjust(pc->y_u.yyx.y2);
pc->u.yyx.x = XAdjust(pc->u.yyx.x); pc->y_u.yyx.x = XAdjust(pc->y_u.yyx.x);
pc = NEXTOP(pc,yyx); pc = NEXTOP(pc,yyx);
break; break;
/* instructions type yyxx */ /* instructions type yyxx */
case _get_yy_var: case _get_yy_var:
case _put_y_vals: case _put_y_vals:
pc->u.yyxx.y1 = YAdjust(pc->u.yyxx.y1); pc->y_u.yyxx.y1 = YAdjust(pc->y_u.yyxx.y1);
pc->u.yyxx.y2 = YAdjust(pc->u.yyxx.y2); pc->y_u.yyxx.y2 = YAdjust(pc->y_u.yyxx.y2);
pc->u.yyxx.x1 = XAdjust(pc->u.yyxx.x1); pc->y_u.yyxx.x1 = XAdjust(pc->y_u.yyxx.x1);
pc->u.yyxx.x2 = XAdjust(pc->u.yyxx.x2); pc->y_u.yyxx.x2 = XAdjust(pc->y_u.yyxx.x2);
pc = NEXTOP(pc,yyxx); pc = NEXTOP(pc,yyxx);
break; break;
#ifdef YAPOR #ifdef YAPOR
@ -823,11 +823,11 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _getwork: case _getwork:
case _getwork_seq: case _getwork_seq:
case _sync: case _sync:
OrArgAdjust(pc->u.Otapl.or_arg); OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te); TabEntryAdjust(pc->y_u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s); pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p); pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d); pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -852,11 +852,11 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
case _table_try_answer: case _table_try_answer:
case _table_try_me: case _table_try_me:
case _table_try_single: case _table_try_single:
OrArgAdjust(pc->u.Otapl.or_arg); OrArgAdjust(pc->y_u.Otapl.or_arg);
TabEntryAdjust(pc->u.Otapl.te); TabEntryAdjust(pc->y_u.Otapl.te);
pc->u.Otapl.s = ArityAdjust(pc->u.Otapl.s); pc->y_u.Otapl.s = ArityAdjust(pc->y_u.Otapl.s);
pc->u.Otapl.p = PtoPredAdjust(pc->u.Otapl.p); pc->y_u.Otapl.p = PtoPredAdjust(pc->y_u.Otapl.p);
pc->u.Otapl.d = PtoOpAdjust(pc->u.Otapl.d); pc->y_u.Otapl.d = PtoOpAdjust(pc->y_u.Otapl.d);
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -868,7 +868,7 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
break; break;
/* instructions type s */ /* instructions type s */
case _table_new_answer: case _table_new_answer:
pc->u.s.s = ConstantAdjust(pc->u.s.s); pc->y_u.s.s = ConstantAdjust(pc->y_u.s.s);
pc = NEXTOP(pc,s); pc = NEXTOP(pc,s);
break; break;
/* instructions type e */ /* instructions type e */
@ -943,15 +943,15 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
/* this instruction is hardwired */ /* this instruction is hardwired */
case _or_last: case _or_last:
#ifdef YAPOR #ifdef YAPOR
OrArgAdjust(pc->u.Osblp.or_arg); OrArgAdjust(pc->y_u.Osblp.or_arg);
pc->u.Osblp.s = ConstantAdjust(pc->u.Osblp.s); pc->y_u.Osblp.s = ConstantAdjust(pc->y_u.Osblp.s);
pc->u.Osblp.bmap = CellPtoHeapAdjust(pc->u.Osblp.bmap); pc->y_u.Osblp.bmap = CellPtoHeapAdjust(pc->y_u.Osblp.bmap);
pc->u.Osblp.l = PtoOpAdjust(pc->u.Osblp.l); pc->y_u.Osblp.l = PtoOpAdjust(pc->y_u.Osblp.l);
pc->u.Osblp.p0 = PtoPredAdjust(pc->u.Osblp.p0); pc->y_u.Osblp.p0 = PtoPredAdjust(pc->y_u.Osblp.p0);
pc = NEXTOP(pc,Osblp); pc = NEXTOP(pc,Osblp);
break; break;
#else #else
pc->u.p.p = PtoPredAdjust(pc->u.p.p); pc->y_u.p.p = PtoPredAdjust(pc->y_u.p.p);
pc = NEXTOP(pc,p); pc = NEXTOP(pc,p);
break; break;
#endif #endif

View File

@ -294,14 +294,14 @@ do_clean_susp_clauses(yamop *ipc USES_REGS) {
yamop **st = (yamop **)NEXTOP(ipc,sssllp); yamop **st = (yamop **)NEXTOP(ipc,sssllp);
ipc->opc = Yap_opcode(_expand_clauses); ipc->opc = Yap_opcode(_expand_clauses);
ipc->u.sssllp.p = PtoPredAdjust(ipc->u.sssllp.p); ipc->y_u.sssllp.p = PtoPredAdjust(ipc->y_u.sssllp.p);
if (ipc->u.sssllp.sprev) { if (ipc->y_u.sssllp.sprev) {
ipc->u.sssllp.sprev = PtoOpAdjust(ipc->u.sssllp.sprev); ipc->y_u.sssllp.sprev = PtoOpAdjust(ipc->y_u.sssllp.sprev);
} }
if (ipc->u.sssllp.snext) { if (ipc->y_u.sssllp.snext) {
ipc->u.sssllp.snext = PtoOpAdjust(ipc->u.sssllp.snext); ipc->y_u.sssllp.snext = PtoOpAdjust(ipc->y_u.sssllp.snext);
} }
for (i = 0; i < ipc->u.sssllp.s1; i++, st++) { for (i = 0; i < ipc->y_u.sssllp.s1; i++, st++) {
if (*st) { if (*st) {
*st = PtoOpAdjust(*st); *st = PtoOpAdjust(*st);
} }
@ -766,10 +766,10 @@ RestoreEnvInst(yamop start[2], yamop **instp, op_numbers opc, PredEntry *pred)
yamop *ipc = start; yamop *ipc = start;
ipc->opc = Yap_opcode(_call); ipc->opc = Yap_opcode(_call);
ipc->u.Osbpp.p = pred; ipc->y_u.Osbpp.p = pred;
ipc->u.Osbpp.p0 = pred; ipc->y_u.Osbpp.p0 = pred;
ipc->u.Osbpp.bmap = NULL; ipc->y_u.Osbpp.bmap = NULL;
ipc->u.Osbpp.s = -Signed(RealEnvSize); ipc->y_u.Osbpp.s = -Signed(RealEnvSize);
ipc = NEXTOP(ipc, Osbpp); ipc = NEXTOP(ipc, Osbpp);
ipc->opc = Yap_opcode(opc); ipc->opc = Yap_opcode(opc);
*instp = ipc; *instp = ipc;
@ -782,15 +782,15 @@ RestoreOtaplInst__(yamop start[1], OPCODE opc, PredEntry *pe USES_REGS)
/* this is a place holder, it should not really be used */ /* this is a place holder, it should not really be used */
ipc->opc = Yap_opcode(opc); ipc->opc = Yap_opcode(opc);
ipc->u.Otapl.s = 0; ipc->y_u.Otapl.s = 0;
ipc->u.Otapl.p = pe; ipc->y_u.Otapl.p = pe;
if (ipc->u.Otapl.d) if (ipc->y_u.Otapl.d)
ipc->u.Otapl.d = PtoOpAdjust(ipc->u.Otapl.d); ipc->y_u.Otapl.d = PtoOpAdjust(ipc->y_u.Otapl.d);
#ifdef YAPOR #ifdef YAPOR
INIT_YAMOP_LTT(ipc, 1); INIT_YAMOP_LTT(ipc, 1);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef TABLING #ifdef TABLING
ipc->u.Otapl.te = NULL; ipc->y_u.Otapl.te = NULL;
#endif /* TABLING */ #endif /* TABLING */
} }
@ -818,7 +818,7 @@ RestoreExpandList__( USES_REGS1 )
yamop *ptr = Yap_heap_regs->expand_clauses_first; yamop *ptr = Yap_heap_regs->expand_clauses_first;
while (ptr) { while (ptr) {
do_clean_susp_clauses(ptr PASS_REGS); do_clean_susp_clauses(ptr PASS_REGS);
ptr = ptr->u.sssllp.snext; ptr = ptr->y_u.sssllp.snext;
} }
} }
} }

View File

@ -13,61 +13,61 @@
switch (op) { switch (op) {
/* instructions type D */ /* instructions type D */
case _write_dbterm: case _write_dbterm:
CHECK(save_DBGroundTerm(stream, pc->u.D.D)); CHECK(save_DBGroundTerm(stream, pc->y_u.D.D));
pc = NEXTOP(pc,D); pc = NEXTOP(pc,D);
break; break;
/* instructions type Illss */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
CHECK(save_PtoLUIndex(stream, pc->u.Illss.I)); CHECK(save_PtoLUIndex(stream, pc->y_u.Illss.I));
CHECK(save_PtoOp(stream, pc->u.Illss.l1)); CHECK(save_PtoOp(stream, pc->y_u.Illss.l1));
CHECK(save_PtoOp(stream, pc->u.Illss.l2)); CHECK(save_PtoOp(stream, pc->y_u.Illss.l2));
CHECK(save_Constant(stream, pc->u.Illss.s)); CHECK(save_Constant(stream, pc->y_u.Illss.s));
CHECK(save_Constant(stream, pc->u.Illss.e)); CHECK(save_Constant(stream, pc->y_u.Illss.e));
pc = NEXTOP(pc,Illss); pc = NEXTOP(pc,Illss);
break; break;
/* instructions type L */ /* instructions type L */
case _alloc_for_logical_pred: case _alloc_for_logical_pred:
CHECK(save_PtoLUClause(stream, pc->u.L.ClBase)); CHECK(save_PtoLUClause(stream, pc->y_u.L.ClBase));
pc = NEXTOP(pc,L); pc = NEXTOP(pc,L);
break; break;
/* instructions type N */ /* instructions type N */
case _write_bigint: case _write_bigint:
CHECK(save_BlobTermInCode(stream, pc->u.N.b)); CHECK(save_BlobTermInCode(stream, pc->y_u.N.b));
pc = NEXTOP(pc,N); pc = NEXTOP(pc,N);
break; break;
/* instructions type Osblp */ /* instructions type Osblp */
case _either: case _either:
case _or_else: case _or_else:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osblp.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Osblp.or_arg));
#endif #endif
CHECK(save_Constant(stream, pc->u.Osblp.s)); CHECK(save_Constant(stream, pc->y_u.Osblp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osblp.bmap)); CHECK(save_CellPtoHeap(stream, pc->y_u.Osblp.bmap));
CHECK(save_PtoOp(stream, pc->u.Osblp.l)); CHECK(save_PtoOp(stream, pc->y_u.Osblp.l));
CHECK(save_PtoPred(stream, pc->u.Osblp.p0)); CHECK(save_PtoPred(stream, pc->y_u.Osblp.p0));
pc = NEXTOP(pc,Osblp); pc = NEXTOP(pc,Osblp);
break; break;
/* instructions type Osbmp */ /* instructions type Osbmp */
case _p_execute: case _p_execute:
case _p_execute_tail: case _p_execute_tail:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbmp.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Osbmp.or_arg));
#endif #endif
CHECK(save_Constant(stream, pc->u.Osbmp.s)); CHECK(save_Constant(stream, pc->y_u.Osbmp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbmp.bmap)); CHECK(save_CellPtoHeap(stream, pc->y_u.Osbmp.bmap));
CHECK(save_Module(stream, pc->u.Osbmp.mod)); CHECK(save_Module(stream, pc->y_u.Osbmp.mod));
CHECK(save_PtoPred(stream, pc->u.Osbmp.p0)); CHECK(save_PtoPred(stream, pc->y_u.Osbmp.p0));
pc = NEXTOP(pc,Osbmp); pc = NEXTOP(pc,Osbmp);
break; break;
/* instructions type Osbpa */ /* instructions type Osbpa */
case _ensure_space: case _ensure_space:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbpa.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Osbpa.or_arg));
#endif #endif
CHECK(save_Constant(stream, pc->u.Osbpa.s)); CHECK(save_Constant(stream, pc->y_u.Osbpa.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbpa.bmap)); CHECK(save_CellPtoHeap(stream, pc->y_u.Osbpa.bmap));
CHECK(save_PtoPred(stream, pc->u.Osbpa.p)); CHECK(save_PtoPred(stream, pc->y_u.Osbpa.p));
CHECK(save_Arity(stream, pc->u.Osbpa.i)); CHECK(save_Arity(stream, pc->y_u.Osbpa.i));
pc = NEXTOP(pc,Osbpa); pc = NEXTOP(pc,Osbpa);
break; break;
/* instructions type Osbpp */ /* instructions type Osbpp */
@ -77,12 +77,12 @@
case _fcall: case _fcall:
case _p_execute2: case _p_execute2:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Osbpp.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Osbpp.or_arg));
#endif #endif
CHECK(save_Constant(stream, pc->u.Osbpp.s)); CHECK(save_Constant(stream, pc->y_u.Osbpp.s));
CHECK(save_CellPtoHeap(stream, pc->u.Osbpp.bmap)); CHECK(save_CellPtoHeap(stream, pc->y_u.Osbpp.bmap));
CHECK(save_PtoPred(stream, pc->u.Osbpp.p)); CHECK(save_PtoPred(stream, pc->y_u.Osbpp.p));
CHECK(save_PtoPred(stream, pc->u.Osbpp.p0)); CHECK(save_PtoPred(stream, pc->y_u.Osbpp.p0));
pc = NEXTOP(pc,Osbpp); pc = NEXTOP(pc,Osbpp);
break; break;
/* instructions type OtILl */ /* instructions type OtILl */
@ -90,14 +90,14 @@
case _profiled_trust_logical: case _profiled_trust_logical:
case _trust_logical: case _trust_logical:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtILl.or_arg)); CHECK(save_OrArg(stream, pc->y_u.OtILl.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtILl.te)); CHECK(save_TabEntry(stream, pc->y_u.OtILl.te));
#endif #endif
CHECK(save_PtoLUIndex(stream, pc->u.OtILl.block)); CHECK(save_PtoLUIndex(stream, pc->y_u.OtILl.block));
CHECK(save_PtoLUClause(stream, pc->u.OtILl.d)); CHECK(save_PtoLUClause(stream, pc->y_u.OtILl.d));
CHECK(save_PtoOp(stream, pc->u.OtILl.n)); CHECK(save_PtoOp(stream, pc->y_u.OtILl.n));
pc = NEXTOP(pc,OtILl); pc = NEXTOP(pc,OtILl);
break; break;
/* instructions type OtaLl */ /* instructions type OtaLl */
@ -106,14 +106,14 @@
case _retry_logical: case _retry_logical:
case _try_logical: case _try_logical:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtaLl.or_arg)); CHECK(save_OrArg(stream, pc->y_u.OtaLl.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtaLl.te)); CHECK(save_TabEntry(stream, pc->y_u.OtaLl.te));
#endif #endif
CHECK(save_Arity(stream, pc->u.OtaLl.s)); CHECK(save_Arity(stream, pc->y_u.OtaLl.s));
CHECK(save_PtoLUClause(stream, pc->u.OtaLl.d)); CHECK(save_PtoLUClause(stream, pc->y_u.OtaLl.d));
CHECK(save_PtoOp(stream, pc->u.OtaLl.n)); CHECK(save_PtoOp(stream, pc->y_u.OtaLl.n));
pc = NEXTOP(pc,OtaLl); pc = NEXTOP(pc,OtaLl);
break; break;
/* instructions type OtapFs */ /* instructions type OtapFs */
@ -124,15 +124,15 @@
case _try_c: case _try_c:
case _try_userc: case _try_userc:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.OtapFs.or_arg)); CHECK(save_OrArg(stream, pc->y_u.OtapFs.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.OtapFs.te)); CHECK(save_TabEntry(stream, pc->y_u.OtapFs.te));
#endif #endif
CHECK(save_Arity(stream, pc->u.OtapFs.s)); CHECK(save_Arity(stream, pc->y_u.OtapFs.s));
CHECK(save_PtoPred(stream, pc->u.OtapFs.p)); CHECK(save_PtoPred(stream, pc->y_u.OtapFs.p));
CHECK(save_ExternalFunction(stream, pc->u.OtapFs.f)); CHECK(save_ExternalFunction(stream, pc->y_u.OtapFs.f));
CHECK(save_Constant(stream, pc->u.OtapFs.extra)); CHECK(save_Constant(stream, pc->y_u.OtapFs.extra));
pc = NEXTOP(pc,OtapFs); pc = NEXTOP(pc,OtapFs);
break; break;
/* instructions type Otapl */ /* instructions type Otapl */
@ -152,80 +152,80 @@
case _try_clause: case _try_clause:
case _try_me: case _try_me:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te)); CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif #endif
CHECK(save_Arity(stream, pc->u.Otapl.s)); CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p)); CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type aFlp */ /* instructions type aFlp */
case _native_me: case _native_me:
CHECK(save_Arity(stream, pc->u.aFlp.n)); CHECK(save_Arity(stream, pc->y_u.aFlp.n));
CHECK(save_ExternalFunction(stream, pc->u.aFlp.native)); CHECK(save_ExternalFunction(stream, pc->y_u.aFlp.native));
CHECK(save_PtoOp(stream, pc->u.aFlp.native_next)); CHECK(save_PtoOp(stream, pc->y_u.aFlp.native_next));
CHECK(save_PtoPred(stream, pc->u.aFlp.p)); CHECK(save_PtoPred(stream, pc->y_u.aFlp.p));
pc = NEXTOP(pc,aFlp); pc = NEXTOP(pc,aFlp);
break; break;
/* instructions type c */ /* instructions type c */
case _write_atom: case _write_atom:
CHECK(save_ConstantTerm(stream, pc->u.c.c)); CHECK(save_ConstantTerm(stream, pc->y_u.c.c));
pc = NEXTOP(pc,c); pc = NEXTOP(pc,c);
break; break;
/* instructions type cc */ /* instructions type cc */
case _get_2atoms: case _get_2atoms:
CHECK(save_ConstantTerm(stream, pc->u.cc.c1)); CHECK(save_ConstantTerm(stream, pc->y_u.cc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cc.c2)); CHECK(save_ConstantTerm(stream, pc->y_u.cc.c2));
pc = NEXTOP(pc,cc); pc = NEXTOP(pc,cc);
break; break;
/* instructions type ccc */ /* instructions type ccc */
case _get_3atoms: case _get_3atoms:
CHECK(save_ConstantTerm(stream, pc->u.ccc.c1)); CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.ccc.c2)); CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.ccc.c3)); CHECK(save_ConstantTerm(stream, pc->y_u.ccc.c3));
pc = NEXTOP(pc,ccc); pc = NEXTOP(pc,ccc);
break; break;
/* instructions type cccc */ /* instructions type cccc */
case _get_4atoms: case _get_4atoms:
CHECK(save_ConstantTerm(stream, pc->u.cccc.c1)); CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c2)); CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c3)); CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.cccc.c4)); CHECK(save_ConstantTerm(stream, pc->y_u.cccc.c4));
pc = NEXTOP(pc,cccc); pc = NEXTOP(pc,cccc);
break; break;
/* instructions type ccccc */ /* instructions type ccccc */
case _get_5atoms: case _get_5atoms:
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c1)); CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c2)); CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c3)); CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c4)); CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c4));
CHECK(save_ConstantTerm(stream, pc->u.ccccc.c5)); CHECK(save_ConstantTerm(stream, pc->y_u.ccccc.c5));
pc = NEXTOP(pc,ccccc); pc = NEXTOP(pc,ccccc);
break; break;
/* instructions type cccccc */ /* instructions type cccccc */
case _get_6atoms: case _get_6atoms:
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c1)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c1));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c2)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c2));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c3)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c3));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c4)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c4));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c5)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c5));
CHECK(save_ConstantTerm(stream, pc->u.cccccc.c6)); CHECK(save_ConstantTerm(stream, pc->y_u.cccccc.c6));
pc = NEXTOP(pc,cccccc); pc = NEXTOP(pc,cccccc);
break; break;
/* instructions type clll */ /* instructions type clll */
case _if_not_then: case _if_not_then:
CHECK(save_ConstantTerm(stream, pc->u.clll.c)); CHECK(save_ConstantTerm(stream, pc->y_u.clll.c));
CHECK(save_PtoOp(stream, pc->u.clll.l1)); CHECK(save_PtoOp(stream, pc->y_u.clll.l1));
CHECK(save_PtoOp(stream, pc->u.clll.l2)); CHECK(save_PtoOp(stream, pc->y_u.clll.l2));
CHECK(save_PtoOp(stream, pc->u.clll.l3)); CHECK(save_PtoOp(stream, pc->y_u.clll.l3));
pc = NEXTOP(pc,clll); pc = NEXTOP(pc,clll);
break; break;
/* instructions type d */ /* instructions type d */
case _write_float: case _write_float:
CHECK(save_DoubleInCode(stream, pc->u.d.d)); CHECK(save_DoubleInCode(stream, pc->y_u.d.d));
pc = NEXTOP(pc,d); pc = NEXTOP(pc,d);
break; break;
/* instructions type e */ /* instructions type e */
@ -263,13 +263,13 @@
/* instructions type fa */ /* instructions type fa */
case _write_l_struc: case _write_l_struc:
case _write_struct: case _write_struct:
CHECK(save_Func(stream, pc->u.fa.f)); CHECK(save_Func(stream, pc->y_u.fa.f));
CHECK(save_Arity(stream, pc->u.fa.a)); CHECK(save_Arity(stream, pc->y_u.fa.a));
pc = NEXTOP(pc,fa); pc = NEXTOP(pc,fa);
break; break;
/* instructions type i */ /* instructions type i */
case _write_longint: case _write_longint:
CHECK(save_IntegerInCode(stream, pc->u.i.i)); CHECK(save_IntegerInCode(stream, pc->y_u.i.i));
pc = NEXTOP(pc,i); pc = NEXTOP(pc,i);
break; break;
/* instructions type l */ /* instructions type l */
@ -287,15 +287,15 @@
case _try_clause3: case _try_clause3:
case _try_clause4: case _try_clause4:
case _try_in: case _try_in:
CHECK(save_PtoOp(stream, pc->u.l.l)); CHECK(save_PtoOp(stream, pc->y_u.l.l));
pc = NEXTOP(pc,l); pc = NEXTOP(pc,l);
break; break;
/* instructions type llll */ /* instructions type llll */
case _switch_on_type: case _switch_on_type:
CHECK(save_PtoOp(stream, pc->u.llll.l1)); CHECK(save_PtoOp(stream, pc->y_u.llll.l1));
CHECK(save_PtoOp(stream, pc->u.llll.l2)); CHECK(save_PtoOp(stream, pc->y_u.llll.l2));
CHECK(save_PtoOp(stream, pc->u.llll.l3)); CHECK(save_PtoOp(stream, pc->y_u.llll.l3));
CHECK(save_PtoOp(stream, pc->u.llll.l4)); CHECK(save_PtoOp(stream, pc->y_u.llll.l4));
pc = NEXTOP(pc,llll); pc = NEXTOP(pc,llll);
break; break;
/* instructions type lp */ /* instructions type lp */
@ -306,8 +306,8 @@
case _try_exo: case _try_exo:
case _try_exo_udi: case _try_exo_udi:
case _user_switch: case _user_switch:
CHECK(save_PtoOp(stream, pc->u.lp.l)); CHECK(save_PtoOp(stream, pc->y_u.lp.l));
CHECK(save_PtoPred(stream, pc->u.lp.p)); CHECK(save_PtoPred(stream, pc->y_u.lp.p));
pc = NEXTOP(pc,lp); pc = NEXTOP(pc,lp);
break; break;
/* instructions type o */ /* instructions type o */
@ -319,21 +319,21 @@
case _unify_list_write: case _unify_list_write:
case _unify_void: case _unify_void:
case _unify_void_write: case _unify_void_write:
CHECK(save_Opcode(stream, pc->u.o.opcw)); CHECK(save_Opcode(stream, pc->y_u.o.opcw));
pc = NEXTOP(pc,o); pc = NEXTOP(pc,o);
break; break;
/* instructions type oD */ /* instructions type oD */
case _unify_dbterm: case _unify_dbterm:
case _unify_l_dbterm: case _unify_l_dbterm:
CHECK(save_Opcode(stream, pc->u.oD.opcw)); CHECK(save_Opcode(stream, pc->y_u.oD.opcw));
CHECK(save_DBGroundTerm(stream, pc->u.oD.D)); CHECK(save_DBGroundTerm(stream, pc->y_u.oD.D));
pc = NEXTOP(pc,oD); pc = NEXTOP(pc,oD);
break; break;
/* instructions type oN */ /* instructions type oN */
case _unify_bigint: case _unify_bigint:
case _unify_l_bigint: case _unify_l_bigint:
CHECK(save_Opcode(stream, pc->u.oN.opcw)); CHECK(save_Opcode(stream, pc->y_u.oN.opcw));
CHECK(save_BlobTermInCode(stream, pc->u.oN.b)); CHECK(save_BlobTermInCode(stream, pc->y_u.oN.b));
pc = NEXTOP(pc,oN); pc = NEXTOP(pc,oN);
break; break;
/* instructions type oc */ /* instructions type oc */
@ -341,8 +341,8 @@
case _unify_atom_write: case _unify_atom_write:
case _unify_l_atom: case _unify_l_atom:
case _unify_l_atom_write: case _unify_l_atom_write:
CHECK(save_Opcode(stream, pc->u.oc.opcw)); CHECK(save_Opcode(stream, pc->y_u.oc.opcw));
CHECK(save_ConstantTerm(stream, pc->u.oc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.oc.c));
pc = NEXTOP(pc,oc); pc = NEXTOP(pc,oc);
break; break;
/* instructions type od */ /* instructions type od */
@ -350,8 +350,8 @@
case _unify_float_write: case _unify_float_write:
case _unify_l_float: case _unify_l_float:
case _unify_l_float_write: case _unify_l_float_write:
CHECK(save_Opcode(stream, pc->u.od.opcw)); CHECK(save_Opcode(stream, pc->y_u.od.opcw));
CHECK(save_DoubleInCode(stream, pc->u.od.d)); CHECK(save_DoubleInCode(stream, pc->y_u.od.d));
pc = NEXTOP(pc,od); pc = NEXTOP(pc,od);
break; break;
/* instructions type ofa */ /* instructions type ofa */
@ -359,9 +359,9 @@
case _unify_l_struc_write: case _unify_l_struc_write:
case _unify_struct: case _unify_struct:
case _unify_struct_write: case _unify_struct_write:
CHECK(save_Opcode(stream, pc->u.ofa.opcw)); CHECK(save_Opcode(stream, pc->y_u.ofa.opcw));
CHECK(save_Func(stream, pc->u.ofa.f)); CHECK(save_Func(stream, pc->y_u.ofa.f));
CHECK(save_Arity(stream, pc->u.ofa.a)); CHECK(save_Arity(stream, pc->y_u.ofa.a));
pc = NEXTOP(pc,ofa); pc = NEXTOP(pc,ofa);
break; break;
/* instructions type oi */ /* instructions type oi */
@ -369,17 +369,17 @@
case _unify_l_longint_write: case _unify_l_longint_write:
case _unify_longint: case _unify_longint:
case _unify_longint_write: case _unify_longint_write:
CHECK(save_Opcode(stream, pc->u.oi.opcw)); CHECK(save_Opcode(stream, pc->y_u.oi.opcw));
CHECK(save_IntegerInCode(stream, pc->u.oi.i)); CHECK(save_IntegerInCode(stream, pc->y_u.oi.i));
pc = NEXTOP(pc,oi); pc = NEXTOP(pc,oi);
break; break;
/* instructions type ollll */ /* instructions type ollll */
case _switch_list_nl: case _switch_list_nl:
CHECK(save_Opcode(stream, pc->u.ollll.pop)); CHECK(save_Opcode(stream, pc->y_u.ollll.pop));
CHECK(save_PtoOp(stream, pc->u.ollll.l1)); CHECK(save_PtoOp(stream, pc->y_u.ollll.l1));
CHECK(save_PtoOp(stream, pc->u.ollll.l2)); CHECK(save_PtoOp(stream, pc->y_u.ollll.l2));
CHECK(save_PtoOp(stream, pc->u.ollll.l3)); CHECK(save_PtoOp(stream, pc->y_u.ollll.l3));
CHECK(save_PtoOp(stream, pc->u.ollll.l4)); CHECK(save_PtoOp(stream, pc->y_u.ollll.l4));
pc = NEXTOP(pc,ollll); pc = NEXTOP(pc,ollll);
break; break;
/* instructions type os */ /* instructions type os */
@ -390,23 +390,23 @@
case _unify_l_n_voids_write: case _unify_l_n_voids_write:
case _unify_n_voids: case _unify_n_voids:
case _unify_n_voids_write: case _unify_n_voids_write:
CHECK(save_Opcode(stream, pc->u.os.opcw)); CHECK(save_Opcode(stream, pc->y_u.os.opcw));
CHECK(save_Constant(stream, pc->u.os.s)); CHECK(save_Constant(stream, pc->y_u.os.s));
pc = NEXTOP(pc,os); pc = NEXTOP(pc,os);
break; break;
/* instructions type osc */ /* instructions type osc */
case _unify_n_atoms: case _unify_n_atoms:
case _unify_n_atoms_write: case _unify_n_atoms_write:
CHECK(save_Opcode(stream, pc->u.osc.opcw)); CHECK(save_Opcode(stream, pc->y_u.osc.opcw));
CHECK(save_Constant(stream, pc->u.osc.s)); CHECK(save_Constant(stream, pc->y_u.osc.s));
CHECK(save_ConstantTerm(stream, pc->u.osc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.osc.c));
pc = NEXTOP(pc,osc); pc = NEXTOP(pc,osc);
break; break;
/* instructions type ou */ /* instructions type ou */
case _unify_l_string: case _unify_l_string:
case _unify_string: case _unify_string:
CHECK(save_Opcode(stream, pc->u.ou.opcw)); CHECK(save_Opcode(stream, pc->y_u.ou.opcw));
CHECK(save_BlobTermInCode(stream, pc->u.ou.ut)); CHECK(save_BlobTermInCode(stream, pc->y_u.ou.ut));
pc = NEXTOP(pc,ou); pc = NEXTOP(pc,ou);
break; break;
/* instructions type ox */ /* instructions type ox */
@ -426,8 +426,8 @@
case _unify_x_val_write: case _unify_x_val_write:
case _unify_x_var: case _unify_x_var:
case _unify_x_var_write: case _unify_x_var_write:
CHECK(save_Opcode(stream, pc->u.ox.opcw)); CHECK(save_Opcode(stream, pc->y_u.ox.opcw));
CHECK(save_X(stream, pc->u.ox.x)); CHECK(save_X(stream, pc->y_u.ox.x));
pc = NEXTOP(pc,ox); pc = NEXTOP(pc,ox);
break; break;
/* instructions type oxx */ /* instructions type oxx */
@ -435,9 +435,9 @@
case _unify_l_x_var2_write: case _unify_l_x_var2_write:
case _unify_x_var2: case _unify_x_var2:
case _unify_x_var2_write: case _unify_x_var2_write:
CHECK(save_Opcode(stream, pc->u.oxx.opcw)); CHECK(save_Opcode(stream, pc->y_u.oxx.opcw));
CHECK(save_X(stream, pc->u.oxx.xl)); CHECK(save_X(stream, pc->y_u.oxx.xl));
CHECK(save_X(stream, pc->u.oxx.xr)); CHECK(save_X(stream, pc->y_u.oxx.xr));
pc = NEXTOP(pc,oxx); pc = NEXTOP(pc,oxx);
break; break;
/* instructions type oy */ /* instructions type oy */
@ -457,8 +457,8 @@
case _unify_y_val_write: case _unify_y_val_write:
case _unify_y_var: case _unify_y_var:
case _unify_y_var_write: case _unify_y_var_write:
CHECK(save_Opcode(stream, pc->u.oy.opcw)); CHECK(save_Opcode(stream, pc->y_u.oy.opcw));
CHECK(save_Y(stream, pc->u.oy.y)); CHECK(save_Y(stream, pc->y_u.oy.y));
pc = NEXTOP(pc,oy); pc = NEXTOP(pc,oy);
break; break;
/* instructions type p */ /* instructions type p */
@ -471,43 +471,43 @@
case _retry_profiled: case _retry_profiled:
case _retry_udi: case _retry_udi:
case _try_udi: case _try_udi:
CHECK(save_PtoPred(stream, pc->u.p.p)); CHECK(save_PtoPred(stream, pc->y_u.p.p));
pc = NEXTOP(pc,p); pc = NEXTOP(pc,p);
break; break;
/* instructions type plxxs */ /* instructions type plxxs */
case _call_bfunc_xx: case _call_bfunc_xx:
CHECK(save_PtoPred(stream, pc->u.plxxs.p)); CHECK(save_PtoPred(stream, pc->y_u.plxxs.p));
CHECK(save_PtoOp(stream, pc->u.plxxs.f)); CHECK(save_PtoOp(stream, pc->y_u.plxxs.f));
CHECK(save_X(stream, pc->u.plxxs.x1)); CHECK(save_X(stream, pc->y_u.plxxs.x1));
CHECK(save_X(stream, pc->u.plxxs.x2)); CHECK(save_X(stream, pc->y_u.plxxs.x2));
CHECK(save_Constant(stream, pc->u.plxxs.flags)); CHECK(save_Constant(stream, pc->y_u.plxxs.flags));
pc = NEXTOP(pc,plxxs); pc = NEXTOP(pc,plxxs);
break; break;
/* instructions type plxys */ /* instructions type plxys */
case _call_bfunc_xy: case _call_bfunc_xy:
case _call_bfunc_yx: case _call_bfunc_yx:
CHECK(save_PtoPred(stream, pc->u.plxys.p)); CHECK(save_PtoPred(stream, pc->y_u.plxys.p));
CHECK(save_PtoOp(stream, pc->u.plxys.f)); CHECK(save_PtoOp(stream, pc->y_u.plxys.f));
CHECK(save_X(stream, pc->u.plxys.x)); CHECK(save_X(stream, pc->y_u.plxys.x));
CHECK(save_Y(stream, pc->u.plxys.y)); CHECK(save_Y(stream, pc->y_u.plxys.y));
CHECK(save_Constant(stream, pc->u.plxys.flags)); CHECK(save_Constant(stream, pc->y_u.plxys.flags));
pc = NEXTOP(pc,plxys); pc = NEXTOP(pc,plxys);
break; break;
/* instructions type plyys */ /* instructions type plyys */
case _call_bfunc_yy: case _call_bfunc_yy:
CHECK(save_PtoPred(stream, pc->u.plyys.p)); CHECK(save_PtoPred(stream, pc->y_u.plyys.p));
CHECK(save_PtoOp(stream, pc->u.plyys.f)); CHECK(save_PtoOp(stream, pc->y_u.plyys.f));
CHECK(save_Y(stream, pc->u.plyys.y1)); CHECK(save_Y(stream, pc->y_u.plyys.y1));
CHECK(save_Y(stream, pc->u.plyys.y2)); CHECK(save_Y(stream, pc->y_u.plyys.y2));
CHECK(save_Constant(stream, pc->u.plyys.flags)); CHECK(save_Constant(stream, pc->y_u.plyys.flags));
pc = NEXTOP(pc,plyys); pc = NEXTOP(pc,plyys);
break; break;
/* instructions type pp */ /* instructions type pp */
case _dexecute: case _dexecute:
case _execute: case _execute:
case _execute_cpred: case _execute_cpred:
CHECK(save_PtoPred(stream, pc->u.pp.p)); CHECK(save_PtoPred(stream, pc->y_u.pp.p));
CHECK(save_PtoPred(stream, pc->u.pp.p0)); CHECK(save_PtoPred(stream, pc->y_u.pp.p0));
pc = NEXTOP(pc,pp); pc = NEXTOP(pc,pp);
break; break;
/* instructions type s */ /* instructions type s */
@ -516,29 +516,29 @@
case _cut_t: case _cut_t:
case _pop_n: case _pop_n:
case _write_n_voids: case _write_n_voids:
CHECK(save_Constant(stream, pc->u.s.s)); CHECK(save_Constant(stream, pc->y_u.s.s));
pc = NEXTOP(pc,s); pc = NEXTOP(pc,s);
break; break;
/* instructions type sc */ /* instructions type sc */
case _write_n_atoms: case _write_n_atoms:
CHECK(save_Constant(stream, pc->u.sc.s)); CHECK(save_Constant(stream, pc->y_u.sc.s));
CHECK(save_ConstantTerm(stream, pc->u.sc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.sc.c));
pc = NEXTOP(pc,sc); pc = NEXTOP(pc,sc);
break; break;
/* instructions type sllll */ /* instructions type sllll */
case _switch_on_sub_arg_type: case _switch_on_sub_arg_type:
CHECK(save_Constant(stream, pc->u.sllll.s)); CHECK(save_Constant(stream, pc->y_u.sllll.s));
CHECK(save_PtoOp(stream, pc->u.sllll.l1)); CHECK(save_PtoOp(stream, pc->y_u.sllll.l1));
CHECK(save_PtoOp(stream, pc->u.sllll.l2)); CHECK(save_PtoOp(stream, pc->y_u.sllll.l2));
CHECK(save_PtoOp(stream, pc->u.sllll.l3)); CHECK(save_PtoOp(stream, pc->y_u.sllll.l3));
CHECK(save_PtoOp(stream, pc->u.sllll.l4)); CHECK(save_PtoOp(stream, pc->y_u.sllll.l4));
pc = NEXTOP(pc,sllll); pc = NEXTOP(pc,sllll);
break; break;
/* instructions type slp */ /* instructions type slp */
case _call_c_wfail: case _call_c_wfail:
CHECK(save_Constant(stream, pc->u.slp.s)); CHECK(save_Constant(stream, pc->y_u.slp.s));
CHECK(save_PtoOp(stream, pc->u.slp.l)); CHECK(save_PtoOp(stream, pc->y_u.slp.l));
CHECK(save_PtoPred(stream, pc->u.slp.p)); CHECK(save_PtoPred(stream, pc->y_u.slp.p));
pc = NEXTOP(pc,slp); pc = NEXTOP(pc,slp);
break; break;
/* instructions type sssl */ /* instructions type sssl */
@ -548,20 +548,20 @@
case _if_func: case _if_func:
case _switch_on_cons: case _switch_on_cons:
case _switch_on_func: case _switch_on_func:
CHECK(save_Constant(stream, pc->u.sssl.s)); CHECK(save_Constant(stream, pc->y_u.sssl.s));
CHECK(save_Constant(stream, pc->u.sssl.e)); CHECK(save_Constant(stream, pc->y_u.sssl.e));
CHECK(save_Constant(stream, pc->u.sssl.w)); CHECK(save_Constant(stream, pc->y_u.sssl.w));
CHECK(save_PtoOp(stream, pc->u.sssl.l)); CHECK(save_PtoOp(stream, pc->y_u.sssl.l));
pc = NEXTOP(pc,sssl); pc = NEXTOP(pc,sssl);
break; break;
/* instructions type sssllp */ /* instructions type sssllp */
case _expand_clauses: case _expand_clauses:
CHECK(save_Constant(stream, pc->u.sssllp.s1)); CHECK(save_Constant(stream, pc->y_u.sssllp.s1));
CHECK(save_Constant(stream, pc->u.sssllp.s2)); CHECK(save_Constant(stream, pc->y_u.sssllp.s2));
CHECK(save_Constant(stream, pc->u.sssllp.s3)); CHECK(save_Constant(stream, pc->y_u.sssllp.s3));
CHECK(save_PtoOp(stream, pc->u.sssllp.sprev)); CHECK(save_PtoOp(stream, pc->y_u.sssllp.sprev));
CHECK(save_PtoOp(stream, pc->u.sssllp.snext)); CHECK(save_PtoOp(stream, pc->y_u.sssllp.snext));
CHECK(save_PtoPred(stream, pc->u.sssllp.p)); CHECK(save_PtoPred(stream, pc->y_u.sssllp.p));
pc = NEXTOP(pc,sssllp); pc = NEXTOP(pc,sssllp);
break; break;
/* instructions type x */ /* instructions type x */
@ -572,50 +572,50 @@
case _write_x_loc: case _write_x_loc:
case _write_x_val: case _write_x_val:
case _write_x_var: case _write_x_var:
CHECK(save_X(stream, pc->u.x.x)); CHECK(save_X(stream, pc->y_u.x.x));
pc = NEXTOP(pc,x); pc = NEXTOP(pc,x);
break; break;
/* instructions type xD */ /* instructions type xD */
case _get_dbterm: case _get_dbterm:
case _put_dbterm: case _put_dbterm:
CHECK(save_X(stream, pc->u.xD.x)); CHECK(save_X(stream, pc->y_u.xD.x));
CHECK(save_DBGroundTerm(stream, pc->u.xD.D)); CHECK(save_DBGroundTerm(stream, pc->y_u.xD.D));
pc = NEXTOP(pc,xD); pc = NEXTOP(pc,xD);
break; break;
/* instructions type xN */ /* instructions type xN */
case _get_bigint: case _get_bigint:
case _put_bigint: case _put_bigint:
CHECK(save_X(stream, pc->u.xN.x)); CHECK(save_X(stream, pc->y_u.xN.x));
CHECK(save_BlobTermInCode(stream, pc->u.xN.b)); CHECK(save_BlobTermInCode(stream, pc->y_u.xN.b));
pc = NEXTOP(pc,xN); pc = NEXTOP(pc,xN);
break; break;
/* instructions type xc */ /* instructions type xc */
case _get_atom: case _get_atom:
case _put_atom: case _put_atom:
CHECK(save_X(stream, pc->u.xc.x)); CHECK(save_X(stream, pc->y_u.xc.x));
CHECK(save_ConstantTerm(stream, pc->u.xc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.xc.c));
pc = NEXTOP(pc,xc); pc = NEXTOP(pc,xc);
break; break;
/* instructions type xd */ /* instructions type xd */
case _get_float: case _get_float:
case _put_float: case _put_float:
CHECK(save_X(stream, pc->u.xd.x)); CHECK(save_X(stream, pc->y_u.xd.x));
CHECK(save_DoubleInCode(stream, pc->u.xd.d)); CHECK(save_DoubleInCode(stream, pc->y_u.xd.d));
pc = NEXTOP(pc,xd); pc = NEXTOP(pc,xd);
break; break;
/* instructions type xfa */ /* instructions type xfa */
case _get_struct: case _get_struct:
case _put_struct: case _put_struct:
CHECK(save_X(stream, pc->u.xfa.x)); CHECK(save_X(stream, pc->y_u.xfa.x));
CHECK(save_Func(stream, pc->u.xfa.f)); CHECK(save_Func(stream, pc->y_u.xfa.f));
CHECK(save_Arity(stream, pc->u.xfa.a)); CHECK(save_Arity(stream, pc->y_u.xfa.a));
pc = NEXTOP(pc,xfa); pc = NEXTOP(pc,xfa);
break; break;
/* instructions type xi */ /* instructions type xi */
case _get_longint: case _get_longint:
case _put_longint: case _put_longint:
CHECK(save_X(stream, pc->u.xi.x)); CHECK(save_X(stream, pc->y_u.xi.x));
CHECK(save_IntegerInCode(stream, pc->u.xi.i)); CHECK(save_IntegerInCode(stream, pc->y_u.xi.i));
pc = NEXTOP(pc,xi); pc = NEXTOP(pc,xi);
break; break;
/* instructions type xl */ /* instructions type xl */
@ -629,37 +629,37 @@
case _p_number_x: case _p_number_x:
case _p_primitive_x: case _p_primitive_x:
case _p_var_x: case _p_var_x:
CHECK(save_X(stream, pc->u.xl.x)); CHECK(save_X(stream, pc->y_u.xl.x));
CHECK(save_PtoOp(stream, pc->u.xl.F)); CHECK(save_PtoOp(stream, pc->y_u.xl.F));
pc = NEXTOP(pc,xl); pc = NEXTOP(pc,xl);
break; break;
/* instructions type xll */ /* instructions type xll */
case _jump_if_nonvar: case _jump_if_nonvar:
CHECK(save_X(stream, pc->u.xll.x)); CHECK(save_X(stream, pc->y_u.xll.x));
CHECK(save_PtoOp(stream, pc->u.xll.l1)); CHECK(save_PtoOp(stream, pc->y_u.xll.l1));
CHECK(save_PtoOp(stream, pc->u.xll.l2)); CHECK(save_PtoOp(stream, pc->y_u.xll.l2));
pc = NEXTOP(pc,xll); pc = NEXTOP(pc,xll);
break; break;
/* instructions type xllll */ /* instructions type xllll */
case _switch_on_arg_type: case _switch_on_arg_type:
CHECK(save_X(stream, pc->u.xllll.x)); CHECK(save_X(stream, pc->y_u.xllll.x));
CHECK(save_PtoOp(stream, pc->u.xllll.l1)); CHECK(save_PtoOp(stream, pc->y_u.xllll.l1));
CHECK(save_PtoOp(stream, pc->u.xllll.l2)); CHECK(save_PtoOp(stream, pc->y_u.xllll.l2));
CHECK(save_PtoOp(stream, pc->u.xllll.l3)); CHECK(save_PtoOp(stream, pc->y_u.xllll.l3));
CHECK(save_PtoOp(stream, pc->u.xllll.l4)); CHECK(save_PtoOp(stream, pc->y_u.xllll.l4));
pc = NEXTOP(pc,xllll); pc = NEXTOP(pc,xllll);
break; break;
/* instructions type xps */ /* instructions type xps */
case _commit_b_x: case _commit_b_x:
CHECK(save_X(stream, pc->u.xps.x)); CHECK(save_X(stream, pc->y_u.xps.x));
CHECK(save_PtoPred(stream, pc->u.xps.p0)); CHECK(save_PtoPred(stream, pc->y_u.xps.p0));
CHECK(save_Constant(stream, pc->u.xps.s)); CHECK(save_Constant(stream, pc->y_u.xps.s));
pc = NEXTOP(pc,xps); pc = NEXTOP(pc,xps);
break; break;
/* instructions type xu */ /* instructions type xu */
case _get_string: case _get_string:
CHECK(save_X(stream, pc->u.xu.x)); CHECK(save_X(stream, pc->y_u.xu.x));
CHECK(save_BlobTermInCode(stream, pc->u.xu.ut)); CHECK(save_BlobTermInCode(stream, pc->y_u.xu.ut));
pc = NEXTOP(pc,xu); pc = NEXTOP(pc,xu);
break; break;
/* instructions type xx */ /* instructions type xx */
@ -670,15 +670,15 @@
case _glist_valx: case _glist_valx:
case _put_x_val: case _put_x_val:
case _put_x_var: case _put_x_var:
CHECK(save_X(stream, pc->u.xx.xl)); CHECK(save_X(stream, pc->y_u.xx.xl));
CHECK(save_X(stream, pc->u.xx.xr)); CHECK(save_X(stream, pc->y_u.xx.xr));
pc = NEXTOP(pc,xx); pc = NEXTOP(pc,xx);
break; break;
/* instructions type xxc */ /* instructions type xxc */
case _p_func2s_cv: case _p_func2s_cv:
CHECK(save_X(stream, pc->u.xxc.x)); CHECK(save_X(stream, pc->y_u.xxc.x));
CHECK(save_X(stream, pc->u.xxc.xi)); CHECK(save_X(stream, pc->y_u.xxc.xi));
CHECK(save_ConstantTerm(stream, pc->u.xxc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.xxc.c));
pc = NEXTOP(pc,xxc); pc = NEXTOP(pc,xxc);
break; break;
/* instructions type xxn */ /* instructions type xxn */
@ -695,9 +695,9 @@
case _p_slr_cv: case _p_slr_cv:
case _p_slr_vc: case _p_slr_vc:
case _p_times_vc: case _p_times_vc:
CHECK(save_X(stream, pc->u.xxn.x)); CHECK(save_X(stream, pc->y_u.xxn.x));
CHECK(save_X(stream, pc->u.xxn.xi)); CHECK(save_X(stream, pc->y_u.xxn.xi));
CHECK(save_Integer(stream, pc->u.xxn.c)); CHECK(save_Integer(stream, pc->y_u.xxn.c));
pc = NEXTOP(pc,xxn); pc = NEXTOP(pc,xxn);
break; break;
/* instructions type xxx */ /* instructions type xxx */
@ -712,24 +712,24 @@
case _p_sll_vv: case _p_sll_vv:
case _p_slr_vv: case _p_slr_vv:
case _p_times_vv: case _p_times_vv:
CHECK(save_X(stream, pc->u.xxx.x)); CHECK(save_X(stream, pc->y_u.xxx.x));
CHECK(save_X(stream, pc->u.xxx.x1)); CHECK(save_X(stream, pc->y_u.xxx.x1));
CHECK(save_X(stream, pc->u.xxx.x2)); CHECK(save_X(stream, pc->y_u.xxx.x2));
pc = NEXTOP(pc,xxx); pc = NEXTOP(pc,xxx);
break; break;
/* instructions type xxxx */ /* instructions type xxxx */
case _put_xx_val: case _put_xx_val:
CHECK(save_X(stream, pc->u.xxxx.xl1)); CHECK(save_X(stream, pc->y_u.xxxx.xl1));
CHECK(save_X(stream, pc->u.xxxx.xl2)); CHECK(save_X(stream, pc->y_u.xxxx.xl2));
CHECK(save_X(stream, pc->u.xxxx.xr1)); CHECK(save_X(stream, pc->y_u.xxxx.xr1));
CHECK(save_X(stream, pc->u.xxxx.xr2)); CHECK(save_X(stream, pc->y_u.xxxx.xr2));
pc = NEXTOP(pc,xxxx); pc = NEXTOP(pc,xxxx);
break; break;
/* instructions type xxy */ /* instructions type xxy */
case _p_func2f_xy: case _p_func2f_xy:
CHECK(save_X(stream, pc->u.xxy.x)); CHECK(save_X(stream, pc->y_u.xxy.x));
CHECK(save_X(stream, pc->u.xxy.x1)); CHECK(save_X(stream, pc->y_u.xxy.x1));
CHECK(save_Y(stream, pc->u.xxy.y2)); CHECK(save_Y(stream, pc->y_u.xxy.y2));
pc = NEXTOP(pc,xxy); pc = NEXTOP(pc,xxy);
break; break;
/* instructions type y */ /* instructions type y */
@ -737,7 +737,7 @@
case _write_y_loc: case _write_y_loc:
case _write_y_val: case _write_y_val:
case _write_y_var: case _write_y_var:
CHECK(save_Y(stream, pc->u.y.y)); CHECK(save_Y(stream, pc->y_u.y.y));
pc = NEXTOP(pc,y); pc = NEXTOP(pc,y);
break; break;
/* instructions type yl */ /* instructions type yl */
@ -751,15 +751,15 @@
case _p_number_y: case _p_number_y:
case _p_primitive_y: case _p_primitive_y:
case _p_var_y: case _p_var_y:
CHECK(save_Y(stream, pc->u.yl.y)); CHECK(save_Y(stream, pc->y_u.yl.y));
CHECK(save_PtoOp(stream, pc->u.yl.F)); CHECK(save_PtoOp(stream, pc->y_u.yl.F));
pc = NEXTOP(pc,yl); pc = NEXTOP(pc,yl);
break; break;
/* instructions type yps */ /* instructions type yps */
case _commit_b_y: case _commit_b_y:
CHECK(save_Y(stream, pc->u.yps.y)); CHECK(save_Y(stream, pc->y_u.yps.y));
CHECK(save_PtoPred(stream, pc->u.yps.p0)); CHECK(save_PtoPred(stream, pc->y_u.yps.p0));
CHECK(save_Constant(stream, pc->u.yps.s)); CHECK(save_Constant(stream, pc->y_u.yps.s));
pc = NEXTOP(pc,yps); pc = NEXTOP(pc,yps);
break; break;
/* instructions type yx */ /* instructions type yx */
@ -771,15 +771,15 @@
case _put_unsafe: case _put_unsafe:
case _put_y_val: case _put_y_val:
case _put_y_var: case _put_y_var:
CHECK(save_Y(stream, pc->u.yx.y)); CHECK(save_Y(stream, pc->y_u.yx.y));
CHECK(save_X(stream, pc->u.yx.x)); CHECK(save_X(stream, pc->y_u.yx.x));
pc = NEXTOP(pc,yx); pc = NEXTOP(pc,yx);
break; break;
/* instructions type yxc */ /* instructions type yxc */
case _p_func2s_y_cv: case _p_func2s_y_cv:
CHECK(save_Y(stream, pc->u.yxc.y)); CHECK(save_Y(stream, pc->y_u.yxc.y));
CHECK(save_X(stream, pc->u.yxc.xi)); CHECK(save_X(stream, pc->y_u.yxc.xi));
CHECK(save_ConstantTerm(stream, pc->u.yxc.c)); CHECK(save_ConstantTerm(stream, pc->y_u.yxc.c));
pc = NEXTOP(pc,yxc); pc = NEXTOP(pc,yxc);
break; break;
/* instructions type yxn */ /* instructions type yxn */
@ -796,9 +796,9 @@
case _p_slr_y_cv: case _p_slr_y_cv:
case _p_slr_y_vc: case _p_slr_y_vc:
case _p_times_y_vc: case _p_times_y_vc:
CHECK(save_Y(stream, pc->u.yxn.y)); CHECK(save_Y(stream, pc->y_u.yxn.y));
CHECK(save_X(stream, pc->u.yxn.xi)); CHECK(save_X(stream, pc->y_u.yxn.xi));
CHECK(save_Integer(stream, pc->u.yxn.c)); CHECK(save_Integer(stream, pc->y_u.yxn.c));
pc = NEXTOP(pc,yxn); pc = NEXTOP(pc,yxn);
break; break;
/* instructions type yxx */ /* instructions type yxx */
@ -813,25 +813,25 @@
case _p_sll_y_vv: case _p_sll_y_vv:
case _p_slr_y_vv: case _p_slr_y_vv:
case _p_times_y_vv: case _p_times_y_vv:
CHECK(save_Y(stream, pc->u.yxx.y)); CHECK(save_Y(stream, pc->y_u.yxx.y));
CHECK(save_X(stream, pc->u.yxx.x1)); CHECK(save_X(stream, pc->y_u.yxx.x1));
CHECK(save_X(stream, pc->u.yxx.x2)); CHECK(save_X(stream, pc->y_u.yxx.x2));
pc = NEXTOP(pc,yxx); pc = NEXTOP(pc,yxx);
break; break;
/* instructions type yyx */ /* instructions type yyx */
case _p_func2f_yy: case _p_func2f_yy:
CHECK(save_Y(stream, pc->u.yyx.y1)); CHECK(save_Y(stream, pc->y_u.yyx.y1));
CHECK(save_Y(stream, pc->u.yyx.y2)); CHECK(save_Y(stream, pc->y_u.yyx.y2));
CHECK(save_X(stream, pc->u.yyx.x)); CHECK(save_X(stream, pc->y_u.yyx.x));
pc = NEXTOP(pc,yyx); pc = NEXTOP(pc,yyx);
break; break;
/* instructions type yyxx */ /* instructions type yyxx */
case _get_yy_var: case _get_yy_var:
case _put_y_vals: case _put_y_vals:
CHECK(save_Y(stream, pc->u.yyxx.y1)); CHECK(save_Y(stream, pc->y_u.yyxx.y1));
CHECK(save_Y(stream, pc->u.yyxx.y2)); CHECK(save_Y(stream, pc->y_u.yyxx.y2));
CHECK(save_X(stream, pc->u.yyxx.x1)); CHECK(save_X(stream, pc->y_u.yyxx.x1));
CHECK(save_X(stream, pc->u.yyxx.x2)); CHECK(save_X(stream, pc->y_u.yyxx.x2));
pc = NEXTOP(pc,yyxx); pc = NEXTOP(pc,yyxx);
break; break;
#ifdef YAPOR #ifdef YAPOR
@ -840,14 +840,14 @@
case _getwork_seq: case _getwork_seq:
case _sync: case _sync:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te)); CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif #endif
CHECK(save_Arity(stream, pc->u.Otapl.s)); CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p)); CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -873,14 +873,14 @@
case _table_try_me: case _table_try_me:
case _table_try_single: case _table_try_single:
#ifdef YAPOR #ifdef YAPOR
CHECK(save_OrArg(stream, pc->u.Otapl.or_arg)); CHECK(save_OrArg(stream, pc->y_u.Otapl.or_arg));
#endif #endif
#ifdef TABLING #ifdef TABLING
CHECK(save_TabEntry(stream, pc->u.Otapl.te)); CHECK(save_TabEntry(stream, pc->y_u.Otapl.te));
#endif #endif
CHECK(save_Arity(stream, pc->u.Otapl.s)); CHECK(save_Arity(stream, pc->y_u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p)); CHECK(save_PtoPred(stream, pc->y_u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->y_u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -892,7 +892,7 @@
break; break;
/* instructions type s */ /* instructions type s */
case _table_new_answer: case _table_new_answer:
CHECK(save_Constant(stream, pc->u.s.s)); CHECK(save_Constant(stream, pc->y_u.s.s));
pc = NEXTOP(pc,s); pc = NEXTOP(pc,s);
break; break;
/* instructions type e */ /* instructions type e */

View File

@ -15,10 +15,10 @@
break; break;
/* instructions type Illss */ /* instructions type Illss */
case _enter_lu_pred: case _enter_lu_pred:
return walk_got_lu_block(pc->u.Illss.I, startp, endp); return walk_got_lu_block(pc->y_u.Illss.I, startp, endp);
/* instructions type L */ /* instructions type L */
case _alloc_for_logical_pred: case _alloc_for_logical_pred:
return walk_got_lu_clause(pc->u.L.ClBase, startp, endp); return walk_got_lu_clause(pc->y_u.L.ClBase, startp, endp);
/* instructions type N */ /* instructions type N */
case _write_bigint: case _write_bigint:
pc = NEXTOP(pc,N); pc = NEXTOP(pc,N);
@ -27,7 +27,7 @@
case _either: case _either:
case _or_else: case _or_else:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.Osblp.p0; pp = pc->y_u.Osblp.p0;
pc = NEXTOP(pc,Osblp); pc = NEXTOP(pc,Osblp);
break; break;
/* instructions type Osbmp */ /* instructions type Osbmp */
@ -41,30 +41,30 @@
break; break;
/* instructions type Osbpp */ /* instructions type Osbpp */
case _call_cpred: case _call_cpred:
pp = pc->u.Osbpp.p; pp = pc->y_u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp); return walk_found_c_pred(pp, startp, endp);
case _call_usercpred: case _call_usercpred:
pp = pc->u.Osbpp.p; pp = pc->y_u.Osbpp.p;
return walk_found_c_pred(pp, startp, endp); return walk_found_c_pred(pp, startp, endp);
case _p_execute2: case _p_execute2:
return found_meta_call(startp, endp); return found_meta_call(startp, endp);
case _call: case _call:
case _fcall: case _fcall:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.Osbpp.p0; pp = pc->y_u.Osbpp.p0;
pc = NEXTOP(pc,Osbpp); pc = NEXTOP(pc,Osbpp);
break; break;
/* instructions type OtILl */ /* instructions type OtILl */
case _count_trust_logical: case _count_trust_logical:
case _profiled_trust_logical: case _profiled_trust_logical:
case _trust_logical: case _trust_logical:
return walk_got_lu_block(pc->u.OtILl.block, startp, endp); return walk_got_lu_block(pc->y_u.OtILl.block, startp, endp);
/* instructions type OtaLl */ /* instructions type OtaLl */
case _count_retry_logical: case _count_retry_logical:
case _profiled_retry_logical: case _profiled_retry_logical:
case _retry_logical: case _retry_logical:
case _try_logical: case _try_logical:
pc = pc->u.OtaLl.n; pc = pc->y_u.OtaLl.n;
break; break;
/* instructions type OtapFs */ /* instructions type OtapFs */
case _cut_c: case _cut_c:
@ -74,7 +74,7 @@
case _try_c: case _try_c:
case _try_userc: case _try_userc:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.OtapFs.p; pp = pc->y_u.OtapFs.p;
pc = NEXTOP(pc,OtapFs); pc = NEXTOP(pc,OtapFs);
break; break;
/* instructions type Otapl */ /* instructions type Otapl */
@ -94,7 +94,7 @@
case _try_clause: case _try_clause:
case _try_me: case _try_me:
clause_code = FALSE; clause_code = FALSE;
pp = pc->u.Otapl.p; pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type aFlp */ /* instructions type aFlp */
@ -342,7 +342,7 @@
/* instructions type p */ /* instructions type p */
case _lock_lu: case _lock_lu:
case _procceed: case _procceed:
pp = pc->u.p.p; pp = pc->y_u.p.p;
if (pp->PredFlags & MegaClausePredFlag) if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp); return found_mega_clause(pp, startp, endp);
clause_code = TRUE; clause_code = TRUE;
@ -372,12 +372,12 @@
break; break;
/* instructions type pp */ /* instructions type pp */
case _execute_cpred: case _execute_cpred:
pp = pc->u.pp.p; pp = pc->y_u.pp.p;
return walk_found_c_pred(pp, startp, endp); return walk_found_c_pred(pp, startp, endp);
case _dexecute: case _dexecute:
case _execute: case _execute:
clause_code = TRUE; clause_code = TRUE;
pp = pc->u.pp.p0; pp = pc->y_u.pp.p0;
pc = NEXTOP(pc,pp); pc = NEXTOP(pc,pp);
break; break;
/* instructions type s */ /* instructions type s */
@ -398,7 +398,7 @@
break; break;
/* instructions type slp */ /* instructions type slp */
case _call_c_wfail: case _call_c_wfail:
pp = pc->u.slp.p; pp = pc->y_u.slp.p;
return walk_found_c_pred(pp, startp, endp); return walk_found_c_pred(pp, startp, endp);
/* instructions type sssl */ /* instructions type sssl */
case _go_on_cons: case _go_on_cons:
@ -619,7 +619,7 @@
case _getwork_seq: case _getwork_seq:
case _sync: case _sync:
clause_code = FALSE; clause_code = FALSE;
pp = pc->u.Otapl.p; pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -644,7 +644,7 @@
case _table_try_me: case _table_try_me:
case _table_try_single: case _table_try_single:
clause_code = FALSE; clause_code = FALSE;
pp = pc->u.Otapl.p; pp = pc->y_u.Otapl.p;
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
/* instructions type e */ /* instructions type e */
@ -728,13 +728,13 @@
/* this instruction is hardwired */ /* this instruction is hardwired */
case _or_last: case _or_last:
#ifdef YAPOR #ifdef YAPOR
pp = pc->u.Osblp.p0; pp = pc->y_u.Osblp.p0;
if (pp->PredFlags & MegaClausePredFlag) if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp); return found_mega_clause(pp, startp, endp);
clause_code = TRUE; clause_code = TRUE;
pc = NEXTOP(pc,Osblp); pc = NEXTOP(pc,Osblp);
#else #else
pp = pc->u.p.p; pp = pc->y_u.p.p;
if (pp->PredFlags & MegaClausePredFlag) if (pp->PredFlags & MegaClausePredFlag)
return found_mega_clause(pp, startp, endp); return found_mega_clause(pp, startp, endp);
clause_code = TRUE; clause_code = TRUE;

View File

@ -266,8 +266,8 @@ int Yap_PlFGetchar(void);
int Yap_GetCharForSIGINT(void); int Yap_GetCharForSIGINT(void);
Int Yap_StreamToFileNo(Term); Int Yap_StreamToFileNo(Term);
Term Yap_OpenStream(FILE *,char *,Term,int); Term Yap_OpenStream(FILE *,char *,Term,int);
Term Yap_StringToTerm(char *,Term *);
char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags); char *Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int flags);
char *Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags);
int Yap_GetFreeStreamD(void); int Yap_GetFreeStreamD(void);
int Yap_GetFreeStreamDForReading(void); int Yap_GetFreeStreamDForReading(void);

View File

@ -52,7 +52,7 @@ DOCSDIR=$(SHAREDIR)/doc/Yap
# #
YAP_EXTRAS=@YAP_EXTRAS@ YAP_EXTRAS=@YAP_EXTRAS@
YAPSTARTUP=startup.yss YAPSTARTUP=@SAVED_STATE_PREFIX@startup.yss
# #
# Please do not add YAP_EXTRA flags here: if you do check the flags # Please do not add YAP_EXTRA flags here: if you do check the flags
@ -108,6 +108,7 @@ VPATH=@srcdir@
CWD=$(PWD) CWD=$(PWD)
# #
VERSION=@YAP_VERSION@ VERSION=@YAP_VERSION@
Y=@YAP_MAJOR_VERSION@
DOC_VERSION=@DOC_VERSION@ DOC_VERSION=@DOC_VERSION@
MYDDAS_VERSION=@MYDDAS_VERSION@ MYDDAS_VERSION=@MYDDAS_VERSION@
# #
@ -451,6 +452,9 @@ clause_list.o: C/clause_list.c include/clause_list.h config.h
udi.o: C/udi.c config.h udi.o: C/udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $< -o $@ $(CC) -c $(C_INTERF_FLAGS) $< -o $@
save.o: C/save.c
$(CC) -c $(C_INTERF_FLAGS) -DYAPSTARTUP=\"$(YAPSTARTUP)\" $< -o $@
%.o: C/%.c config.h %.o: C/%.c config.h
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
@ -510,9 +514,6 @@ c_interface.i: C/c_interface.c include/c_interface.h
$(CC) -E $(C_INTERF_FLAGS) C/c_interface.c > $@ $(CC) -E $(C_INTERF_FLAGS) C/c_interface.c > $@
# #
mycb: mycb.c
$(CC) $(CFLAGS) mycb.c -o mycb
INSTALLED_PACKAGES= \ INSTALLED_PACKAGES= \
library/matrix \ library/matrix \
library/random \ library/random \
@ -568,7 +569,7 @@ all: startup.yss
-rm -f startup.yss -rm -f startup.yss
echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). qsave_program('startup.yss')." | @PRE_INSTALL_ENV@ ./yap@EXEC_SUFFIX@ -b $(srcdir)/pl/boot.yap echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). qsave_program('startup.yss')." | @PRE_INSTALL_ENV@ ./yap@EXEC_SUFFIX@ -b $(srcdir)/pl/boot.yap
yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@ yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@ libYap.a
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap@EXEC_SUFFIX@ yap.o @YAPLIB@ $(LIBS) $(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap@EXEC_SUFFIX@ yap.o @YAPLIB@ $(LIBS)
yap-win: yap-win@EXEC_SUFFIX@ yap-win: yap-win@EXEC_SUFFIX@
@ -579,38 +580,39 @@ yap-win@EXEC_SUFFIX@: $(PLCONS_OBJECTS) $(HEADERS) @YAPLIB@
(cd swi/console; $(MAKE)) (cd swi/console; $(MAKE))
$(MPI_CC) -municode -DUNICODE -D_UNICODE $(EXECUTABLE_CFLAGS) $(LDFLAGS) -Wl,-subsystem,windows -o yap-win@EXEC_SUFFIX@ $(PLCONS_OBJECTS) plterm.dll @YAPLIB@ $(LIBS) -lgdi32 @MPILDF@ $(MPI_CC) -municode -DUNICODE -D_UNICODE $(EXECUTABLE_CFLAGS) $(LDFLAGS) -Wl,-subsystem,windows -o yap-win@EXEC_SUFFIX@ $(PLCONS_OBJECTS) plterm.dll @YAPLIB@ $(LIBS) -lgdi32 @MPILDF@
libYap.a: $(LIB_OBJECTS) libYap.a: $(LIB_OBJECTS) yapi.o
-rm -f libYap.a -rm -f libYap.a
$(AR) rc libYap.a $(LIB_OBJECTS) $(AR) rc libYap.a $(LIB_OBJECTS) yapi.o
$(RANLIB) libYap.a $(RANLIB) libYap.a
@DYNYAPLIB@: $(LIB_OBJECTS) yapi.o libYap.a @DYNYAPLIB@: $(LIB_OBJECTS)
@YAPLIB_LD@ -o @YAPLIB@ $(LIB_OBJECTS) $(LIBS) $(LDFLAGS) $(SONAMEFLAG) @SHLIB_LD@ -o @YAPLIB@ $(LIB_OBJECTS) $(LIBS) $(LDFLAGS) $(SONAMEFLAG)
for p in $(EXTRAYAPLIBS); do \ for p in $(EXTRAYAPLIBS); do \
$(LN_S) -f @DYNYAPLIB@ $$p; \ $(LN_S) -f @DYNYAPLIB@ $$p; \
done done
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES) $(SWI_LIB_SOURCES) @STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES)
adb shell mkdir -p /data/yap adb shell mkdir -p /data/yap
adb shell mkdir -p /data/yap/pl adb shell mkdir -p /data/yap/pl
adb shell mkdir -p /data/yap/swi/library adb shell mkdir -p /data/yap/swi/library
adb push yap /data/yap/ adb push yap /data/yap/
adb push libYap.so.? /data/yap/ adb push @DYNYAPLIB@ /data/yap/
adb push $(GMPDIR)/lib/libgmp.so data/yap/
adb push $(srcdir)/swi/library /data/yap/swi/library adb push $(srcdir)/swi/library /data/yap/swi/library
adb push $(srcdir)/pl /data/yap/pl/ adb push $(srcdir)/pl /data/yap/pl/
adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap" adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap"
adb pull /data/yap/startup.yss . adb pull /data/yap/startup.yss
$(MAKE) install_unix
install: @INSTALL_COMMAND@ install_common install: @INSTALL_COMMAND@ install_startup install_common
install_unix: startup.yss @YAPLIB@ install_unix: @YAPLIB@ yap@EXEC_SUFFIX@
mkdir -p $(DESTDIR)$(BINDIR) mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(YAPLIBDIR) mkdir -p $(DESTDIR)$(YAPLIBDIR)
mkdir -p $(DESTDIR)$(SHAREDIR) mkdir -p $(DESTDIR)$(SHAREDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/icons mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/icons
$(INSTALL_PROGRAM) -m 755 yap@EXEC_SUFFIX@ $(DESTDIR)$(BINDIR)/yap $(INSTALL_PROGRAM) -m 755 yap@EXEC_SUFFIX@ $(DESTDIR)$(BINDIR)/yap
$(INSTALL_DATA) startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
$(INSTALL_DATA) -m 755 @YAPLIB@ $(DESTDIR)$(LIBDIR) $(INSTALL_DATA) -m 755 @YAPLIB@ $(DESTDIR)$(LIBDIR)
install_startup: startup.yss install_startup: startup.yss
@ -626,10 +628,12 @@ install_win32: startup.yss @WINDOWS@ yap-win@EXEC_SUFFIX@
@WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap-win.exe $(DESTDIR)$(BINDIR)/yap-win.exe @WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap-win.exe $(DESTDIR)$(BINDIR)/yap-win.exe
@WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe @WINDOWS@ $(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
@WINDOWS@ for i in *.dll; do $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(BINDIR)/; done @WINDOWS@ for i in *.dll; do $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(BINDIR)/; done
$(INSTALL_DATA) startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
$(INSTALL_DATA) $(srcdir)/misc/icons/yap.ico $(DESTDIR)$(SHAREDIR)/Yap/icons/yap.ico $(INSTALL_DATA) $(srcdir)/misc/icons/yap.ico $(DESTDIR)$(SHAREDIR)/Yap/icons/yap.ico
install_common: install_common: install_startup
mkdir -p $(DESTDIR)$(YAPLIBDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/PrologCommons mkdir -p $(DESTDIR)$(SHAREDIR)/PrologCommons
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/pl mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/pl
mkdir -p $(DESTDIR)$(DOCSDIR) mkdir -p $(DESTDIR)$(DOCSDIR)
@ -728,11 +732,11 @@ install_info:
fi; \ fi; \
$(INSTALL_INFO) --quiet --section "Programming Languages" --entry="`cat pillow_doc.infoindex`" --info-dir=$(DESTDIR)$(INFODIR) pillow_doc.info $(INSTALL_INFO) --quiet --section "Programming Languages" --entry="`cat pillow_doc.infoindex`" --info-dir=$(DESTDIR)$(INFODIR) pillow_doc.info
install_docs: install_docs: doxygen
$(MAKE) pdf $(MAKE) pdf
$(MAKE) html $(MAKE) html
$(INSTALL_DATA) yap.html* $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) html $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) yap.pdf $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) pdf $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) README.TXT $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) README.TXT $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) Artistic $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) Artistic $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) COPYING $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) COPYING $(DESTDIR)$(DOCSDIR)
@ -741,6 +745,8 @@ install_docs:
$(INSTALL_DATA) changes-5.1.html $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) changes-5.1.html $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) changes-6.0.html $(DESTDIR)$(DOCSDIR) $(INSTALL_DATA) changes-6.0.html $(DESTDIR)$(DOCSDIR)
doxygen:
doxygen $(srcdir)/docs/doxygen.rc
info: yap.info info: yap.info

View File

@ -80,16 +80,16 @@ static inline qg_sol_fr_ptr CUT_prune_solution_frames(qg_sol_fr_ptr, int);
#define YAMOP_LTT_BITS OOOOPPS!!! Unknown Integer Sizeof #define YAMOP_LTT_BITS OOOOPPS!!! Unknown Integer Sizeof
#endif /* SIZEOF_INT */ #endif /* SIZEOF_INT */
#define YAMOP_OR_ARG(INST) ((INST)->u.Otapl.or_arg) #define YAMOP_OR_ARG(INST) ((INST)->y_u.Otapl.or_arg)
#define YAMOP_LTT(INST) (((INST)->u.Otapl.or_arg) & YAMOP_LTT_BITS) #define YAMOP_LTT(INST) (((INST)->y_u.Otapl.or_arg) & YAMOP_LTT_BITS)
#define YAMOP_SEQ(INST) (((INST)->u.Otapl.or_arg) & YAMOP_SEQ_FLAG) #define YAMOP_SEQ(INST) (((INST)->y_u.Otapl.or_arg) & YAMOP_SEQ_FLAG)
#define YAMOP_CUT(INST) (((INST)->u.Otapl.or_arg) & YAMOP_CUT_FLAG) #define YAMOP_CUT(INST) (((INST)->y_u.Otapl.or_arg) & YAMOP_CUT_FLAG)
#define YAMOP_FLAGS(INST) (((INST)->u.Otapl.or_arg) & YAMOP_FLAGS_BITS) #define YAMOP_FLAGS(INST) (((INST)->y_u.Otapl.or_arg) & YAMOP_FLAGS_BITS)
#define INIT_YAMOP_LTT(INST, LTT) ((INST)->u.Otapl.or_arg = LTT+1) #define INIT_YAMOP_LTT(INST, LTT) ((INST)->y_u.Otapl.or_arg = LTT+1)
#define PUT_YAMOP_LTT(INST, LTT) (INST)->u.Otapl.or_arg = YAMOP_FLAGS(INST) | (LTT+1) #define PUT_YAMOP_LTT(INST, LTT) (INST)->y_u.Otapl.or_arg = YAMOP_FLAGS(INST) | (LTT+1)
#define PUT_YAMOP_SEQ(INST) (INST)->u.Otapl.or_arg |= YAMOP_SEQ_FLAG #define PUT_YAMOP_SEQ(INST) (INST)->y_u.Otapl.or_arg |= YAMOP_SEQ_FLAG
#define PUT_YAMOP_CUT(INST) (INST)->u.Otapl.or_arg |= YAMOP_CUT_FLAG #define PUT_YAMOP_CUT(INST) (INST)->y_u.Otapl.or_arg |= YAMOP_CUT_FLAG
#define BRANCH(WORKER, DEPTH) GLOBAL_branch(WORKER, DEPTH) #define BRANCH(WORKER, DEPTH) GLOBAL_branch(WORKER, DEPTH)
#define BRANCH_LTT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_LTT_BITS) #define BRANCH_LTT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_LTT_BITS)

View File

@ -434,14 +434,14 @@
if (PREG->opc == Yap_opcode(_table_try)) { if (PREG->opc == Yap_opcode(_table_try)) {
/* table_try */ /* table_try */
code_ap = NEXTOP(PREG,Otapl); code_ap = NEXTOP(PREG,Otapl);
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
} else if (PREG->opc == Yap_opcode(_table_try_single)) { } else if (PREG->opc == Yap_opcode(_table_try_single)) {
/* table_try_single */ /* table_try_single */
code_ap = COMPLETION; code_ap = COMPLETION;
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
} else { } else {
/* table_try_me */ /* table_try_me */
code_ap = PREG->u.Otapl.d; code_ap = PREG->y_u.Otapl.d;
PREG = NEXTOP(PREG,Otapl); PREG = NEXTOP(PREG,Otapl);
} }
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
@ -453,7 +453,7 @@
GONext(); GONext();
} }
#else #else
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
GONext(); GONext();
#endif /* INCOMPLETE_TABLING */ #endif /* INCOMPLETE_TABLING */
@ -470,7 +470,7 @@
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(TR); check_trail(TR);
tab_ent = PREG->u.Otapl.te; tab_ent = PREG->y_u.Otapl.te;
YENV2MEM; YENV2MEM;
sg_fr = subgoal_search(PREG, YENV_ADDRESS); sg_fr = subgoal_search(PREG, YENV_ADDRESS);
MEM2YENV; MEM2YENV;
@ -488,7 +488,7 @@
#ifdef THREADS_CONSUMER_SHARING #ifdef THREADS_CONSUMER_SHARING
if (SgFr_state(sg_fr) == ready_external) { if (SgFr_state(sg_fr) == ready_external) {
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
store_generator_consumer_node(tab_ent, sg_fr, TRUE, PREG->u.Otapl.s); store_generator_consumer_node(tab_ent, sg_fr, TRUE, PREG->y_u.Otapl.s);
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
check_for_deadlock(sg_fr); check_for_deadlock(sg_fr);
@ -505,9 +505,9 @@
} else } else
#endif /* DETERMINISTIC_TABLING */ #endif /* DETERMINISTIC_TABLING */
{ {
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, COMPLETION); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, COMPLETION);
} }
PREG = PREG->u.Otapl.d; /* should work also with PREG = NEXTOP(PREG,Otapl); */ PREG = PREG->y_u.Otapl.d; /* should work also with PREG = NEXTOP(PREG,Otapl); */
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
GONext(); GONext();
@ -522,7 +522,7 @@
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
SgFr_try_answer(sg_fr) = ans_node; SgFr_try_answer(sg_fr) = ans_node;
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, TRY_ANSWER);
PREG = (yamop *) CPREG; PREG = (yamop *) CPREG;
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
load_answer(ans_node, subs_ptr); load_answer(ans_node, subs_ptr);
@ -638,7 +638,7 @@
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(TR); check_trail(TR);
tab_ent = PREG->u.Otapl.te; tab_ent = PREG->y_u.Otapl.te;
YENV2MEM; YENV2MEM;
sg_fr = subgoal_search(PREG, YENV_ADDRESS); sg_fr = subgoal_search(PREG, YENV_ADDRESS);
MEM2YENV; MEM2YENV;
@ -657,7 +657,7 @@
if (SgFr_state(sg_fr) == ready_external) { if (SgFr_state(sg_fr) == ready_external) {
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
store_generator_consumer_node(tab_ent, sg_fr, TRUE, PREG->u.Otapl.s); store_generator_consumer_node(tab_ent, sg_fr, TRUE, PREG->y_u.Otapl.s);
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
check_for_deadlock(sg_fr); check_for_deadlock(sg_fr);
@ -668,7 +668,7 @@
/* subgoal new */ /* subgoal new */
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, PREG->u.Otapl.d); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, PREG->y_u.Otapl.d);
PREG = NEXTOP(PREG, Otapl); PREG = NEXTOP(PREG, Otapl);
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
@ -684,7 +684,7 @@
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
SgFr_try_answer(sg_fr) = ans_node; SgFr_try_answer(sg_fr) = ans_node;
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, TRY_ANSWER);
PREG = (yamop *) CPREG; PREG = (yamop *) CPREG;
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
load_answer(ans_node, subs_ptr); load_answer(ans_node, subs_ptr);
@ -788,7 +788,7 @@
sg_fr_ptr sg_fr; sg_fr_ptr sg_fr;
check_trail(TR); check_trail(TR);
tab_ent = PREG->u.Otapl.te; tab_ent = PREG->y_u.Otapl.te;
YENV2MEM; YENV2MEM;
sg_fr = subgoal_search(PREG, YENV_ADDRESS); sg_fr = subgoal_search(PREG, YENV_ADDRESS);
MEM2YENV; MEM2YENV;
@ -807,7 +807,7 @@
if (SgFr_state(sg_fr) == ready_external) { if (SgFr_state(sg_fr) == ready_external) {
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
store_generator_consumer_node(tab_ent, sg_fr, TRUE , PREG->u.Otapl.s); store_generator_consumer_node(tab_ent, sg_fr, TRUE , PREG->y_u.Otapl.s);
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
check_for_deadlock(sg_fr); check_for_deadlock(sg_fr);
@ -818,8 +818,8 @@
/* subgoal new */ /* subgoal new */
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, NEXTOP(PREG,Otapl)); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, NEXTOP(PREG,Otapl));
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
allocate_environment(); allocate_environment();
GONext(); GONext();
@ -834,7 +834,7 @@
init_subgoal_frame(sg_fr); init_subgoal_frame(sg_fr);
UNLOCK_SG_FR(sg_fr); UNLOCK_SG_FR(sg_fr);
SgFr_try_answer(sg_fr) = ans_node; SgFr_try_answer(sg_fr) = ans_node;
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER); store_generator_node(tab_ent, sg_fr, PREG->y_u.Otapl.s, TRY_ANSWER);
PREG = (yamop *) CPREG; PREG = (yamop *) CPREG;
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
load_answer(ans_node, subs_ptr); load_answer(ans_node, subs_ptr);
@ -946,7 +946,7 @@
************************************************************************/ ************************************************************************/
Op(table_retry_me, Otapl) Op(table_retry_me, Otapl)
restore_generator_node(PREG->u.Otapl.s, PREG->u.Otapl.d); restore_generator_node(PREG->y_u.Otapl.s, PREG->y_u.Otapl.d);
YENV = (CELL *) PROTECT_FROZEN_B(B); YENV = (CELL *) PROTECT_FROZEN_B(B);
set_cut(YENV, B->cp_b); set_cut(YENV, B->cp_b);
SET_BB(NORM_CP(YENV)); SET_BB(NORM_CP(YENV));
@ -962,12 +962,12 @@
************************************************************************/ ************************************************************************/
Op(table_retry, Otapl) Op(table_retry, Otapl)
restore_generator_node(PREG->u.Otapl.s, NEXTOP(PREG,Otapl)); restore_generator_node(PREG->y_u.Otapl.s, NEXTOP(PREG,Otapl));
YENV = (CELL *) PROTECT_FROZEN_B(B); YENV = (CELL *) PROTECT_FROZEN_B(B);
set_cut(YENV, B->cp_b); set_cut(YENV, B->cp_b);
SET_BB(NORM_CP(YENV)); SET_BB(NORM_CP(YENV));
allocate_environment(); allocate_environment();
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
GONext(); GONext();
ENDOp(); ENDOp();
@ -978,10 +978,10 @@
************************************************************************/ ************************************************************************/
Op(table_trust_me, Otapl) Op(table_trust_me, Otapl)
restore_generator_node(PREG->u.Otapl.s, COMPLETION); restore_generator_node(PREG->y_u.Otapl.s, COMPLETION);
#ifdef DETERMINISTIC_TABLING #ifdef DETERMINISTIC_TABLING
if (B_FZ > B && IS_BATCHED_NORM_GEN_CP(B)) { if (B_FZ > B && IS_BATCHED_NORM_GEN_CP(B)) {
CELL *subs_ptr = (CELL *)(GEN_CP(B) + 1) + PREG->u.Otapl.s; CELL *subs_ptr = (CELL *)(GEN_CP(B) + 1) + PREG->y_u.Otapl.s;
choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1); choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1);
sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr; sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr;
DET_GEN_CP(gcp)->cp_sg_fr = sg_fr; DET_GEN_CP(gcp)->cp_sg_fr = sg_fr;
@ -1010,10 +1010,10 @@
************************************************************************/ ************************************************************************/
Op(table_trust, Otapl) Op(table_trust, Otapl)
restore_generator_node(PREG->u.Otapl.s, COMPLETION); restore_generator_node(PREG->y_u.Otapl.s, COMPLETION);
#ifdef DETERMINISTIC_TABLING #ifdef DETERMINISTIC_TABLING
if (B_FZ > B && IS_BATCHED_NORM_GEN_CP(B)) { if (B_FZ > B && IS_BATCHED_NORM_GEN_CP(B)) {
CELL *subs_ptr = (CELL *)(GEN_CP(B) + 1) + PREG->u.Otapl.s; CELL *subs_ptr = (CELL *)(GEN_CP(B) + 1) + PREG->y_u.Otapl.s;
choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1); choiceptr gcp = NORM_CP(DET_GEN_CP(subs_ptr) - 1);
sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr; sg_fr_ptr sg_fr = GEN_CP(B)->cp_sg_fr;
DET_GEN_CP(gcp)->cp_sg_fr = sg_fr; DET_GEN_CP(gcp)->cp_sg_fr = sg_fr;
@ -1031,7 +1031,7 @@
set_cut(YENV, B->cp_b); set_cut(YENV, B->cp_b);
SET_BB(NORM_CP(YENV)); SET_BB(NORM_CP(YENV));
allocate_environment(); allocate_environment();
PREG = PREG->u.Otapl.d; PREG = PREG->y_u.Otapl.d;
GONext(); GONext();
ENDOp(); ENDOp();
@ -1056,7 +1056,7 @@
#endif /* DETERMINISTIC_TABLING */ #endif /* DETERMINISTIC_TABLING */
{ {
sg_fr = GEN_CP(gcp)->cp_sg_fr; sg_fr = GEN_CP(gcp)->cp_sg_fr;
subs_ptr = (CELL *)(GEN_CP(gcp) + 1) + PREG->u.s.s; subs_ptr = (CELL *)(GEN_CP(gcp) + 1) + PREG->y_u.s.s;
} }
#if defined(DEBUG_TABLING) && !defined(DETERMINISTIC_TABLING) #if defined(DEBUG_TABLING) && !defined(DETERMINISTIC_TABLING)
{ {
@ -1064,7 +1064,7 @@
CELL *aux_args; CELL *aux_args;
CELL *aux_subs; CELL *aux_subs;
arity_args = PREG->u.s.s; arity_args = PREG->y_u.s.s;
arity_subs = *subs_ptr; arity_subs = *subs_ptr;
aux_args = (CELL *)(GEN_CP(gcp) + 1); aux_args = (CELL *)(GEN_CP(gcp) + 1);
aux_subs = subs_ptr; aux_subs = subs_ptr;

View File

@ -271,8 +271,8 @@ typedef struct subgoal_entry {
#define SgEnt_lock(X) ((X)->lock) #define SgEnt_lock(X) ((X)->lock)
#define SgEnt_code(X) ((X)->code_of_subgoal) #define SgEnt_code(X) ((X)->code_of_subgoal)
#define SgEnt_tab_ent(X) (((X)->code_of_subgoal)->u.Otapl.te) #define SgEnt_tab_ent(X) (((X)->code_of_subgoal)->y_u.Otapl.te)
#define SgEnt_arity(X) (((X)->code_of_subgoal)->u.Otapl.s) #define SgEnt_arity(X) (((X)->code_of_subgoal)->y_u.Otapl.s)
#define SgEnt_hash_chain(X) ((X)->hash_chain) #define SgEnt_hash_chain(X) ((X)->hash_chain)
#define SgEnt_answer_trie(X) ((X)->answer_trie) #define SgEnt_answer_trie(X) ((X)->answer_trie)
#define SgEnt_first_answer(X) ((X)->first_answer) #define SgEnt_first_answer(X) ((X)->first_answer)
@ -316,8 +316,8 @@ typedef struct subgoal_frame {
#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ #endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */
#define SgFr_lock(X) (SUBGOAL_ENTRY(X) lock) #define SgFr_lock(X) (SUBGOAL_ENTRY(X) lock)
#define SgFr_code(X) (SUBGOAL_ENTRY(X) code_of_subgoal) #define SgFr_code(X) (SUBGOAL_ENTRY(X) code_of_subgoal)
#define SgFr_tab_ent(X) ((SUBGOAL_ENTRY(X) code_of_subgoal)->u.Otapl.te) #define SgFr_tab_ent(X) ((SUBGOAL_ENTRY(X) code_of_subgoal)->y_u.Otapl.te)
#define SgFr_arity(X) ((SUBGOAL_ENTRY(X) code_of_subgoal)->u.Otapl.s) #define SgFr_arity(X) ((SUBGOAL_ENTRY(X) code_of_subgoal)->y_u.Otapl.s)
#define SgFr_hash_chain(X) (SUBGOAL_ENTRY(X) hash_chain) #define SgFr_hash_chain(X) (SUBGOAL_ENTRY(X) hash_chain)
#define SgFr_answer_trie(X) (SUBGOAL_ENTRY(X) answer_trie) #define SgFr_answer_trie(X) (SUBGOAL_ENTRY(X) answer_trie)
#define SgFr_first_answer(X) (SUBGOAL_ENTRY(X) first_answer) #define SgFr_first_answer(X) (SUBGOAL_ENTRY(X) first_answer)

View File

@ -1071,8 +1071,8 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
stack_vars = *Yaddr; stack_vars = *Yaddr;
subs_arity = 0; subs_arity = 0;
pred_arity = preg->u.Otapl.s; pred_arity = preg->y_u.Otapl.s;
tab_ent = preg->u.Otapl.te; tab_ent = preg->y_u.Otapl.te;
current_sg_node = get_insert_subgoal_trie(tab_ent PASS_REGS); current_sg_node = get_insert_subgoal_trie(tab_ent PASS_REGS);
LOCK_SUBGOAL_TRIE(tab_ent); LOCK_SUBGOAL_TRIE(tab_ent);

View File

@ -12,4 +12,12 @@
#undef SIZEOF_FLOAT #undef SIZEOF_FLOAT
#undef SIZEOF_DOUBLE #undef SIZEOF_DOUBLE
#ifndef HAVE_INTTYPES_H
#undef HAVE_INTTYPES_H
#endif
#ifndef HAVE_STDINT_H
#undef HAVE_STDINT_H
#endif
#endif #endif

View File

@ -324,6 +324,9 @@
/* Define to 1 if you have the `lgamma' function. */ /* Define to 1 if you have the `lgamma' function. */
#undef HAVE_LGAMMA #undef HAVE_LGAMMA
/* Define to 1 if you have the `android' library (-landroid). */
#undef HAVE_LIBANDROID
/* Define to 1 if you have the `comdlg32' library (-lcomdlg32). */ /* Define to 1 if you have the `comdlg32' library (-lcomdlg32). */
#undef HAVE_LIBCOMDLG32 #undef HAVE_LIBCOMDLG32
@ -339,6 +342,9 @@
/* Define to 1 if you have the <LibLoaderAPI.h> header file. */ /* Define to 1 if you have the <LibLoaderAPI.h> header file. */
#undef HAVE_LIBLOADERAPI_H #undef HAVE_LIBLOADERAPI_H
/* Define to 1 if you have the `log' library (-llog). */
#undef HAVE_LIBLOG
/* Define to 1 if you have the `m' library (-lm). */ /* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM #undef HAVE_LIBM
@ -501,6 +507,9 @@
/* Define to 1 if you have the `pthread_mutexattr_settype' function. */ /* Define to 1 if you have the `pthread_mutexattr_settype' function. */
#undef HAVE_PTHREAD_MUTEXATTR_SETTYPE #undef HAVE_PTHREAD_MUTEXATTR_SETTYPE
/* Define to 1 if you have the `pthread_setconcurrency' function. */
#undef HAVE_PTHREAD_SETCONCURRENCY
/* Define to 1 if you have the `putenv' function. */ /* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV #undef HAVE_PUTENV

890
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ AC_ARG_WITH(sysroot,
CFLAGS="$CFLAGS --sysroot=$SYSROOT" CFLAGS="$CFLAGS --sysroot=$SYSROOT"
CPPFLAGS="$CPPFLAGS --sysroot=$SYSROOT" CPPFLAGS="$CPPFLAGS --sysroot=$SYSROOT"
LDFLAGS="$LDFLAGS --sysroot=$SYSROOT" ], LDFLAGS="$LDFLAGS --sysroot=$SYSROOT" ],
[yap_cv_gmp=yes]) [])
AC_PROG_CC AC_PROG_CC
AC_PROG_CPP AC_PROG_CPP
@ -184,9 +184,9 @@ AC_ARG_ENABLE(dlcompat,
[ --enable-dlcompat use dlcompat library for dynamic loading on Mac OS X], [ --enable-dlcompat use dlcompat library for dynamic loading on Mac OS X],
use_dlcompat="$enableval", use_dlcompat=no) use_dlcompat="$enableval", use_dlcompat=no)
AC_ARG_ENABLE(clpbn-horus, AC_ARG_ENABLE(horus,
[ --enable-clpbn-horus enable CLPBN HORUS library. ], [ --enable-horus enable CLPBN HORUS library. ],
yap_cv_clpbn_horus="$enableval", horus=yes) yap_cv_horus="$enableval", yap_cv_horus=yes)
AC_ARG_WITH(gmp, AC_ARG_WITH(gmp,
[ --with-gmp[=DIR] use GNU Multiple Precision in DIR], [ --with-gmp[=DIR] use GNU Multiple Precision in DIR],
@ -368,7 +368,7 @@ else
INSTALL_PRISM="packages/prism/src/c packages/prism/src/prolog" INSTALL_PRISM="packages/prism/src/c packages/prism/src/prolog"
fi fi
if test "$yap_cv_clpbn_bp"="yes"; then if test "$yap_cv_horus"="yes"; then
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
my_save_cxxflags="$CXXFLAGS" my_save_cxxflags="$CXXFLAGS"
CXXFLAGS=-std=c++0x CXXFLAGS=-std=c++0x
@ -376,13 +376,13 @@ if test "$yap_cv_clpbn_bp"="yes"; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])], [AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])] [AC_MSG_RESULT([no])]
[yap_cv_clpbn_bp=no] [yap_cv_horus=no]
) )
CXXFLAGS="$my_save_cxxflags" CXXFLAGS="$my_save_cxxflags"
AC_LANG_POP() AC_LANG_POP()
fi fi
if test "$yap_cv_clpbn_bp" = no if test "$yap_cv_horus" = no
then then
PKG_CLPBN="packages/CLPBN" PKG_CLPBN="packages/CLPBN"
else else
@ -409,6 +409,8 @@ else
STATIC_MODE="# " STATIC_MODE="# "
fi fi
AC_CHECK_DECL(__clang_major__, CLANG=yes, CLANG=no)
dnl Compilation Flags dnl Compilation Flags
if test "$GCC" = "yes" if test "$GCC" = "yes"
then then
@ -595,7 +597,7 @@ then
AC_CHECK_LIB(pthread,pthread_create) AC_CHECK_LIB(pthread,pthread_create)
fi fi
else else
if test "$prefix" = "NONE" if test "$prefix" = "NONE" -a x"$SYSROOT" = x
then then
prefix=/usr/local prefix=/usr/local
fi fi
@ -603,8 +605,11 @@ else
then then
LDFLAGS="$LDFLAGS -L${prefix}/lib64" LDFLAGS="$LDFLAGS -L${prefix}/lib64"
fi fi
LDFLAGS="$LDFLAGS -L${prefix}/lib" if test x"$SYSROOT" = x
CPPFLAGS="$CPPFLAGS -I${prefix}/include" then
LDFLAGS="$LDFLAGS -L${prefix}/lib"
CPPFLAGS="$CPPFLAGS -I${prefix}/include"
fi
if test "$exec_prefix" != "NONE" -a "$exec_prefix" != "$prefix" if test "$exec_prefix" != "NONE" -a "$exec_prefix" != "$prefix"
then then
if test -d "${exec_prefix}/lib64" -a "$YAP_TARGET" = amd64; then if test -d "${exec_prefix}/lib64" -a "$YAP_TARGET" = amd64; then
@ -615,6 +620,16 @@ else
INSTALL_COMMAND="install_unix" INSTALL_COMMAND="install_unix"
WINDOWS="#" WINDOWS="#"
PKG_WINCONSOLE="" PKG_WINCONSOLE=""
case "$host" in
*android*)
AC_CHECK_LIB(android,main)
AC_CHECK_LIB(log,main)
;;
**)
STARTUP_ANDROID="x"
STARTUP_DEFAULT=""
;;
esac
AC_CHECK_LIB(m,sin) AC_CHECK_LIB(m,sin)
AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(socket,socket)
dnl X/Open Networking is sometimes a separate library dnl X/Open Networking is sometimes a separate library
@ -660,7 +675,7 @@ fi
if test "$threads" = yes if test "$threads" = yes
then then
AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(pthread.h)
AC_CHECK_FUNCS(pthread_mutexattr_setkind_np pthread_mutexattr_settype) AC_CHECK_FUNCS(pthread_mutexattr_setkind_np pthread_mutexattr_settype pthread_setconcurrency)
if test "$pthreadlocking" = yes if test "$pthreadlocking" = yes
then then
AC_DEFINE(USE_PTHREAD_LOCKING, 1, [do not use our own locking routines]) AC_DEFINE(USE_PTHREAD_LOCKING, 1, [do not use our own locking routines])
@ -860,7 +875,7 @@ fi
fi fi
if test "$have_nsl" = yes if test "$have_nsl" = yes
then then
LIBS="$LIBS -lnsl" LIBS="$LIBS -lnsl"
fi fi
if test "$dynamic_loading" = "yes" if test "$dynamic_loading" = "yes"
then then
@ -1009,8 +1024,14 @@ dnl Linux has both elf and a.out, in this case we found elf
fi fi
if test "$ac_cv_prog_gcc" = "yes" if test "$ac_cv_prog_gcc" = "yes"
then then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS" if test "$CLANG" = "yes"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS" then
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
else
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
fi
INSTALL_DLLS="yes" INSTALL_DLLS="yes"
fi fi
CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall" CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall"
@ -1220,7 +1241,7 @@ AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(arpa/inet.h alloca.h crtdbg.h crypt.h) AC_CHECK_HEADERS(arpa/inet.h alloca.h crtdbg.h crypt.h)
AC_CHECK_HEADERS(ctype.h direct.h dirent.h dlfcn.h) AC_CHECK_HEADERS(ctype.h direct.h dirent.h dlfcn.h)
AC_CHECK_HEADERS(errno.h execinfo.h fcntl.h fenv.h) AC_CHECK_HEADERS(errno.h execinfo.h fcntl.h fenv.h)
AC_CHECK_HEADERS(float.h fpu_control.h ieeefp.h io.h limits.h) AC_CHECK_HEADERS(float.h fpu_control.h ieeefp.h inttypes.h io.h limits.h)
AC_CHECK_HEADERS(malloc.h math.h memory.h) AC_CHECK_HEADERS(malloc.h math.h memory.h)
AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/tcp.h pwd.h regex.h shlobj.h) AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/tcp.h pwd.h regex.h shlobj.h)
AC_CHECK_HEADERS(siginfo.h signal.h stdarg.h stdint.h string.h stropts.h) AC_CHECK_HEADERS(siginfo.h signal.h stdarg.h stdint.h string.h stropts.h)
@ -1348,7 +1369,7 @@ AC_SUBST(ARCH)
case "$host" in case "$host" in
*android*) *android*)
STARTUP_ANDROID="" STARTUP_ANDROID=""
STARTUP_DEFAULT="x" STARTUP_DEFAULT="x"
;; ;;
**) **)
STARTUP_ANDROID="x" STARTUP_ANDROID="x"
@ -1424,6 +1445,8 @@ AC_SUBST(PKG_REAL)
AC_SUBST(INSTALL_PRISM) AC_SUBST(INSTALL_PRISM)
AC_SUBST(SAVED_STATE_PREFIX)
dnl check for threaded code dnl check for threaded code
AC_MSG_CHECKING(for gcc threaded code) AC_MSG_CHECKING(for gcc threaded code)
AC_CACHE_VAL(yap_cv_threaded_code,[ AC_CACHE_VAL(yap_cv_threaded_code,[
@ -1634,6 +1657,9 @@ AC_CHECK_FUNCS(time times tmpnam usleep utime vsnprintf wcsdup wcsnlen)
case "$host" in case "$host" in
*android*) *android*)
echo "no locale" echo "no locale"
SAVED_STATE_PREFIX="/assets/lib/Yap/"
AC_SUBST(C_PARSER_FLAGS)
AC_SUBST(GCC_VERSION)
;; ;;
**) **)
AC_CHECK_HEADERS(locale.h) AC_CHECK_HEADERS(locale.h)
@ -2006,7 +2032,7 @@ yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YA
yap_startup=startup.yss yap_startup=startup.yss
AC_DEFINE_UNQUOTED( C_CC, [ "$CC" ], [c-compiler used]) AC_DEFINE_UNQUOTED( C_CC, [ "$CC" ], [c-compiler used])
AC_DEFINE_UNQUOTED( C_CFLAGS, ["$CFLAGS $YAP_EXTRAS $DEFS -D_YAP_NOT_INSTALLED_=1 $CPPFLAGS -I. -I$srcdir/H -I$srcdir/include -I$srcdir/os -I$srcdir/OPTYap -I$srcdir/BEAM" ], [compilation flags]) AC_DEFINE_UNQUOTED( C_CFLAGS, ["$CFLAGS $YAP_EXTRAS $ -D_YAP_NOT_INSTALLED_=1 $CPPFLAGS -I. -I$srcdir/H -I$srcdir/include -I$srcdir/os -I$srcdir/OPTYap -I$srcdir/BEAM" ], [compilation flags])
AC_DEFINE_UNQUOTED( C_LDFLAGS, [ "$LDFLAGS" ], [linking flags]) AC_DEFINE_UNQUOTED( C_LDFLAGS, [ "$LDFLAGS" ], [linking flags])
AC_DEFINE_UNQUOTED( C_LIBS, [ "$LIBS" ], [main libs for YAP]) AC_DEFINE_UNQUOTED( C_LIBS, [ "$LIBS" ], [main libs for YAP])
AC_DEFINE_UNQUOTED( C_LIBPLSO, [ "$LIBS $EXTRA_LIBS_FOR_DLLS" ], [libs for linking with DLLs]) AC_DEFINE_UNQUOTED( C_LIBPLSO, [ "$LIBS $EXTRA_LIBS_FOR_DLLS" ], [libs for linking with DLLs])

View File

@ -136,7 +136,7 @@ typedef unsigned long uintptr_t;
#ifndef PL_HAVE_TERM_T #ifndef PL_HAVE_TERM_T
#define PL_HAVE_TERM_T #define PL_HAVE_TERM_T
typedef uintptr_t term_t; typedef intptr_t term_t;
#endif #endif
typedef struct mod_entry *module_t; typedef struct mod_entry *module_t;
typedef struct DB_STRUCT *record_t; typedef struct DB_STRUCT *record_t;
@ -505,7 +505,7 @@ extern X_API int PL_compare(term_t, term_t);
/* begin PL_unify_* functions =============================*/ /* begin PL_unify_* functions =============================*/
extern X_API int PL_unify(term_t, term_t); extern X_API int PL_unify(term_t, term_t);
extern X_API int PL_unify_atom(term_t, atom_t); extern X_API int PL_unify_atom(term_t, atom_t);
extern X_API int PL_unify_arg(int, term_t, atom_t); extern X_API int PL_unify_arg(int, term_t, term_t);
extern X_API int PL_unify_atom_chars(term_t, const char *); extern X_API int PL_unify_atom_chars(term_t, const char *);
extern X_API int PL_unify_atom_nchars(term_t, size_t len, const char *); extern X_API int PL_unify_atom_nchars(term_t, size_t len, const char *);
extern X_API int PL_unify_float(term_t, double); extern X_API int PL_unify_float(term_t, double);

View File

@ -43,6 +43,8 @@ typedef Term YAP_Module;
typedef int YAP_Bool; typedef int YAP_Bool;
typedef handle_t YAP_handle_t;
#define YAP_PredEntryPtr struct pred_entry * #define YAP_PredEntryPtr struct pred_entry *
#define YAP_UserCPred CPredicate #define YAP_UserCPred CPredicate
@ -91,6 +93,8 @@ typedef double YAP_Float;
#define FALSE 0 #define FALSE 0
#endif #endif
typedef YAP_Int YAP_handle_t;
typedef struct YAP_pred_entry *YAP_PredEntryPtr; typedef struct YAP_pred_entry *YAP_PredEntryPtr;
typedef YAP_Bool (* YAP_UserCPred)(void); typedef YAP_Bool (* YAP_UserCPred)(void);
@ -110,6 +114,9 @@ typedef struct YAP_thread_attr_struct {
YAP_Term egoal, alias; YAP_Term egoal, alias;
} YAP_thread_attr; } YAP_thread_attr;
#ifdef YAP_H
#include <threads.h>
#endif
typedef enum { typedef enum {
YAP_TAG_ATT = 0x1, YAP_TAG_ATT = 0x1,
@ -293,4 +300,16 @@ typedef enum
YAPC_ENABLE_AGC /* enable or disable atom garbage collection */ YAPC_ENABLE_AGC /* enable or disable atom garbage collection */
} yap_flag_t; } yap_flag_t;
#if __ANDROID__
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#else
inline void __android_log_print(int i, const char loc[], const char msg[], ...) {}
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
#endif
#endif /* _YAPDEFS_H */ #endif /* _YAPDEFS_H */

View File

@ -420,31 +420,31 @@ extern X_API void YAP_FlushAllStreams(void);
#define YAP_SEEKABLE_STREAM 0x80 #define YAP_SEEKABLE_STREAM 0x80
/* YAP_Term *YAP_NewSlots() */ /* YAP_Term *YAP_NewSlots() */
extern X_API YAP_Int YAP_NewSlots(int); extern X_API YAP_handle_t YAP_NewSlots(int);
/* YAP_Int YAP_CurrentSlot() */ /* YAP_Int YAP_CurrentSlot() */
extern X_API YAP_Int YAP_CurrentSlot(void); extern X_API YAP_handle_t YAP_CurrentSlot(void);
/* YAP_Term *YAP_InitSlot() */ /* YAP_Term *YAP_InitSlot() */
extern X_API YAP_Int YAP_InitSlot(YAP_Term); extern X_API YAP_handle_t YAP_InitSlot(YAP_Term);
/* YAP_Term YAP_GetFromSlots(t) */ /* YAP_Term YAP_GetFromSlots(t) */
extern X_API YAP_Term YAP_GetFromSlot(YAP_Int); extern X_API YAP_Term YAP_GetFromSlot(YAP_handle_t);
/* YAP_Term *YAP_AddressFromSlots(t) */ /* YAP_Term *YAP_AddressFromSlots(t) */
extern X_API YAP_Term *YAP_AddressFromSlot(YAP_Int); extern X_API YAP_Term *YAP_AddressFromSlot(YAP_handle_t);
/* YAP_Term *YAP_AddressOfTermInSlot(t) */ /* YAP_Term *YAP_AddressOfTermInSlot(t) */
extern X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_Int); extern X_API YAP_Term *YAP_AddressOfTermInSlot(YAP_handle_t);
/* YAP_Term YAP_PutInSlots(t) */ /* YAP_Term YAP_PutInSlots(t) */
extern X_API void YAP_PutInSlot(YAP_Int, YAP_Term); extern X_API void YAP_PutInSlot(YAP_handle_t, YAP_Term);
extern X_API int YAP_RecoverSlots(int n, YAP_Int top_slot); extern X_API int YAP_RecoverSlots(int n, YAP_handle_t top_slot);
extern X_API YAP_Int YAP_ArgsToSlots(int); extern X_API YAP_handle_t YAP_ArgsToSlots(int);
extern X_API void YAP_SlotsToArgs(int, YAP_Int); extern X_API void YAP_SlotsToArgs(int, YAP_handle_t);
/* void YAP_Throw() */ /* void YAP_Throw() */
extern X_API void YAP_Throw(YAP_Term); extern X_API void YAP_Throw(YAP_Term);

View File

@ -30,7 +30,7 @@ typedef void *yamop;
typedef char *ADDR; typedef char *ADDR;
#define RESET_VARIABLE(X) (*(X) = (CELL)(X)) // #define RESET_VARIABLE(X) (*(X) = (CELL)(X))
#ifdef _YAP_NOT_INSTALLED_ #ifdef _YAP_NOT_INSTALLED_
#include "Regs.h" #include "Regs.h"

View File

@ -81,7 +81,7 @@ do_gc(UInt sz)
yamop *nextpc; yamop *nextpc;
if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) { if (P && PREVOP(P,Osbpp)->opc == Yap_opcode(_call_usercpred)) {
arity = PREVOP(P,Osbpp)->u.Osbpp.p->ArityOfPE; arity = PREVOP(P,Osbpp)->y_u.Osbpp.p->ArityOfPE;
nextpc = P; nextpc = P;
} else { } else {
arity = 0; arity = 0;

View File

@ -61,7 +61,7 @@ void shift_right(RL_Tree *tree,const NUM idx,const long nnodes);
void shift_left(RL_Tree *tree,const NUM idx, const long nnodes); void shift_left(RL_Tree *tree,const NUM idx, const long nnodes);
void intersect_leafs(char *storage1,char *storage2); void intersect_leafs(char *storage1,char *storage2);
static void print_nodes(RL_Tree* tree); //static void print_nodes(RL_Tree* tree);
// //
RL_Buffer* buffer=NULL; RL_Buffer* buffer=NULL;
@ -245,6 +245,7 @@ NUM rl_next_in_bigger(RL_Tree *tree,NUM min) {
/* ****************************************************************************** /* ******************************************************************************
Private Functions Private Functions
****************************************************************************** */ ****************************************************************************** */
/*
static void print_nodes(RL_Tree* tree) { static void print_nodes(RL_Tree* tree) {
RL_Node* nodes=tree->root; RL_Node* nodes=tree->root;
int j; int j;
@ -253,6 +254,8 @@ static void print_nodes(RL_Tree* tree) {
printf("[%d]=%lu\n",j,(unsigned long int)nodes[j].leaf); printf("[%d]=%lu\n",j,(unsigned long int)nodes[j].leaf);
} }
*/
// treeXquadrantXinterval->quadrant_minXquadrant_max // treeXquadrantXinterval->quadrant_minXquadrant_max
static void quadrant_interval(RL_Tree *tree,short quadrant,NUM interval,NUM *quad_interval) { static void quadrant_interval(RL_Tree *tree,short quadrant,NUM interval,NUM *quad_interval) {

View File

@ -425,6 +425,8 @@ p_rl_b_in1(void) {
} }
} }
/* ******************************************************* */ /* ******************************************************* */
void init_rl(void);
void init_rl(void){ void init_rl(void){

View File

@ -295,6 +295,23 @@ list_directory(void)
YAP_PutInSlot(sl,YAP_MkPairTerm(ti, YAP_GetFromSlot(sl))); YAP_PutInSlot(sl,YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
} }
_findclose( hFile ); _findclose( hFile );
#elif __ANDROID__
{
extern AAssetManager *assetManager;
const char *dirName = buf+strlen("/assets/");
AAssetManager* mgr = assetManager;
AAssetDir *de;
const char* dp;
if ((de = AAssetManager_openDir(mgr, dirName)) == NULL) {
return(YAP_Unify(YAP_ARG3, YAP_MkIntTerm(errno)));
}
while (( dp = AAssetDir_getNextFileName(de))) {
YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(dp));
YAP_PutInSlot(sl,YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
}
AAssetDir_close(de);
}
#elif HAVE_OPENDIR #elif HAVE_OPENDIR
{ {
DIR *de; DIR *de;

View File

@ -381,7 +381,7 @@ F CommentHook CommentHook 3
F Context2 Context 2 F Context2 Context 2
F ConsistencyError ConsistencyError 1 F ConsistencyError ConsistencyError 1
F Creep Creep 1 F Creep Creep 1
F Csult Csult 1 F Csult Csult 2
F CurrentModule CurrentModule 1 F CurrentModule CurrentModule 1
F CutBy CutBy 1 F CutBy CutBy 1
F DBREF DBREF 1 F DBREF DBREF 1

View File

@ -269,7 +269,7 @@ UInt exo_arg =0
struct scan_atoms* search_atoms void struct scan_atoms* search_atoms void
// Slots // Slots
Int CurSlot =0 handle_t CurSlot =0
Term SourceModule =0 Term SourceModule =0

View File

@ -200,15 +200,15 @@ special_formats(C,"e") :- !,
special_formats(C,"l") :- !, special_formats(C,"l") :- !,
format(C,' if (op == _Ystop) return;~n',[]). format(C,' if (op == _Ystop) return;~n',[]).
special_formats(C,"sssl") :- !, special_formats(C,"sssl") :- !,
format(C,' AdjustSwitchTable(op, pc->u.sssl.l, pc->u.sssl.s);~n',[]). format(C,' AdjustSwitchTable(op, pc->y_u.sssl.l, pc->y_u.sssl.s);~n',[]).
special_formats(C,"Illss") :- !, special_formats(C,"Illss") :- !,
format(C,' opc = NEXTOP(pc,Illss); format(C,' opc = NEXTOP(pc,Illss);
pc = pc->u.Illss.l1; pc = pc->y_u.Illss.l1;
break;~n',[]), break;~n',[]),
% don't go to NEXTOP % don't go to NEXTOP
fail. fail.
special_formats(C,"OtaLl") :- !, special_formats(C,"OtaLl") :- !,
format(C,' pc = pc->u.OtaLl.n; format(C,' pc = pc->y_u.OtaLl.n;
break;~n',[]), break;~n',[]),
% don't go to NEXTOP % don't go to NEXTOP
fail. fail.
@ -230,10 +230,10 @@ dump_fields(C,[_|Info],Ops,T) :-
dump_field(C,I,O,T) :- dump_field(C,I,O,T) :-
rewritable_field(O), !, rewritable_field(O), !,
get_op(O,A), get_op(O,A),
format(C,' ~sAdjust(pc->u.~s.~s);~n',[A,T,I]). format(C,' ~sAdjust(pc->y_u.~s.~s);~n',[A,T,I]).
dump_field(C,I,O,T) :- dump_field(C,I,O,T) :-
get_op(O,A), get_op(O,A),
format(C,' pc->u.~s.~s = ~sAdjust(pc->u.~s.~s);~n',[T,I,A,T,I]). format(C,' pc->y_u.~s.~s = ~sAdjust(pc->y_u.~s.~s);~n',[T,I,A,T,I]).
rewritable_field(0'd). rewritable_field(0'd).
rewritable_field(0'i). rewritable_field(0'i).
@ -349,15 +349,15 @@ c_call_op("call_c_wfail").
% I field gives direct access to LU index block and to all Pred information % I field gives direct access to LU index block and to all Pred information
output_walk(C,"Illss",_) :- !, output_walk(C,"Illss",_) :- !,
format(C,' return walk_got_lu_block(pc->u.Illss.I, startp, endp);~n',[]). format(C,' return walk_got_lu_block(pc->y_u.Illss.I, startp, endp);~n',[]).
output_walk(C,"OtILl",_) :- !, output_walk(C,"OtILl",_) :- !,
format(C,' return walk_got_lu_block(pc->u.OtILl.block, startp, endp);~n',[]). format(C,' return walk_got_lu_block(pc->y_u.OtILl.block, startp, endp);~n',[]).
% I field gives direct access to LU index clause and to all Pred information % I field gives direct access to LU index clause and to all Pred information
output_walk(C,"L",_) :- !, output_walk(C,"L",_) :- !,
format(C,' return walk_got_lu_clause(pc->u.L.ClBase, startp, endp);~n',[]). format(C,' return walk_got_lu_clause(pc->y_u.L.ClBase, startp, endp);~n',[]).
% we cannot jump to clause code. % we cannot jump to clause code.
output_walk(C,"OtaLl",_) :- !, output_walk(C,"OtaLl",_) :- !,
format(C,' pc = pc->u.OtaLl.n;~n break;~n',[]). format(C,' pc = pc->y_u.OtaLl.n;~n break;~n',[]).
% ops which point at the clause's predicate. % ops which point at the clause's predicate.
output_walk(C,"Osblp",_) :- !, output_walk(C,"Osblp",_) :- !,
label_in_clause(C,"Osblp","p0"). label_in_clause(C,"Osblp","p0").
@ -443,23 +443,23 @@ output_ewalks(C,["trust_fail"|Ops]) :-
label_in_clause(C,Type,Field) :- label_in_clause(C,Type,Field) :-
format(C,' clause_code = TRUE;~n',[]), format(C,' clause_code = TRUE;~n',[]),
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]), format(C,' pp = pc->y_u.~s.~s;~n',[Type,Field]),
format(C,' pc = NEXTOP(pc,~s); format(C,' pc = NEXTOP(pc,~s);
break;~n',[Type]). break;~n',[Type]).
label_in_index(C,Type,Field) :- label_in_index(C,Type,Field) :-
format(C,' clause_code = FALSE;~n',[]), format(C,' clause_code = FALSE;~n',[]),
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]), format(C,' pp = pc->y_u.~s.~s;~n',[Type,Field]),
format(C,' pc = NEXTOP(pc,~s); format(C,' pc = NEXTOP(pc,~s);
break;~n',[Type]). break;~n',[Type]).
add_pi(C,Type,Field) :- add_pi(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]), format(C,' pp = pc->y_u.~s.~s;~n',[Type,Field]),
format(C,' clause_code = FALSE;~n',[]), format(C,' clause_code = FALSE;~n',[]),
format(C,' pc = NEXTOP(pc,~s);~n',[Type]). format(C,' pc = NEXTOP(pc,~s);~n',[Type]).
add_pp(C,Type,Field) :- add_pp(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]), format(C,' pp = pc->y_u.~s.~s;~n',[Type,Field]),
format(C,' if (pp->PredFlags & MegaClausePredFlag)~n',[]), format(C,' if (pp->PredFlags & MegaClausePredFlag)~n',[]),
format(C,' return found_mega_clause(pp, startp, endp);~n',[]), format(C,' return found_mega_clause(pp, startp, endp);~n',[]),
format(C,' clause_code = TRUE;~n',[]), format(C,' clause_code = TRUE;~n',[]),
@ -469,7 +469,7 @@ walk_to_meta_call(C) :-
format(C,' return found_meta_call(startp, endp);~n',[]). format(C,' return found_meta_call(startp, endp);~n',[]).
walk_to_c_code(C,Type,Field) :- walk_to_c_code(C,Type,Field) :-
format(C,' pp = pc->u.~s.~s;~n',[Type,Field]), format(C,' pp = pc->y_u.~s.~s;~n',[Type,Field]),
format(C,' return walk_found_c_pred(pp, startp, endp);~n',[]). format(C,' return walk_found_c_pred(pp, startp, endp);~n',[]).
% %
@ -500,7 +500,7 @@ dump_actions([A|Actions], Op, T, L) :-
% conditional jumps can % conditional jumps can
dump_action(body, _, _, _). dump_action(body, _, _, _).
dump_action(ifthenelse, _, T, L) :- dump_action(ifthenelse, _, T, L) :-
format(L,' if (cl->u.~s.F != FAILCODE) { format(L,' if (cl->y_u.~s.F != FAILCODE) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T]). }~n', [T]).
@ -517,22 +517,22 @@ dump_action(bind(Who,What,Extra), _, T, L) :-
handle_bind_extra(Extra, T, Command), handle_bind_extra(Extra, T, Command),
handle_constant(What, T, Constant), handle_constant(What, T, Constant),
check_atom_dbref(What, Constant, ExtraAction), check_atom_dbref(What, Constant, ExtraAction),
format(L,' if (is_regcopy(myregs, nofregs, cl->u.~s.~s)) { format(L,' if (is_regcopy(myregs, nofregs, cl->y_u.~s.~s)) {
~sclause->Tag = ~s;~s ~sclause->Tag = ~s;~s
return; return;
}~n', [T, Who, ExtraAction, Constant, Command]). }~n', [T, Who, ExtraAction, Constant, Command]).
dump_action(new(Who), _, T, L) :- dump_action(new(Who), _, T, L) :-
format(L,' if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.~s.~s))) { format(L,' if (!(nofregs = delete_regcopy(myregs, nofregs, cl->y_u.~s.~s))) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who]). }~n', [T,Who]).
dump_action(dup(Who1,Who2), _, T, L) :- dump_action(dup(Who1,Who2), _, T, L) :-
format(L,' if (!(nofregs = add_regcopy(myregs, nofregs, cl->u.~s.~s, cl->u.~s.~s))) { format(L,' if (!(nofregs = add_regcopy(myregs, nofregs, cl->y_u.~s.~s, cl->y_u.~s.~s))) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1,T,Who2]). }~n', [T,Who1,T,Who2]).
dump_action(unify(Who1,Who2), _, T, L) :- dump_action(unify(Who1,Who2), _, T, L) :-
format(L,' if (!(nofregs = link_regcopies(myregs, nofregs, cl->u.~s.~s, cl->u.~s.~s))) { format(L,' if (!(nofregs = link_regcopies(myregs, nofregs, cl->y_u.~s.~s, cl->y_u.~s.~s))) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1,T,Who2]). }~n', [T,Who1,T,Who2]).
@ -579,7 +579,7 @@ handle_bind_extra([], _, "").
handle_bind_extra(t_ptr=[], _,S) :- !, handle_bind_extra(t_ptr=[], _,S) :- !,
format_to_chars("~n clause->ucd.t_ptr = (CELL)NULL;",[],S). format_to_chars("~n clause->ucd.t_ptr = (CELL)NULL;",[],S).
handle_bind_extra(t_ptr=F, Type, S) :- handle_bind_extra(t_ptr=F, Type, S) :-
format_to_chars("~n clause->ucd.t_ptr = AbsAppl(cl->u.~s.~s);",[Type,F],S). format_to_chars("~n clause->ucd.t_ptr = AbsAppl(cl->y_u.~s.~s);",[Type,F],S).
handle_bind_extra(workpc=nextop, T,S) :- handle_bind_extra(workpc=nextop, T,S) :-
format_to_chars("~n clause->ucd.WorkPC = NEXTOP(cl,~s);",[T],S). format_to_chars("~n clause->ucd.WorkPC = NEXTOP(cl,~s);",[T],S).
handle_bind_extra(workpc=currentop, _,S) :- handle_bind_extra(workpc=currentop, _,S) :-
@ -596,7 +596,7 @@ handle_constant(What, T, Const) :-
-> ->
Const = What Const = What
; ;
format_to_chars("cl->u.~s.~s",[T,What],Const) format_to_chars("cl->y_u.~s.~s",[T,What],Const)
). ).
% %
@ -640,45 +640,45 @@ dump_head_action(bind(Who,What,Extra), _, T, L) :-
handle_constant(What, T, Constant), handle_constant(What, T, Constant),
handle_bind_extra(Extra, T, Command), handle_bind_extra(Extra, T, Command),
check_atom_dbref(What, Constant, ExtraAction), check_atom_dbref(What, Constant, ExtraAction),
format(L,' if (iarg == cl->u.~s.~s) { format(L,' if (iarg == cl->y_u.~s.~s) {
~sclause->Tag = ~s;~s ~sclause->Tag = ~s;~s
return; return;
}~n', [T,Who,ExtraAction,Constant,Command]). }~n', [T,Who,ExtraAction,Constant,Command]).
dump_head_action(new(Who), _, _, _) :- Who = [0'y|_], !. % 0'y done dump_head_action(new(Who), _, _, _) :- Who = [0'y|_], !. % 0'y done
dump_head_action(new(Who), _, T, L) :- dump_head_action(new(Who), _, T, L) :-
format(L,' if (iarg == cl->u.~s.~s) { format(L,' if (iarg == cl->y_u.~s.~s) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who]). }~n', [T,Who]).
dump_head_action(dup(Who1,Who2), _, T, L) :- Who1 = [0'y|_], !, % 0'y done dump_head_action(dup(Who1,Who2), _, T, L) :- Who1 = [0'y|_], !, % 0'y done
format(L,' if (cl->u.~s.~s == iarg) { format(L,' if (cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who2]). }~n', [T,Who2]).
dump_head_action(dup(Who1,Who2), _, T, L) :- Who2 = [0'y|_], !, % 0'y done dump_head_action(dup(Who1,Who2), _, T, L) :- Who2 = [0'y|_], !, % 0'y done
format(L,' if (cl->u.~s.~s == iarg) { format(L,' if (cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1]). }~n', [T,Who1]).
dump_head_action(dup(Who1,Who2), _, T, L) :- dump_head_action(dup(Who1,Who2), _, T, L) :-
format(L,' if (cl->u.~s.~s == iarg || format(L,' if (cl->y_u.~s.~s == iarg ||
cl->u.~s.~s == iarg) { cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1,T,Who2]). }~n', [T,Who1,T,Who2]).
dump_head_action(unify(Who1,Who2), _, T, L) :- Who1 = [0'y|_], !, % 0'y done dump_head_action(unify(Who1,Who2), _, T, L) :- Who1 = [0'y|_], !, % 0'y done
format(L,' if (cl->u.~s.~s == iarg) { format(L,' if (cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who2]). }~n', [T,Who2]).
dump_head_action(unify(Who1,Who2), _, T, L) :- Who2 = [0'y|_], !, % 0'y done dump_head_action(unify(Who1,Who2), _, T, L) :- Who2 = [0'y|_], !, % 0'y done
format(L,' if (cl->u.~s.~s == iarg) { format(L,' if (cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1]). }~n', [T,Who1]).
dump_head_action(unify(Who1,Who2), _, T, L) :- dump_head_action(unify(Who1,Who2), _, T, L) :-
format(L,' if (cl->u.~s.~s == iarg || format(L,' if (cl->y_u.~s.~s == iarg ||
cl->u.~s.~s == iarg) { cl->y_u.~s.~s == iarg) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
return; return;
}~n', [T,Who1,T,Who2]). }~n', [T,Who1,T,Who2]).
@ -882,7 +882,7 @@ opinfo("gl_void_valx",[bind("xl","AbsPair(NULL)",workpc=currentop)]).
opinfo("gl_void_valy",[bind("y","AbsPair(NULL)",workpc=currentop)]). opinfo("gl_void_valy",[bind("y","AbsPair(NULL)",workpc=currentop)]).
opinfo("gl_void_varx",[bind("xl","AbsPair(NULL)",workpc=currentop),new("xr")]). opinfo("gl_void_varx",[bind("xl","AbsPair(NULL)",workpc=currentop),new("xr")]).
opinfo("gl_void_vary",[bind("y","AbsPair(NULL)",workpc=currentop),new("y")]). opinfo("gl_void_vary",[bind("y","AbsPair(NULL)",workpc=currentop),new("y")]).
opinfo("get_struct",[bind("x","AbsAppl((CELL *)cl->u.xfa.f)",workpc=nextop)]). opinfo("get_struct",[bind("x","AbsAppl((CELL *)cl->y_u.xfa.f)",workpc=nextop)]).
opinfo("get_float",[bind("x","AbsAppl((CELL *)FunctorDouble)",t_ptr="d")]). opinfo("get_float",[bind("x","AbsAppl((CELL *)FunctorDouble)",t_ptr="d")]).
opinfo("get_longint",[bind("x","AbsAppl((CELL *)FunctorLongInt)",t_ptr="i")]). opinfo("get_longint",[bind("x","AbsAppl((CELL *)FunctorLongInt)",t_ptr="i")]).
opinfo("get_string",[bind("x","AbsAppl((CELL *)FunctorString)",t_ptr=[])]). opinfo("get_string",[bind("x","AbsAppl((CELL *)FunctorString)",t_ptr=[])]).
@ -1166,10 +1166,10 @@ output_save(S, [Name|Names], [Type|Types], Desc) :-
output_save_type(S, OpT, T-"none", Desc) :- !, output_save_type(S, OpT, T-"none", Desc) :- !,
get_op(OpT, Name), get_op(OpT, Name),
format(S, " CHECK(save_~s(stream, pc->u.~s.~s));~n", [Name, Desc, T]). format(S, " CHECK(save_~s(stream, pc->y_u.~s.~s));~n", [Name, Desc, T]).
output_save_type(S, OpT, T-Def, Desc) :- output_save_type(S, OpT, T-Def, Desc) :-
get_op(OpT, Name), get_op(OpT, Name),
format(S, "#ifdef ~s~n CHECK(save_~s(stream, pc->u.~s.~s));~n#endif~n", [Def,Name, Desc, T]). format(S, "#ifdef ~s~n CHECK(save_~s(stream, pc->y_u.~s.~s));~n#endif~n", [Def,Name, Desc, T]).

View File

@ -67,7 +67,7 @@ extern "C" {
#ifndef PL_HAVE_TERM_T #ifndef PL_HAVE_TERM_T
#define PL_HAVE_TERM_T #define PL_HAVE_TERM_T
typedef uintptr_t term_t; typedef intptr_t term_t;
#endif #endif
/******************************* /*******************************
* CONSTANTS * * CONSTANTS *
@ -373,6 +373,9 @@ PL_EXPORT(int) StryLock(IOSTREAM *s);
PL_EXPORT(int) Sunlock(IOSTREAM *s); PL_EXPORT(int) Sunlock(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions); PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions);
PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how); PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how);
#if __ANDROID__
PL_EXPORT(IOSTREAM *) Sopen_asset(char *bufp, const char *how);
#endif
PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type); PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type);
PL_EXPORT(int) Sfileno(IOSTREAM *s); PL_EXPORT(int) Sfileno(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Sopen_pipe(const char *command, const char *type); PL_EXPORT(IOSTREAM *) Sopen_pipe(const char *command, const char *type);

View File

@ -86,3 +86,5 @@ COMMON(int) PL_get_atom_ex__LD(term_t t, atom_t *a ARG_LD);
#endif #endif
COMMON(int) PL_get_module_ex(term_t name, module_t *m); COMMON(int) PL_get_module_ex(term_t name, module_t *m);
COMMON(int) PL_get_arg_ex(int n, term_t term, term_t arg); COMMON(int) PL_get_arg_ex(int n, term_t term, term_t arg);
COMMON(int) check_float(double f);

View File

@ -3247,7 +3247,17 @@ openStream(term_t file, term_t mode, term_t options)
} else } else
#endif /*HAVE_POPEN*/ #endif /*HAVE_POPEN*/
if ( PL_get_file_name(file, &path, 0) ) if ( PL_get_file_name(file, &path, 0) )
{ if ( !(s = Sopen_file(path, how)) ) {
#if __ANDROID__
if (strstr(path,"/assets/")) {
if (!(s=Sopen_asset(path+8, "r")))
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file);
return NULL;
}
} else
#endif
if ( !(s = Sopen_file(path, how)) )
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION, { PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file); ATOM_open, ATOM_source_sink, file);
return NULL; return NULL;

View File

@ -1641,6 +1641,7 @@ bool
ChDir(const char *path) ChDir(const char *path)
{ char ospath[MAXPATHLEN]; { char ospath[MAXPATHLEN];
char tmp[MAXPATHLEN]; char tmp[MAXPATHLEN];
int hyper_path = FALSE;
OsPath(path, ospath); OsPath(path, ospath);
@ -1649,8 +1650,28 @@ ChDir(const char *path)
succeed; succeed;
AbsoluteFile(path, tmp); AbsoluteFile(path, tmp);
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "ChDir %s ",osPath);
#if __ANDROID__
/* treat "/assets" as a directory (actually as a mounted file system).
*
*/
if (strstr(ospath, "/assets/") == ospath) {
extern AAssetManager *assetManager;
const char *dirName = ospath+strlen("/assets/");
AAssetManager* mgr = assetManager;
AAssetDir* dir;
if ( chdir(ospath) == 0 ) if (( dir = AAssetManager_openDir(mgr, dirName))) {
AAssetDir_close(dir);
hyper_path = TRUE;
}
hyper_path = FALSE;
} else if (!strcmp(ospath, "/assets"))
hyper_path = TRUE;
#endif
if ( hyper_path ||
chdir(ospath) == 0 )
{ size_t len; { size_t len;
len = strlen(tmp); len = strlen(tmp);

View File

@ -1413,64 +1413,89 @@ return FALSE;
static int static int
atom_to_term(term_t atom, term_t term, term_t bindings) atom_to_term(term_t atom, term_t term, term_t bindings)
{ GET_LD { GET_LD
PL_chars_t txt; PL_chars_t txt;
if ( !bindings && PL_is_variable(atom) ) /* term_to_atom(+, -) */ if ( !bindings && PL_is_variable(atom) ) /* term_to_atom(+, -) */
{ char buf[1024]; { char buf[1024];
size_t bufsize = sizeof(buf); size_t bufsize = sizeof(buf);
int rval; int rval;
char *s = buf; char *s = buf;
IOSTREAM *stream; IOSTREAM *stream;
PL_chars_t txt; PL_chars_t txt;
stream = Sopenmem(&s, &bufsize, "w"); stream = Sopenmem(&s, &bufsize, "w");
stream->encoding = ENC_UTF8; stream->encoding = ENC_UTF8;
PL_write_term(stream, term, 1200, PL_WRT_QUOTED); PL_write_term(stream, term, 1200, PL_WRT_QUOTED);
Sflush(stream); Sflush(stream);
txt.text.t = s; txt.text.t = s;
txt.length = bufsize; txt.length = bufsize;
txt.storage = PL_CHARS_HEAP; txt.storage = PL_CHARS_HEAP;
txt.encoding = ENC_UTF8; txt.encoding = ENC_UTF8;
txt.canonical = FALSE; txt.canonical = FALSE;
rval = PL_unify_text(atom, 0, &txt, PL_ATOM); rval = PL_unify_text(atom, 0, &txt, PL_ATOM);
Sclose(stream); Sclose(stream);
if ( s != buf ) if ( s != buf )
Sfree(s); Sfree(s);
return rval; return rval;
} }
if ( PL_get_text(atom, &txt, CVT_ALL|CVT_EXCEPTION) ) if ( PL_get_text(atom, &txt, CVT_ALL|CVT_EXCEPTION) )
{ GET_LD { GET_LD
read_data rd; read_data rd;
int rval; int rval;
IOSTREAM *stream; IOSTREAM *stream;
source_location oldsrc = LD->read_source; source_location oldsrc = LD->read_source;
stream = Sopen_text(&txt, "r"); stream = Sopen_text(&txt, "r");
init_read_data(&rd, stream PASS_LD);
if ( bindings && (PL_is_variable(bindings) || PL_is_list(bindings)) )
rd.varnames = bindings;
else if ( bindings )
return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_list, bindings);
if ( !(rval = read_term(term, &rd PASS_LD)) && rd.has_exception )
rval = PL_raise_exception(rd.exception);
free_read_data(&rd);
Sclose(stream);
LD->read_source = oldsrc;
// getchar();
return rval;
}
fail;
}
Term
Yap_StringToTerm(const char *s, size_t len, term_t bindings)
{ GET_LD;
read_data rd;
int rval;
IOSTREAM *stream;
source_location oldsrc = LD->read_source;
stream = Sopen_string(0, (char *)s, strlen( s ), "r");
init_read_data(&rd, stream PASS_LD); init_read_data(&rd, stream PASS_LD);
if ( bindings && (PL_is_variable(bindings) || PL_is_list(bindings)) ) rd.varnames = bindings;
rd.varnames = bindings; term_t tt = Yap_NewSlots(1 PASS_REGS);
else if ( bindings )
return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_list, bindings);
if ( !(rval = read_term(term, &rd PASS_LD)) && rd.has_exception ) if ( !(rval = read_term(tt, &rd PASS_LD)) && rd.has_exception ) {
rval = PL_raise_exception(rd.exception); rval = PL_raise_exception(rd.exception);
return 0L;
}
free_read_data(&rd); free_read_data(&rd);
Sclose(stream); Sclose(stream);
LD->read_source = oldsrc; LD->read_source = oldsrc;
// getchar(); // getchar();
return rval; return Yap_GetFromSlot( tt PASS_REGS);
} }
fail;
}
static static
PRED_IMPL("atom_to_term", 3, atom_to_term, 0) PRED_IMPL("atom_to_term", 3, atom_to_term, 0)
{ return atom_to_term(A1, A2, A3); { return atom_to_term(A1, A2, A3);

View File

@ -545,7 +545,6 @@ S__fillbuf(IOSTREAM *s)
if ( s->flags & SIO_NBUF ) if ( s->flags & SIO_NBUF )
{ char chr; { char chr;
ssize_t n; ssize_t n;
n = (*s->functions->read)(s->handle, &chr, 1); n = (*s->functions->read)(s->handle, &chr, 1);
if ( n == 1 ) if ( n == 1 )
{ c = char_to_int(chr); { c = char_to_int(chr);
@ -578,7 +577,7 @@ S__fillbuf(IOSTREAM *s)
len = s->bufsize; len = s->bufsize;
} }
n = (*s->functions->read)(s->handle, s->limitp, len); n = (*s->functions->read)(s->handle, s->limitp, len);
if ( n > 0 ) if ( n > 0 )
{ s->limitp += n; { s->limitp += n;
c = char_to_int(*s->bufp++); c = char_to_int(*s->bufp++);
@ -738,7 +737,7 @@ unget_byte(int c, IOSTREAM *s)
*--s->bufp = c; *--s->bufp = c;
if ( p ) if ( p )
{ p->charno--; /* FIXME: not correct */ { p->charno--; /* sz */
p->byteno--; p->byteno--;
if ( c == '\n' ) if ( c == '\n' )
p->lineno--; p->lineno--;
@ -785,7 +784,11 @@ reperror(int c, IOSTREAM *s)
return -1; return -1;
} }
#if __ANDROID__
//hack!!!!
char *Yap_AndroidBufp = NULL;
void( *Yap_DisplayWithJava)(int c);
#endif
static int static int
put_code(int c, IOSTREAM *s) put_code(int c, IOSTREAM *s)
@ -877,8 +880,16 @@ put_code(int c, IOSTREAM *s)
s->lastc = c; s->lastc = c;
#if __ANDROID__
if ( c == '\n' && (s->flags & SIO_LBUF) ) if (Yap_AndroidBufp && (s == Soutput || s == Serror) ) {
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "get char %c %p",c, Yap_AndroidBufp);
(Yap_DisplayWithJava)(c);
}
#endif
if ( (c == '\n' && (s->flags & SIO_LBUF) ) )
{ if ( S__flushbuf(s) < 0 ) { if ( S__flushbuf(s) < 0 )
return -1; return -1;
} }
@ -902,7 +913,6 @@ Sputcode(int c, IOSTREAM *s)
{ if ( put_code('\r', s) < 0 ) { if ( put_code('\r', s) < 0 )
return -1; return -1;
} }
return put_code(c, s); return put_code(c, s);
} }
@ -2875,7 +2885,13 @@ Sopen_file(const char *path, const char *how)
enum {lnone=0,lread,lwrite} lock = lnone; enum {lnone=0,lread,lwrite} lock = lnone;
IOSTREAM *s; IOSTREAM *s;
IOENC enc = ENC_UNKNOWN; IOENC enc = ENC_UNKNOWN;
int wait = TRUE;
#if __ANDROID__
if (strstr(path, "/assets/") == path) {
char * p = (char *)path + strlen("/assets/");
return Sopen_asset( p, how-1);
}
#endif
for( ; *how; how++) for( ; *how; how++)
{ switch(*how) { switch(*how)
@ -2887,7 +2903,7 @@ Sopen_file(const char *path, const char *how)
flags &= ~SIO_RECORDPOS; flags &= ~SIO_RECORDPOS;
break; break;
case 'L': /* lock r: read, w: write */ case 'L': /* lock r: read, w: write */
wait = FALSE; // wait = FALSE;
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 'l': /* lock r: read, w: write */ case 'l': /* lock r: read, w: write */
if ( *++how == 'r' ) if ( *++how == 'r' )
@ -3181,6 +3197,190 @@ Sopen_pipe(const char *command, const char *type)
#endif /*HAVE_POPEN*/ #endif /*HAVE_POPEN*/
#if __ANDROID__
/*******************************
* ASSET FILES *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Asset files provide a mechanism for accesing file resources stored in
an Android application pack.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static ssize_t
Swrite_asset(void *handle, char *buf, size_t size)
{
return -1L;
}
static ssize_t
Sread_asset(void *handle, char *buf, size_t size)
{
int res = AAsset_read((AAsset* )handle, (void* )buf, size);
if (res < 0) {
errno = ENOSPC; /* signal error */
}
return res;
}
static long
Sseek_asset(void *handle, long offset, int whence)
{ int res = AAsset_seek((AAsset* )handle, (off_t)offset, whence);
if (res == (off_t)-1) {
errno = ENOSPC; /* signal error */
}
return res;
}
static int64_t
Sseek64_asset(void *handle, int64_t offset, int whence)
{ off64_t res = AAsset_seek64((AAsset* )handle, (off64_t)offset, whence);
if (res == (off64_t)-1) {
errno = ENOSPC; /* signal error */
}
return res;
}
static int
Scontrol_asset(void *handle, int action, void *arg)
{ AAsset* h = (AAsset* ) handle;
off_t *rval = (off_t *)arg;
switch(action)
{
case SIO_GETSIZE:
*rval = AAsset_getLength(h);
return 0;
case SIO_GETFILENO:
{ off_t start = 0, end = AAsset_getLength(h);
int fd = AAsset_openFileDescriptor((AAsset*)handle, &start, &end);
if (fd == 0)
return -1;
*rval = fd;
return 0;
}
case SIO_SETENCODING:
case SIO_FLUSHOUTPUT:
return 0;
default:
return -1;
}
}
static int
Sclose_asset(void *handle)
{
AAsset_close((AAsset* )handle);
return 0;
}
IOFUNCTIONS Sassetfunctions =
{ Sread_asset,
Swrite_asset,
Sseek_asset,
Sclose_asset,
Scontrol_asset,
Sseek64_asset
};
#include <jni.h>
#include <string.h>
AAssetManager *assetManager;
JNIEnv *env;
void Java_org_swig_simple_SwigSimple_load(JNIEnv *env0, jobject obj, jobject mgr);
void Java_org_swig_simple_SwigSimple_load
(JNIEnv *env0, jobject obj, jobject mgr)
{
assetManager = AAssetManager_fromJava(env0, mgr);
env = env0;
if (assetManager == NULL) {
__android_log_print(ANDROID_LOG_DEBUG, "os-stream.c", "error loading asset manager");
} else {
__android_log_print(ANDROID_LOG_DEBUG, "os-stream.c", "loaded asset manager");
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sopen_asset(char **buffer, size_t *sizep, const char* mode)
Open an Android asset, essentially a read-only part of a ZIP archive.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IOSTREAM *
Sopen_asset(char *bufp, const char *how)
{
AAsset* asset;
int flags = SIO_FILE|SIO_TEXT|SIO_RECORDPOS|SIO_FBUF;
int op = *how++;
IOSTREAM *s;
IOENC enc = ENC_UNKNOWN;
AAssetManager* mgr = assetManager;
for( ; *how; how++)
{ switch(*how)
{ case 'b': /* binary */
flags &= ~SIO_TEXT;
enc = ENC_OCTET;
break;
case 'r': /* no record */
flags &= ~SIO_RECORDPOS;
break;
case 'L': /* lock r: read, w: write */
case 'l': /* lock r: read, w: write */
// read-only, nothing changes.
break;
default:
errno = EINVAL;
return NULL;
}
}
#if O_LARGEFILES && defined(O_LARGEFILE)
oflags |= O_LARGEFILE;
#endif
switch(op)
{ case 'w':
return NULL;
case 'a':
return NULL;
case 'u':
return NULL;
case 'r':
//const char *utf8 = (*env)->GetStringUTFChars(env, bufp, NULL);
asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
flags |= SIO_INPUT;
break;
default:
errno = EINVAL;
return NULL;
}
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "got asset %s -> %p", bufp, asset);\
if ( !asset )
return NULL;
s = Snew((void *)asset, flags, &Sassetfunctions);
if ( enc != ENC_UNKNOWN )
s->encoding = enc;
return s;
}
#endif /* __ANDROID__ */
/******************************* /*******************************
* MEMORY STREAMS * * MEMORY STREAMS *
*******************************/ *******************************/

@ -1 +1 @@
Subproject commit dec22cfcd9b99ffe18bb6716dcaa0761dbc29bce Subproject commit 0a9fc69fecfb78fb07b4f0a624964ae33d4e7632

View File

@ -5,7 +5,7 @@ AC_ARG_ENABLE(gecode,
[use_gecode="$enableval"], use_gecode=no) [use_gecode="$enableval"], use_gecode=no)
dnl gecode is usually in /usr/local dnl gecode is usually in /usr/local
if test -d /usr/local/include/gecode; then if test -d /usr/local/include/gecode -a x$SYSROOT = x; then
CFLAGS="$CFLAGS -I/usr/local/include" CFLAGS="$CFLAGS -I/usr/local/include"
SHLIB_CXXFLAGS="$SHLIB_CXXFLAGS -I/usr/local/include" SHLIB_CXXFLAGS="$SHLIB_CXXFLAGS -I/usr/local/include"
GECODE_EXTRALIBS="-L/usr/local/lib" GECODE_EXTRALIBS="-L/usr/local/lib"

@ -1 +1 @@
Subproject commit 90510fe601057a9122b6abeb17b716fa16a7c1aa Subproject commit 688bf6c3b2bc472ce8cb2fce58657cc38a496f07

View File

@ -15,6 +15,8 @@
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
/* Functions from B-Prolog */ /* Functions from B-Prolog */
int bpx_mount_query_term(TERM t);
/* cpred.c */ /* cpred.c */
int bp_string_2_term(const char *, TERM, TERM); int bp_string_2_term(const char *, TERM, TERM);
char* bp_term_2_string(TERM); char* bp_term_2_string(TERM);

View File

@ -220,14 +220,17 @@ write_term(TERM t)
YAP_Write(t,NULL,0); YAP_Write(t,NULL,0);
} }
static NORET quit(const char *s) INLINE_ONLY inline EXTERN NORET quit(const char *s);
INLINE_ONLY inline EXTERN NORET myquit(int i, const char *s);
INLINE_ONLY inline EXTERN NORET quit(const char *s)
{ {
fprintf(stderr,"PRISM QUIT: %s\n",s); fprintf(stderr,"PRISM QUIT: %s\n",s);
exit(0); exit(0);
} }
static NORET myquit(int i, const char *s) INLINE_ONLY inline EXTERN NORET myquit(int i, const char *s)
{ {
fprintf(stderr,"PRISM QUIT: %s\n",s); fprintf(stderr,"PRISM QUIT: %s\n",s);
exit(i); exit(i);

View File

@ -7,6 +7,11 @@
#ifndef __YAP_PROLOG__ #ifndef __YAP_PROLOG__
TERM bpx_build_atom(const char *); TERM bpx_build_atom(const char *);
#endif #endif
TERM build_runtime_error(const char *s);
TERM build_internal_error(const char *s);
void register_prism_errors(void);
void emit_error(const char *fmt, ...);
void emit_internal_error(const char *fmt, ...);
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/

View File

@ -1,5 +1,10 @@
#include <stdlib.h> #include <stdlib.h>
void bp4p_init(int *argc, char **argv[]);
void bp4p_exit(int status);
void bp4p_quit(int status);
void bp4p_register_preds(void);
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
#define REGISTER_CPRED(p,n) \ #define REGISTER_CPRED(p,n) \
@ -13,8 +18,9 @@ SYM_REC_PTR insert_cpred(const char *, int, int(*)(void));
void exit(int); void exit(int);
#ifdef __YAP_PROLOG__ #ifdef __YAP_PROLOG__
typedef int (*CPredicate)(void);
int YAP_UserCpredicate(const char *s, int (*f)(void), unsigned long int n); void
YAP_UserCPredicate(const char *name, CPredicate def, uintptr_t arity);
SYM_REC_PTR insert_cpred(const char *s, int n, int(*f)(void)) SYM_REC_PTR insert_cpred(const char *s, int n, int(*f)(void))
{ {

View File

@ -172,5 +172,5 @@ TERM unnumber_var_term(TERM term)
{ {
CACHE_REGS CACHE_REGS
BPLONG mvn = -1; BPLONG mvn = -1;
return unnumberVarTerm(term, local_top, &mvn); return unnumberVarTerm(term, (BPLONG_PTR)local_top, &mvn);
} }

View File

@ -46,6 +46,17 @@ Here is the original copyright notice.
/***********[ REDUCED VERSION OF MT19937AR.C STARTS HERE ]***********/ /***********[ REDUCED VERSION OF MT19937AR.C STARTS HERE ]***********/
void init_by_array(unsigned long init_key[], int key_length);
int pc_random_auto_seed_1(void);
int pc_random_init_by_seed_1(void);
int pc_random_init_by_list_1(void);
int pc_random_float_1(void);
int pc_random_gaussian_1(void);
int pc_random_int_2(void);
int pc_random_int_3(void);
int pc_random_get_state_1(void);
int pc_random_set_state_1(void);
/* Period parameters */ /* Period parameters */
#define N 624 #define N 624
#define M 397 #define M 397

View File

@ -81,7 +81,7 @@ static void revert_vars(void)
assert(trail_pos0 != 0); assert(trail_pos0 != 0);
trail_top0 = trail_up_addr - trail_pos0; trail_top0 = (BPLONG_PTR)(trail_up_addr - trail_pos0);
UNDO_TRAILING; UNDO_TRAILING;
trail_pos0 = 0; trail_pos0 = 0;
} }
@ -92,7 +92,6 @@ static void revert_vars(void)
*/ */
static BPULONG prism_hash_value(TERM term) static BPULONG prism_hash_value(TERM term)
{ {
CACHE_REGS
TERM t, *rest; TERM t, *rest;
BPLONG i, n; BPLONG i, n;
SYM_REC_PTR sym; SYM_REC_PTR sym;
@ -201,7 +200,7 @@ nderef_loop:
break; break;
case LST: case LST:
q = term_pool_allocate(this, 2); q = (TERM *)term_pool_allocate(this, 2);
*(q + 1) = GET_CDR(*p); *(q + 1) = GET_CDR(*p);
VECTOR_PUSH(rest, q + 1); VECTOR_PUSH(rest, q + 1);
*(q + 0) = GET_CAR(*p); *(q + 0) = GET_CAR(*p);
@ -212,7 +211,7 @@ nderef_loop:
case STR: case STR:
sym = GET_STR_SYM_REC(*p); sym = GET_STR_SYM_REC(*p);
n = GET_ARITY_STR(sym); n = GET_ARITY_STR(sym);
q = term_pool_allocate(this, n + 1); q = (TERM *)term_pool_allocate(this, n + 1);
*q = (TERM)(sym); *q = (TERM)(sym);
for (i = n; i >= 1; i--) { for (i = n; i >= 1; i--) {
*(q + i) = GET_ARG(*p, i); *(q + i) = GET_ARG(*p, i);

View File

@ -19,11 +19,22 @@ int failure_observed;
/* mic.c (B-Prolog) */ /* mic.c (B-Prolog) */
int compare(TERM,TERM); int compare(TERM,TERM);
void quit(const char *); void quit(const char *);
void alloc_occ_switches(void);
void sort_occ_switches(void);
void release_occ_switches(void);
void alloc_num_sw_vals(void);
void release_num_sw_vals(void);
void transfer_hyperparams_prolog(void);
int pc_compute_viterbi_5(void);
void release_num_sw_vals(void);
void transfer_hyperparams_prolog(void);
int pc_compute_n_viterbi_3(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* for sort_occ_switches() */ /* for sort_occ_switches() */
static int compare_sw_ins(const void *a, const void *b) static int
compare_sw_ins(const void *a, const void *b)
{ {
SW_INS_PTR sw_ins_a, sw_ins_b; SW_INS_PTR sw_ins_a, sw_ins_b;
TERM msw_a, msw_b; TERM msw_a, msw_b;

View File

@ -11,6 +11,29 @@
#include "up/em_aux.h" #include "up/em_aux.h"
#include "up/util.h" #include "up/util.h"
int check_smooth(int *smooth);
void initialize_params(void);
int compute_inside_scaling_none(void);
int compute_inside_scaling_none(void);
int compute_daem_inside_scaling_none(void);
int compute_daem_inside_scaling_log_exp(void);
int examine_inside_scaling_none(void);
int examine_inside_scaling_log_exp(void);
int compute_expectation_scaling_none(void);
int compute_expectation_scaling_log_exp(void);
double compute_daem_log_prior(void);
double compute_likelihood_scaling_none(void);
void release_num_sw_vals(void);
void transfer_hyperparams_prolog(void);
double compute_likelihood_scaling_log_exp(void);
void save_params(void);
void restore_params(void);
double compute_log_prior(void);
double compute_bic(double likelihood);
double compute_cs(double likelihood);
int update_params(void);
int update_params_smooth(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* We check if all smoothing constants are positive (MAP), /* We check if all smoothing constants are positive (MAP),

View File

@ -12,6 +12,27 @@
#include "up/flags.h" #include "up/flags.h"
#include "up/util.h" #include "up/util.h"
int check_smooth_vb(void);
int compute_daem_inside_vb_scaling_none(void);
double compute_free_energy_l0(void);
double compute_free_energy_l1_scaling_none(void);
double compute_free_energy_l1_scaling_log_exp(void);
double compute_daem_free_energy_l1_scaling_none(void);
double compute_daem_free_energy_l1_scaling_log_exp(void);
void initialize_hyperparams(void);
int update_hyperparams(void);
int update_daem_hyperparams(void);
void save_hyperparams(void);
void restore_hyperparams(void);
void transfer_hyperparams(void);
void get_param_means(void);
int compute_pi_scaling_none(void);
int compute_pi_scaling_log_exp(void);
int compute_inside_vb_scaling_none(void);
int compute_inside_vb_scaling_log_exp(void);
int compute_daem_inside_vb_scaling_log_exp(void);
double compute_daem_free_energy_l0(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Just check if there is any negative hyperparameter */ /* Just check if there is any negative hyperparameter */

View File

@ -11,6 +11,9 @@
#include "up/flags.h" #include "up/flags.h"
#include "up/util.h" #include "up/util.h"
void config_em(EM_ENG_PTR em_ptr);
int run_em(EM_ENG_PTR em_ptr);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
void config_em(EM_ENG_PTR em_ptr) void config_em(EM_ENG_PTR em_ptr)

View File

@ -22,6 +22,13 @@
/* mic.c (B-Prolog) */ /* mic.c (B-Prolog) */
NORET myquit(int, const char *); NORET myquit(int, const char *);
int pc_prism_prepare_4(void);
int pc_prism_em_6(void);
int pc_prism_vbem_2(void);
int pc_prism_both_em_2(void);
int pc_compute_inside_2(void);
int pc_compute_probf_1(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
int pc_prism_prepare_4(void) int pc_prism_prepare_4(void)

View File

@ -13,6 +13,9 @@
#include "up/flags.h" #include "up/flags.h"
#include "up/util.h" #include "up/util.h"
void config_vbem(VBEM_ENG_PTR vb_ptr);
int run_vbem(VBEM_ENG_PTR vb_ptr);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
void config_vbem(VBEM_ENG_PTR vb_ptr) void config_vbem(VBEM_ENG_PTR vb_ptr)

View File

@ -39,6 +39,28 @@ static int warn = 0;
*/ */
int debug_level = 0; int debug_level = 0;
int pc_set_daem_1(void);
int pc_set_em_message_1(void);
int pc_set_em_progress_1(void);
int pc_set_error_on_cycle_1(void);
int pc_set_explicit_empty_expls_1(void);
int pc_set_fix_init_order_1(void);
int pc_set_init_method_1(void);
int pc_set_init_method_1(void);
int pc_set_itemp_rate_1(void);
int pc_set_log_scale_1(void);
int pc_set_max_iterate_1(void);
int pc_set_num_restart_1(void);
int pc_set_num_restart_1(void);
int pc_set_show_itemp_1(void);
int pc_set_std_ratio_1(void);
int pc_set_verb_em_1(void);
int pc_set_verb_graph_1(void);
int pc_set_warn_1(void);
int pc_set_debug_level_1(void);
int pc_set_itemp_init_1(void);
int pc_set_prism_epsilon_1(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
int pc_set_daem_1(void) int pc_set_daem_1(void)

View File

@ -12,6 +12,8 @@ NORET myquit(int, const char *);
/* univ.c (B-Prolog) */ /* univ.c (B-Prolog) */
int list_length(BPLONG, BPLONG); int list_length(BPLONG, BPLONG);
int pc_import_graph_stats_4(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int max_egraph_size = INIT_MAX_EGRAPH_SIZE; static int max_egraph_size = INIT_MAX_EGRAPH_SIZE;

View File

@ -13,7 +13,13 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* mic.c (B-Prolog) */ /* mic.c (B-Prolog) */
NORET quit(const char *); extern NORET quit(const char *);
int compute_outside_scaling_none(void);
int compute_outside_scaling_log_exp(void);
int pc_compute_hindsight_4(void);
int compute_outside_scaling_none(void);
int compute_outside_scaling_log_exp(void);
int pc_compute_hindsight_4(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/

View File

@ -7,6 +7,16 @@
/* mic.c (B-Prolog) */ /* mic.c (B-Prolog) */
int compare(TERM, TERM); int compare(TERM, TERM);
int prism_printf(const char *fmt, ...);
int pc_mp_mode_0(void);
int compare_sw_ins(const void *a, const void *b);
int get_term_depth(TERM t);
int pc_get_term_depth_2(void);
int pc_lngamma_2(void);
int pc_mtrace_0(void);
int pc_muntrace_0(void);
void xsleep(unsigned int milliseconds);
int pc_sleep_1(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/

View File

@ -21,6 +21,10 @@ struct ViterbiRankEntry {
NORET quit(const char *); NORET quit(const char *);
NORET myquit(int, const char *); NORET myquit(int, const char *);
int pc_compute_n_viterbi_3(void);
int pc_compute_n_viterbi_rerank_4(void);
void transfer_hyperparams_prolog(void);
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static EG_NODE_PTR * viterbi_egraphs = NULL; static EG_NODE_PTR * viterbi_egraphs = NULL;
@ -39,6 +43,10 @@ static int n_viterbi_egraph_size;
static V_RANK_PTR viterbi_rank = NULL; static V_RANK_PTR viterbi_rank = NULL;
void compute_max(void);
void compute_n_max(int n);
int pc_compute_viterbi_5(void);
/* Viterbi works on only one explanation graph */ /* Viterbi works on only one explanation graph */
void compute_max(void) void compute_max(void)
{ {

View File

@ -27,7 +27,7 @@ install-dummy::
install-pitf: $(SOLIBS) $(addprefix $(srcdir)/, $(LIBPL)) install-examples install-pitf: $(SOLIBS) $(addprefix $(srcdir)/, $(LIBPL)) install-examples
mkdir -p $(DESTDIR)$(SOLIBDIR) mkdir -p $(DESTDIR)$(SOLIBDIR)
rm -f $(DESTDIR)$(SOLIBDIR)/python.@SO@ rm -f $(DESTDIR)$(SOLIBDIR)/python.@SO@
$(INSTALL_PROGRAM) $(SOLIBS) $(SOLIBDIR) $(INSTALL_PROGRAM) $(SOLIBS) $(DESTDIR)$(SOLIBDIR)
mkdir -p $(DESTDIR)$(PLLIBDIR) mkdir -p $(DESTDIR)$(PLLIBDIR)
for f in $(LIBPL); do \ for f in $(LIBPL); do \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(PLLIBDIR); \ $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(PLLIBDIR); \

View File

@ -1,12 +1,31 @@
# File: Android.mk # File: Android.mk
#use current directory
LOCAL_PATH := $(call my-dir) LOCAL_PATH := $(call my-dir)
NDK_TOOLCHAIN_VERSION := 4.8
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_LDLIBS += @abs_top_builddir@/libYap.a @abs_top_builddir@/yapi.o
LOCAL_LDLIBS := -landroid -llog
LOCAL_MODULE := yap0
LOCAL_SRC_FILES += @abs_top_builddir@/../../gmp/lib/libgmp.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := yap1
LOCAL_SRC_FILES += @abs_top_builddir@/libYap.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
NDK_TOOLCHAIN_VERSION := @GCC_VERSION@
LOCAL_LDLIBS := -landroid -llog
LOCAL_MODULE := example LOCAL_MODULE := example
LOCAL_SRC_FILES := yap_wrap.cpp LOCAL_SHARED_LIBRARIES := yap0 yap1
LOCAL_C_INCLUDES := @abs_top_builddir@ @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX LOCAL_STATIC_LIBRARIES := @abs_top_builddir@/libYap.ar
LOCAL_CFLAGS := @DEFS@ -D_YAP_NOT_INSTALLED_=1 LOCAL_SRC_FILES += @abs_top_builddir@/packages/swig/android/jni/yap_wrap.cpp
LOCAL_C_INCLUDES := @abs_top_builddir@ @abs_top_builddir@/../../gmp/include @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX
LOCAL_CFLAGS := @YAP_EXTRAS@ @DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"\"
LOCAL_CPP_FEATURES := rtti LOCAL_CPP_FEATURES := rtti
# LOCAL_ALLOW_UNDEFINED_SYMBOLS := true # LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@ -8,10 +8,10 @@ include ../Makefile.defs
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"$(DESTDIR)\" DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"$(DESTDIR)\"
YAP_EXTRAS=@YAP_EXTRAS@ YAP_EXTRAS=@YAP_EXTRAS@
srcdir=@srcdir@ srcdir=@srcdir@
CPPFLAGS=@CPPFLAGS@ -I../.. -I$(srcdir)/../../H -I$(srcdir)/../../include -I$(srcdir)/../../os -I$(srcdir)/../../OPTYap -I$(srcdir)/../../BEAM -I$(srcdir)/../../CXX CPPFLAGS= -I../.. -I$(srcdir)/../../H -I$(srcdir)/../../include -I$(srcdir)/../../os -I$(srcdir)/../../OPTYap -I$(srcdir)/../../BEAM -I$(srcdir)/../../CXX
CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) CXXFLAGS= $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
PROGRAMS= \ PROGRAMS= $(srcdir)/python/demo.py \
SWIG_FILES= \ SWIG_FILES= \
$(srcdir)/yap.i $(srcdir)/yap.i
@ -19,12 +19,14 @@ SWIG_FILES= \
all: python java R all: python java R
python: $(SWIG_FILES) python/_yap.so python/yap.py python: $(SWIG_FILES) python/_yap.so python/yap.py
cp $(srcdir)/python/demo.py python
python/_yap.so: python/yap_wrap.o python/_yap.so: python/yap_wrap.o
$(CXX) -shared $(LDSOFLAGS) -o python/_yap.so python/yap_wrap.o ../../yapi.o $(LIBS) @PYTHON_LIBS@ -L ../.. -lYap -lpthread $(CXX) -shared $(LDSOFLAGS) -o python/_yap.so python/yap_wrap.o ../../yapi.o $(LIBS) @PYTHON_LIBS@ -L ../.. -lYap -lpthread
python/yap_wrap.c: $(srcdir)/yap.i python/yap_wrap.c: $(srcdir)/yap.i
$(SWIG) -c++ -python -outdir python -o $@ $(DEFS) $(CPPFLAGS) -Wall $< mkdir -p python
$(SWIG) -c++ -python -outdir python -o $@ $(CXXFLAGS) -Wall $<
python/yap_wrap.o: python/yap_wrap.c python/yap_wrap.o: python/yap_wrap.c
$(CXX) -c $(CXXFLAGS) @PYTHON_INCLUDES@ $< -o $@ $(CXX) -c $(CXXFLAGS) @PYTHON_INCLUDES@ $< -o $@
@ -33,22 +35,34 @@ java: jni/libyap.@SO@ java/yap.java
cd java ; $(JAVAC) *.java; $(JAR) cvf yap.jar *.class cd java ; $(JAVAC) *.java; $(JAR) cvf yap.jar *.class
jni/libyap.@SO@: jni/yap_wrap.o jni/libyap.@SO@: jni/yap_wrap.o
$(CXX) -shared $(LDSOFLAGS) -L ../.. -lYap -o $@ ../../yapi.o $< $(LIBS) @JPLLDFLAGS@ -L ../.. -lYap -lpthread $(CXX) -shared $(LDSOFLAGS) -o $@ ../../yapi.o $< $(LIBS) @JPLLDFLAGS@ -L ../.. -lYap -lpthread
jni/yap_wrap.cpp: $(srcdir)/yap.i jni/yap_wrap.cpp: $(srcdir)/yap.i
$(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o $@ $(DEFS) $(CPPFLAGS) -Wall $< $(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o $@ $(CXXFLAGS) -Wall $<
jni/yap_wrap.o: jni/yap_wrap.cpp jni/yap_wrap.o: jni/yap_wrap.cpp
$(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@ $(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@
# depends on make install on top-level
# also, should have an android device running, say
# emulator -avd first &
#
# adb uninstall org.swig.simple ( if not the first time )
# adb install bin/SwigSimple-debug.apk
#
#
android: android/jni/yap_wrap.cpp android: android/jni/yap_wrap.cpp
android/jni/yap_wrap.cpp: $(srcdir)/yap.i android/jni/yap_wrap.cpp: $(srcdir)/yap.i
android create project --target 1 --name SwigSimple --path ./android --activity SwigSimple --package org.swig.simple android create project --target 1 --name SwigSimple --path ./android --activity SwigSimple --package org.swig.simple;\
( cd android ; mkdir -p jni;\ ( cd android ; mkdir -p jni jni/lib; mkdir -p assets/share/Yap; mkdir -p assets/lib/Yap;\
$(SWIG) -c++ -java -I$(srcdir)/../../CXX -package org.swig.simple -outdir src/org/swig/simple -o jni/yap_wrap.cpp $< ;\ $(SWIG) -c++ -java -I$(srcdir)/../../CXX -package org.swig.simple -outdir src/org/swig/simple -o jni/yap_wrap.cpp $(CXXFLAGS) $< ;\
cp $(srcdir)/android/SwigSimple.java src/org/swig/simple/ ;\ cp $(srcdir)/android/SwigSimple.java src/org/swig/simple/ ;\
cp $(srcdir)/android/main.xml res/layout ;\ cp $(srcdir)/android/main.xml res/layout ;\
cp $(srcdir)/android/Application.mk jni ;\
cp -r $(DESTDIR)$(PLLIBDIR)/* assets/share/Yap;\
cp -r ../../../startup.yss assets/lib/Yap;\
cp -r $(DESTDIR)$(SOLIBDIR)/*.so jni;\
cp ../Android.mk jni ;\ cp ../Android.mk jni ;\
ndk-build; \ ndk-build; \
ant debug \ ant debug \
@ -63,7 +77,7 @@ install:
clean: clean:
rm -f */* rm -fr android/* jni/* java/* python/*
distclean: clean distclean: clean
rm -f *def Makefile rm -f *def Makefile

View File

@ -1,2 +1,4 @@
# File: Application.mk # File: Application.mk
NDK_TOOLCHAIN_VERSION = 4.8 NDK_TOOLCHAIN_VERSION = 4.8
APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions

View File

@ -6,50 +6,189 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
import android.content.res.AssetManager;
import android.widget.EditText;
public class SwigSimple extends Activity public class SwigSimple extends Activity
{ {
TextView outputText = null; TextView outputText = null;
ScrollView scroller = null; ScrollView scroller = null;
YAPEngine eng = null;
EditText text;
String str;
String buf;
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle savedInstanceState) public void onCreate(Bundle savedInstanceState)
{ {
super.onCreate(savedInstanceState); String s = null;
setContentView(R.layout.main); super.onCreate(savedInstanceState);
setContentView(R.layout.main);
outputText = (TextView)findViewById(R.id.OutputText); try {
outputText.setText("Press 'Run' to start...\n"); PackageManager m = getPackageManager();
outputText.setMovementMethod(new ScrollingMovementMethod()); s = getPackageName();
PackageInfo p = m.getPackageInfo(s, 0);
//s = p.applicationInfo.dataDir;
AssetManager mgr = getResources().getAssets();
load(mgr);
} catch(NameNotFoundException e) {
Log.e(TAG, "Couldn't find package information in PackageManager", e);
}
Log.i(TAG, "mgr=" +mgr);
scroller = (ScrollView)findViewById(R.id.Scroller); text = (EditText)findViewById(R.id.EditText01);
} outputText = (TextView)findViewById(R.id.OutputText);
outputText.setText("Application " + s + "\nPress 'Run' to start...\n");
outputText.setMovementMethod(new ScrollingMovementMethod());
scroller = (ScrollView)findViewById(R.id.Scroller);
eng = new YAPEngine( );
Log.i(TAG, "engine done");
JavaCallback callback = new JavaCallback( outputText );
// set the Java Callback
eng.setYAPCallback(callback);
if (BuildConfig.DEBUG) {
Log.i(TAG, "callback done");
}
}
public void onRunButtonClick(View view) public void onResetButtonClick(View view)
{ {
outputText.append("Started...\n"); if (BuildConfig.DEBUG) {
nativeCall(); Log.i(TAG, "onReseButtonClick called");
outputText.append("Finished!\n"); }
// Ensure scroll to end of text
scroller.post(new Runnable() {
public void run() {
scroller.fullScroll(ScrollView.FOCUS_DOWN);
text.setText("");
}
});
}
public void onRunButtonClick(View view)
{
if (BuildConfig.DEBUG) {
Log.i(TAG, "onRunButtonClick called");
}
// Ensure scroll to end of text
scroller.post(new Runnable() {
public void run() {
scroller.fullScroll(ScrollView.FOCUS_DOWN);
str = text.getText().toString();
outputText.append("?- " + str);
YAPQuery q = eng.query( str );
YAPListTerm vs = q.namedVars();
// text.setText("");
if (vs.nil()) {
if (q.next()) {
outputText.append( "yes\n" );
} else {
outputText.append( "no\n" );
}
} else {
while (q.next()) {
int i=1;
// outputText.append(Integer.toString(i++) + ": " + vs.text() +"\n");
while(!vs.nil()){
YAPTerm eq = vs.car();
//outputText.append(Integer.toString(i) + ": " + eq.text() );
outputText.append(Integer.toString(i++) + ":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
vs = vs.cdr();
}
}
}
q.close();
}
});
}
// Ensure scroll to end of text public void onRunSelectionButtonClick(View view)
scroller.post(new Runnable() { {
public void run() { if (BuildConfig.DEBUG) {
scroller.fullScroll(ScrollView.FOCUS_DOWN); Log.i(TAG, "onRunButtonClick called");
} }
}); // Ensure scroll to end of text
} scroller.post(new Runnable() {
public void run() {
scroller.fullScroll(ScrollView.FOCUS_DOWN);
int startSelection = text.getSelectionStart();
int endSelection = text.getSelectionEnd();
str = text.getText().toString().substring( startSelection, endSelection );
outputText.append("?- " + str);
YAPQuery q = eng.query( str );
YAPListTerm vs = q.namedVars();
// text.setText("");
if (vs.nil()) {
if (q.next()) {
outputText.append( "yes\n" );
} else {
outputText.append( "no\n" );
}
} else {
while (q.next()) {
int i=1;
// outputText.append(Integer.toString(i++) + ": " + vs.text() +"\n");
while(!vs.nil()){
YAPTerm eq = vs.car();
//outputText.append(Integer.toString(i) + ": " + eq.text() );
outputText.append(Integer.toString(i++) + ":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
vs = vs.cdr();
}
}
}
q.close();
}
});
}
/** Calls into C/C++ code */
public void nativeCall()
{
// YAPParams p = new YAPParams();
//YAPEngine t = new YAPEngine( p ); // TODO
}
/** static constructor */ /** static constructor */
static { static {
System.loadLibrary("example"); System.loadLibrary("android");
} System.loadLibrary("log");
System.loadLibrary("gmp");
System.loadLibrary("example");
}
private static native void load(AssetManager mgr);
private AssetManager mgr;
private static final String TAG = "SwigSimple";
}
class JavaCallback extends YAPCallback
{
TextView output;
public JavaCallback( TextView outputText )
{
super();
output = outputText;
Log.i(TAG, "java callback init");
}
public void run()
{
System.out.println("JavaCallback.run() ");
Log.i(TAG, "java callback ");
}
public void displayInWindow(String s)
{
System.out.println("JavaCallback.run() ");
Log.i(TAG, "java callback ");
output.append(s);
}
private static final String TAG = "JavaCallback";
} }

View File

@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent"
> android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:lines="6" />
<Button <Button
android:id="@+id/RunButton" android:id="@+id/RunButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -11,16 +21,32 @@
android:text="Run..." android:text="Run..."
android:onClick="onRunButtonClick" android:onClick="onRunButtonClick"
/> />
<Button
android:id="@+id/RunSelectionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select"
android:onClick="onRunSelectionButtonClick"
/>
<Button
android:id="@+id/ClearButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:onClick="onClearButtonClick"
/>
</LinearLayout>
<ScrollView <ScrollView
android:id="@+id/Scroller" android:id="@+id/Scroller"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent">
> <TextView
<TextView
android:id="@+id/OutputText" android:id="@+id/OutputText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />
<!-- Set MaxLegth EditText -->
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,19 @@
# python commands
import sys
import yap
engine = yap.YAPEngine();
# engine = yap.YAPEngine(yap.YAPParams());
def go():
while True:
s = raw_input("Prolog Query: ")
q = engine.query(s)
while q.next():
vs = q.namedVars();
while vs.length() > 0:
eq = vs.car()
print eq.getArg(1).text() + " = " + eq.getArg(2).text()
vs = vs.cdr()
print "no more answers"

View File

@ -1,12 +1,31 @@
/* example.i */ /* example.i */
%module yap %module(directors="1") yap
%{ %{
/* Put header files here or function declarations like below */ /* Put header files here or function declarations like below */
#define YAP_CPP_INTERFACE 1
extern "C" {
#include "yapi.hh" #include "yapi.hh"
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
#if THREADS
#define Yap_regp regcache
#endif
// we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't
}
%} %}
/* turn on director wrapping Callback */
%feature("director") YAPCallback;
%include "yapi.hh" %include "yapi.hh"

Some files were not shown because too many files have changed in this diff Show More