fix integer as DBRef
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@971 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
0df93ffc6e
commit
cfd3683891
19
C/absmi.c
19
C/absmi.c
@ -1086,6 +1086,19 @@ Yap_absmi(int inp)
|
||||
GONext();
|
||||
ENDOp();
|
||||
|
||||
/* only meaningful with THREADS on! */
|
||||
/* lock logical updates predicate. */
|
||||
Op(unlock_lu, e);
|
||||
PREG = NEXTOP(PREG, e);
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (PP) {
|
||||
READ_UNLOCK(PP->PRWLock);
|
||||
PP = NULL;
|
||||
}
|
||||
#endif
|
||||
GONext();
|
||||
ENDOp();
|
||||
|
||||
|
||||
/* enter logical pred */
|
||||
BOp(stale_lu_index, Ill);
|
||||
@ -2552,12 +2565,6 @@ Yap_absmi(int inp)
|
||||
E_YREG = ENV;
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = E_YREG[E_DEPTH];
|
||||
#endif
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (PP) {
|
||||
READ_UNLOCK(PP->PRWLock);
|
||||
PP = NULL;
|
||||
}
|
||||
#endif
|
||||
WRITEBACK_Y_AS_ENV();
|
||||
JMPNext();
|
||||
|
17
C/amasm.c
17
C/amasm.c
@ -2430,6 +2430,12 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
*clause_has_blobsp &&
|
||||
!clinfo.alloc_found)
|
||||
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
||||
#if THREADS
|
||||
else
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_e(_procceed, code_p, pass_no);
|
||||
#ifdef YAPOR
|
||||
if (pass_no)
|
||||
@ -2530,12 +2536,23 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
*clause_has_blobsp &&
|
||||
!clinfo.alloc_found)
|
||||
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
|
||||
#if THREADS
|
||||
else
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_e(_procceed, code_p, pass_no);
|
||||
break;
|
||||
case call_op:
|
||||
code_p = a_p(_call, &clinfo, code_p, pass_no, cip);
|
||||
break;
|
||||
case execute_op:
|
||||
#if THREADS
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_p(_execute, &clinfo, code_p, pass_no, cip);
|
||||
break;
|
||||
case safe_call_op:
|
||||
|
@ -648,6 +648,7 @@ void Yap_InitAttVarPreds(void)
|
||||
attas[attvars_ext].to_term_op = AttVarToTerm;
|
||||
attas[attvars_ext].term_to_op = TermToAttVar;
|
||||
attas[attvars_ext].mark_op = mark_attvar;
|
||||
CurrentModule = ATTRIBUTES_MODULE;
|
||||
Yap_InitCPred("get_att", 3, p_get_att, SafePredFlag);
|
||||
Yap_InitCPred("get_all_atts", 2, p_get_all_atts, SafePredFlag);
|
||||
Yap_InitCPred("free_att", 2, p_free_att, SafePredFlag);
|
||||
@ -657,6 +658,7 @@ void Yap_InitAttVarPreds(void)
|
||||
Yap_InitCPred("n_of_atts", 1, p_n_atts, SafePredFlag);
|
||||
Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag);
|
||||
Yap_InitCPred("all_attvars", 1, p_all_attvars, SafePredFlag);
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
Yap_InitCPred("$is_att_variable", 1, p_is_attvar, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag);
|
||||
}
|
||||
|
@ -276,6 +276,10 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code
|
||||
/* just skip for now, but should worry about locking */
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
case _unlock_lu:
|
||||
/* just skip for now, but should worry about locking */
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
case _retry_profiled:
|
||||
case _count_retry:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
|
30
C/dbase.c
30
C/dbase.c
@ -3309,10 +3309,17 @@ p_recorded(void)
|
||||
PredEntry *pe;
|
||||
|
||||
if (!IsVarTerm(t3)) {
|
||||
if (!IsDBRefTerm(t3)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
DBRef ref = DBRefOfTerm(t3);
|
||||
if (!IsDBRefTerm(t3)) {
|
||||
if (IsIntegerTerm(t3)) {
|
||||
ref = (DBRef)IntegerOfTerm(t3);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
ref = DBRefOfTerm(t3);
|
||||
}
|
||||
ref = DBRefOfTerm(t3);
|
||||
if (ref == NULL) return FALSE;
|
||||
if (DEAD_REF(ref)) {
|
||||
return FALSE;
|
||||
@ -3336,7 +3343,6 @@ p_recorded(void)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((pe = find_lu_entry(twork)) != NULL) {
|
||||
return lu_recorded(pe);
|
||||
}
|
||||
@ -4130,9 +4136,14 @@ p_erase(void)
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsDBRefTerm(t1)) {
|
||||
if (IsIntegerTerm(t1)) {
|
||||
EraseEntry((DBRef)IntegerOfTerm(t1));
|
||||
return TRUE;
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_DBREF, t1, "erase");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
EraseEntry(DBRefOfTerm(t1));
|
||||
return (TRUE);
|
||||
}
|
||||
@ -4148,17 +4159,22 @@ p_erase_clause(void)
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsDBRefTerm(t1)) {
|
||||
if (IsIntegerTerm(t1)) {
|
||||
entryref = (DBRef)IntegerOfTerm(t1);
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_DBREF, t1, "erase");
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
entryref = DBRefOfTerm(t1);
|
||||
}
|
||||
if (entryref->Flags & StaticMask) {
|
||||
if (entryref->Flags & ErasedMask)
|
||||
return FALSE;
|
||||
Yap_EraseStaticClause((StaticClause *)entryref, Yap_LookupModule(Deref(ARG2)));
|
||||
return TRUE;
|
||||
}
|
||||
EraseEntry(DBRefOfTerm(t1));
|
||||
EraseEntry(entryref);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -4243,9 +4259,13 @@ p_erased(void)
|
||||
return (FALSE);
|
||||
}
|
||||
if (!IsDBRefTerm(t)) {
|
||||
if (IsIntegerTerm(t)) {
|
||||
return (((DBRef)IntegerOfTerm(t))->Flags & ErasedMask);
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_DBREF, t, "erased");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
return (DBRefOfTerm(t)->Flags & ErasedMask);
|
||||
}
|
||||
|
||||
|
13
C/index.c
13
C/index.c
@ -1582,6 +1582,7 @@ add_info(ClauseDef *clause, UInt regno)
|
||||
case _jump_if_var:
|
||||
case _try_in:
|
||||
case _lock_lu:
|
||||
case _unlock_lu:
|
||||
clause->Tag = (CELL)NULL;
|
||||
return;
|
||||
case _jump_if_nonvar:
|
||||
@ -3822,6 +3823,9 @@ expand_index(struct intermediates *cint) {
|
||||
case _lock_lu:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
case _unlock_lu:
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
case _jump_if_var:
|
||||
if (IsVarTerm(Deref(ARG1))) {
|
||||
labp = &(ipc->u.l.l);
|
||||
@ -5531,6 +5535,9 @@ add_to_index(struct intermediates *cint, int first, path_stack_entry *sp, Clause
|
||||
case _lock_lu:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
case _unlock_lu:
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
default:
|
||||
sp = kill_unsafe_block(sp, op, ap);
|
||||
ipc = pop_path(&sp, cls, ap);
|
||||
@ -6034,6 +6041,9 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
|
||||
case _lock_lu:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
case _unlock_lu:
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
default:
|
||||
if (IN_BETWEEN(bg,ipc,lt)) {
|
||||
sp = kill_unsafe_block(sp, op, ap);
|
||||
@ -6543,6 +6553,9 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
||||
case _lock_lu:
|
||||
ipc = NEXTOP(ipc,p);
|
||||
break;
|
||||
case _unlock_lu:
|
||||
ipc = NEXTOP(ipc,e);
|
||||
break;
|
||||
#if THREADS
|
||||
case _thread_local:
|
||||
break;
|
||||
|
2
C/init.c
2
C/init.c
@ -839,8 +839,6 @@ InitCodes(void)
|
||||
don't initialise this here, this is initialised by Yap_InitModules!!!!
|
||||
heap_regs->no_of_modules = 1;
|
||||
*/
|
||||
heap_regs->primitives_module = 0;
|
||||
heap_regs->user_module = 1;
|
||||
heap_regs->atom_abol = Yap_FullLookupAtom("$abol");
|
||||
AtomAltNot = Yap_LookupAtom("not");
|
||||
heap_regs->atom_append = Yap_LookupAtom ("append");
|
||||
|
56
C/iopreds.c
56
C/iopreds.c
@ -3789,7 +3789,7 @@ format(Term tail, Term args, int sno)
|
||||
{
|
||||
if (format_buf_size == -1) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
ch = IntOfTerm (head);
|
||||
if (ch == '~')
|
||||
@ -3801,22 +3801,22 @@ format(Term tail, Term args, int sno)
|
||||
if (IsVarTerm (tail = Deref (tail)) ) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (tail)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
head = HeadOfTerm (tail);
|
||||
tail = TailOfTerm (tail);
|
||||
if (IsVarTerm (head)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if ( !IsIntTerm (head)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_INTEGER,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else
|
||||
ch = IntOfTerm (head);
|
||||
if (ch == '*')
|
||||
@ -3825,27 +3825,27 @@ format(Term tail, Term args, int sno)
|
||||
arg_size = GetArgSizeFromThirdArg (&ptr, &args);
|
||||
if (format_error) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm (tail = Deref (tail)) ) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (tail)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
head = HeadOfTerm (tail);
|
||||
tail = TailOfTerm (tail);
|
||||
if (IsVarTerm (head)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if ( !IsIntTerm (head)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_INTEGER,tail,"format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else
|
||||
ch = IntOfTerm (head);
|
||||
}
|
||||
@ -3856,7 +3856,7 @@ format(Term tail, Term args, int sno)
|
||||
ch = GetArgSizeFromChars (&ptr, &arg_size, &tail);
|
||||
if (format_error) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (ch == '`')
|
||||
@ -3865,7 +3865,7 @@ format(Term tail, Term args, int sno)
|
||||
arg_size = GetArgSizeFromChar(&tail);
|
||||
if (format_error) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
ch = 't';
|
||||
}
|
||||
@ -3874,27 +3874,27 @@ format(Term tail, Term args, int sno)
|
||||
case 'a':
|
||||
if (size_args) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
return (FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
if (IsVarTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,args,"~a format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,args,"~a format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
arghd = HeadOfTerm (args);
|
||||
args = TailOfTerm (args);
|
||||
if (IsVarTerm (arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,arghd,"~a in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsAtomTerm (arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_ATOM,arghd,"~a in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
Yap_plwrite (arghd, format_putc, Handle_vars_f|To_heap_f);
|
||||
break;
|
||||
@ -3902,22 +3902,22 @@ format(Term tail, Term args, int sno)
|
||||
if (IsVarTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,args,"~c in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,args,"~c in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
arghd = HeadOfTerm (args);
|
||||
args = TailOfTerm (args);
|
||||
if (IsVarTerm (arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,arghd,"~c in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsIntTerm (arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_ATOM,arghd,"~a in format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else int2= IntOfTerm(arghd);
|
||||
if (!size_args)
|
||||
arg_size = 1;
|
||||
@ -3932,11 +3932,11 @@ format(Term tail, Term args, int sno)
|
||||
if (IsVarTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,args,"~%d in format/2", ch);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,args,"~%d in format/2", ch);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
if (arg_size == 0 || arg_size > 6)
|
||||
arg_size = 6;
|
||||
@ -3949,11 +3949,11 @@ format(Term tail, Term args, int sno)
|
||||
if (IsVarTerm(arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,arghd,"~%c in format/2", ch);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsNumTerm (arghd)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_FLOAT,arghd,"~%c in format/2", ch);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
if (IsIntegerTerm(arghd)) {
|
||||
float_tmp = IntegerOfTerm(arghd);
|
||||
@ -3973,7 +3973,7 @@ format(Term tail, Term args, int sno)
|
||||
if (IsVarTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(INSTANTIATION_ERROR,args,"~d format/2");
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
} else if (!IsPairTerm (args)) {
|
||||
Yap_FreeAtomSpace(format_base);
|
||||
Yap_Error(TYPE_ERROR_LIST,args,"~d format/2");
|
||||
@ -5031,7 +5031,6 @@ Yap_InitIOPreds(void)
|
||||
Yap_InitCPred ("$check_stream", 1, p_check_if_stream, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$stream_flags", 2, p_stream_flags, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$close", 1, p_close, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("peek_mem_write_stream", 3, p_peek_mem_write_stream, SyncPredFlag);
|
||||
Yap_InitCPred ("flush_output", 1, p_flush, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$flush_all_streams", 0, p_flush_all_streams, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$get", 2, p_get, SafePredFlag|SyncPredFlag);
|
||||
@ -5042,8 +5041,11 @@ Yap_InitIOPreds(void)
|
||||
Yap_InitCPred ("$file_expansion", 2, p_file_expansion, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$open_null_stream", 1, p_open_null_stream, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$open_pipe_stream", 2, p_open_pipe_stream, SafePredFlag|SyncPredFlag);
|
||||
CurrentModule = CHARSIO_MODULE;
|
||||
Yap_InitCPred ("open_mem_read_stream", 2, p_open_mem_read_stream, SyncPredFlag);
|
||||
Yap_InitCPred ("open_mem_write_stream", 1, p_open_mem_write_stream, SyncPredFlag);
|
||||
Yap_InitCPred ("peek_mem_write_stream", 3, p_peek_mem_write_stream, SyncPredFlag);
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
Yap_InitCPred ("$put", 2, p_put, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$put_byte", 2, p_put_byte, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag);
|
||||
|
14
C/modules.c
14
C/modules.c
@ -148,12 +148,18 @@ Yap_InitModulesC(void)
|
||||
void
|
||||
Yap_InitModules(void)
|
||||
{
|
||||
ModuleName[PrimitivesModule = 0] =
|
||||
ModuleName[PROLOG_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("prolog"));
|
||||
ModuleName[1] =
|
||||
ModuleName[USER_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("user"));
|
||||
ModuleName[2] =
|
||||
ModuleName[IDB_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("idb"));
|
||||
NoOfModules = 3;
|
||||
ModuleName[ATTRIBUTES_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("attributes"));
|
||||
ModuleName[CHARSIO_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("charsio"));
|
||||
ModuleName[TERMS_MODULE] =
|
||||
MkAtomTerm(Yap_LookupAtom("terms"));
|
||||
NoOfModules = 6;
|
||||
CurrentModule = 0;
|
||||
}
|
||||
|
@ -616,8 +616,10 @@ void
|
||||
Yap_InitUnify(void)
|
||||
{
|
||||
Yap_InitCPred("unify_with_occurs_check", 2, p_ocunify, SafePredFlag);
|
||||
CurrentModule = TERMS_MODULE;
|
||||
Yap_InitCPred("cyclic_term", 1, p_cyclic, SafePredFlag|TestPredFlag);
|
||||
Yap_InitCPred("acyclic_term", 1, p_acyclic, SafePredFlag|TestPredFlag);
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ typedef struct {
|
||||
|
||||
|
||||
STATIC_PROTO(int copy_complex_term, (CELL *, CELL *, CELL *, CELL *));
|
||||
STATIC_PROTO(CELL vars_in_complex_term, (CELL *, CELL *));
|
||||
STATIC_PROTO(CELL vars_in_complex_term, (CELL *, CELL *, Term));
|
||||
STATIC_PROTO(Int p_non_singletons_in_term, (void));
|
||||
STATIC_PROTO(CELL non_singletons_in_complex_term, (CELL *, CELL *));
|
||||
STATIC_PROTO(Int p_variables_in_term, (void));
|
||||
@ -678,7 +678,7 @@ p_copy_term_no_delays(void) /* copy term t to a new instance */
|
||||
}
|
||||
|
||||
|
||||
static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Term inp)
|
||||
{
|
||||
|
||||
register CELL **to_visit0, **to_visit = (CELL **)Yap_PreAllocCodeSpace();
|
||||
@ -774,7 +774,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
|
||||
if (H != InitialH) {
|
||||
/* close the list */
|
||||
Term t2 = Deref(ARG2);
|
||||
Term t2 = Deref(inp);
|
||||
if (IsVarTerm(t2)) {
|
||||
RESET_VARIABLE(H-1);
|
||||
Yap_unify((CELL)(H-1),ARG2);
|
||||
@ -783,7 +783,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
}
|
||||
return(output);
|
||||
} else {
|
||||
return(ARG2);
|
||||
return(inp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -804,17 +804,40 @@ p_variables_in_term(void) /* variables in term t */
|
||||
out = ARG2;
|
||||
else if (IsPairTerm(t)) {
|
||||
out = vars_in_complex_term(RepPair(t)-1,
|
||||
RepPair(t)+1);
|
||||
RepPair(t)+1, ARG2);
|
||||
}
|
||||
else {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
out = vars_in_complex_term(RepAppl(t),
|
||||
RepAppl(t)+
|
||||
ArityOfFunctor(f));
|
||||
ArityOfFunctor(f), ARG2);
|
||||
}
|
||||
return(Yap_unify(ARG3,out));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_term_variables(void) /* variables in term t */
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
Term out;
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
return Yap_unify(MkPairTerm(t,TermNil), ARG2);
|
||||
} else if (IsPrimitiveTerm(t)) {
|
||||
return Yap_unify(TermNil, ARG2);
|
||||
} else if (IsPairTerm(t)) {
|
||||
out = vars_in_complex_term(RepPair(t)-1,
|
||||
RepPair(t)+1, TermNil);
|
||||
}
|
||||
else {
|
||||
Functor f = FunctorOfTerm(t);
|
||||
out = vars_in_complex_term(RepAppl(t),
|
||||
RepAppl(t)+
|
||||
ArityOfFunctor(f), TermNil);
|
||||
}
|
||||
return Yap_unify(ARG2,out);
|
||||
}
|
||||
|
||||
static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt0_end)
|
||||
{
|
||||
|
||||
@ -1708,11 +1731,14 @@ void Yap_InitUtilCPreds(void)
|
||||
Yap_InitCPred("$copy_term_but_not_constraints", 2, p_copy_term_no_delays, 0);
|
||||
Yap_InitCPred("ground", 1, p_ground, SafePredFlag);
|
||||
Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, SafePredFlag);
|
||||
Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag);
|
||||
Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, SafePredFlag);
|
||||
CurrentModule = TERMS_MODULE;
|
||||
Yap_InitCPred("term_variables", 2, p_term_variables, SafePredFlag);
|
||||
Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag);
|
||||
Yap_InitCPred("term_hash", 4, GvNTermHash, SafePredFlag);
|
||||
Yap_InitCPred("variant", 2, p_variant, SafePredFlag);
|
||||
Yap_InitCPred("subsumes", 2, p_subsumes, SafePredFlag);
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
#ifdef DEBUG
|
||||
Yap_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag);
|
||||
Yap_InitCPred("dum", 1, camacho_dum, SafePredFlag);
|
||||
|
6
H/Heap.h
6
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* comments: Heap Init Structure *
|
||||
* version: $Id: Heap.h,v 1.52 2004-02-05 16:57:00 vsc Exp $ *
|
||||
* version: $Id: Heap.h,v 1.53 2004-02-09 14:19:04 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* information that can be stored in Code Space */
|
||||
@ -200,8 +200,6 @@ typedef struct various_codes {
|
||||
struct pred_entry *module_pred[MaxModules];
|
||||
SMALLUNSGN no_of_modules;
|
||||
struct dead_clause *dead_clauses;
|
||||
int primitives_module;
|
||||
int user_module;
|
||||
Atom
|
||||
atom_abol,
|
||||
atom_alarm,
|
||||
@ -453,8 +451,6 @@ struct various_codes *heap_regs;
|
||||
#define CharConversionTable2 heap_regs->char_conversion_table2
|
||||
#define ModuleName heap_regs->module_name
|
||||
#define ModulePred heap_regs->module_pred
|
||||
#define PrimitivesModule heap_regs->primitives_module
|
||||
#define UserModule heap_regs->user_module
|
||||
#define NoOfModules heap_regs->no_of_modules
|
||||
#define AtomAbol heap_regs->atom_abol
|
||||
#define AtomAlarm heap_regs->atom_alarm
|
||||
|
@ -256,6 +256,7 @@
|
||||
OPCODE(count_trust_me ,ld),
|
||||
OPCODE(count_retry_and_mark ,ld),
|
||||
OPCODE(lock_lu ,p),
|
||||
OPCODE(unlock_lu ,e),
|
||||
OPCODE(enter_lu_pred ,Ill),
|
||||
OPCODE(stale_lu_index ,Ill),
|
||||
OPCODE(trust_logical_pred ,l),
|
||||
|
@ -650,6 +650,7 @@ restore_opcodes(yamop *pc)
|
||||
case _count_a_call:
|
||||
case _index_dbref:
|
||||
case _index_blob:
|
||||
case _unlock_lu:
|
||||
#ifdef YAPOR
|
||||
case _getwork_first_time:
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@
|
||||
:- module(terms, [
|
||||
term_hash/2,
|
||||
term_hash/4,
|
||||
term_variables/2,
|
||||
term_variablesb/2,
|
||||
variant/2,
|
||||
subsumes/2,
|
||||
subsumes_chk/2,
|
||||
@ -30,6 +30,9 @@
|
||||
term_hash(T,H) :-
|
||||
term_hash(T, -1, 33554432, H).
|
||||
|
||||
%term_hash(X,Y) :-
|
||||
% term_hash(X,-1,16'1000000,Y).
|
||||
|
||||
subsumes_chk(X,Y) :-
|
||||
\+ \+ subsumes(X,Y).
|
||||
|
||||
|
@ -567,7 +567,10 @@ PredPropByAtom(Atom at, SMALLUNSGN cur_mod)
|
||||
typedef enum {
|
||||
PROLOG_MODULE = 0,
|
||||
USER_MODULE = 1,
|
||||
IDB_MODULE = 2
|
||||
IDB_MODULE = 2,
|
||||
ATTRIBUTES_MODULE = 3,
|
||||
CHARSIO_MODULE = 4,
|
||||
TERMS_MODULE = 5
|
||||
} default_modules;
|
||||
|
||||
|
||||
|
24
pl/init.yap
24
pl/init.yap
@ -89,30 +89,6 @@ system_mode(verbose,off) :- set_value('$verbose',off).
|
||||
|
||||
:- default_sequential(off).
|
||||
|
||||
:- '$set_pred_module'(get_att(_,_,_), attributes),
|
||||
'$set_pred_module'(get_all_atts(_,_), attributes),
|
||||
'$set_pred_module'(free_att(_,_), attributes),
|
||||
'$set_pred_module'(put_att(_,_,_), attributes),
|
||||
'$set_pred_module'(rm_att(_,_), attributes),
|
||||
'$set_pred_module'(inc_n_of_atts(_), attributes),
|
||||
'$set_pred_module'(n_of_atts(_), attributes),
|
||||
'$set_pred_module'(bind_attvar(_), attributes),
|
||||
'$set_pred_module'(all_attvars(_), attributes).
|
||||
|
||||
|
||||
:- '$set_pred_module'(open_mem_read_stream(_,_), charsio),
|
||||
'$set_pred_module'(open_mem_write_stream(_), charsio),
|
||||
'$set_pred_module'(peek_mem_write_stream(_,_,_), charsio).
|
||||
|
||||
:- '$set_pred_module'(term_hash(_,_,_,_), terms),
|
||||
'$set_pred_module'(term_hash(_,_), terms),
|
||||
'$set_pred_module'(term_variables(_,_), terms),
|
||||
'$set_pred_module'(variant(_,_), terms),
|
||||
'$set_pred_module'(subsumes(_,_), terms),
|
||||
'$set_pred_module'(cyclic_term(_), terms),
|
||||
'$set_pred_module'(acyclic_term(_,_), terms),
|
||||
'$set_pred_module'(variable_in_term(_,_), terms).
|
||||
|
||||
%
|
||||
% cleanup ensure loaded and recover some data-base space.
|
||||
%
|
||||
|
@ -774,9 +774,6 @@ version(T) :-
|
||||
'$assert_version'(T) :- recordz('$version',T,_), fail.
|
||||
'$assert_version'(_).
|
||||
|
||||
term_variables(Term, L) :-
|
||||
'$variables_in_term'(Term, [], L).
|
||||
|
||||
term_hash(X,Y) :-
|
||||
term_hash(X,-1,16'1000000,Y).
|
||||
|
||||
|
Reference in New Issue
Block a user