diff --git a/C/modules.c b/C/modules.c index a1a5c5754..be842029f 100644 --- a/C/modules.c +++ b/C/modules.c @@ -218,14 +218,17 @@ init_current_module(void) static Int p_strip_module(void) { - Term t1 = Deref(ARG1), t2, tmod; + Term t1 = Deref(ARG1), t2, tmod = CurrentModule; + if (tmod == PROLOG_MODULE) { + tmod = TermProlog; + } if (IsVarTerm(t1) || !IsApplTerm(t1) || FunctorOfTerm(t1) != FunctorModule || IsVarTerm(t2 = ArgOfTerm(1,t1)) || !IsAtomTerm(t2)) { return Yap_unify(ARG3, t1) && - Yap_unify(ARG2, CurrentModule); + Yap_unify(ARG2, tmod); } do { tmod = t2; diff --git a/C/save.c b/C/save.c index 18fd49094..2790f0e89 100644 --- a/C/save.c +++ b/C/save.c @@ -1007,8 +1007,10 @@ get_coded(int flag, OPCODE old_ops[]) static void restore_heap_regs(void) { - HeapTop = AddrAdjust(HeapTop); - *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + if (HeapTop) { + HeapTop = AddrAdjust(HeapTop); + *((YAP_SEG_SIZE *) HeapTop) = InUseFlag; + } HeapMax = Yap_heap_regs->heap_used = OldHeapUsed; restore_codes(); } diff --git a/C/stdpreds.c b/C/stdpreds.c index 931ec9d1d..216cdb979 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -11,8 +11,12 @@ * File: stdpreds.c * * comments: General-purpose C implemented system predicates * * * -* Last rev: $Date: 2008-02-13 10:15:35 $,$Author: vsc $ * +* Last rev: $Date: 2008-02-15 12:41:33 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.127 2008/02/13 10:15:35 vsc +* fix some bugs from yesterday plus improve support for modules in +* operators. +* * Revision 1.126 2008/02/07 23:09:13 vsc * don't break ISO standard in current_predicate/1. * Include Nicos flag. @@ -2827,7 +2831,7 @@ cont_current_op(void) tmod = pp->OpModule; READ_UNLOCK(pp->OpRWLock); EXTRA_CBACK_ARG(4,3) = (CELL) MkIntTerm(fix); - return (Yap_unify_constant(ARG1, MkIntTerm(prio)) && + return (Yap_unify_constant(ARG1, MkIntTerm(prio)) && Yap_unify_constant(ARG2, TType) && Yap_unify_constant(ARG3, MkAtomTerm(a)) && Yap_unify_constant(ARG4, tmod)); @@ -2881,7 +2885,7 @@ init_current_op(void) EXTRA_CBACK_ARG(4,1) = (CELL) MkAtomTerm(a); EXTRA_CBACK_ARG(4,2) = (CELL) MkIntTerm(i); if (IsVarTerm(top)) - EXTRA_CBACK_ARG(4,3) = (CELL) MkIntTerm(3); + EXTRA_CBACK_ARG(4,3) = (CELL) MkIntTerm(0); else if (IsAtomTerm(top)) EXTRA_CBACK_ARG(4,3) = (CELL) MkIntTerm(4); else diff --git a/pl/utils.yap b/pl/utils.yap index cf5eefbe5..39727344e 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -296,17 +296,23 @@ op(P,T,V) :- '$check_op_names'(As, G). +'$op'(P, T, [A|As]) :- !, + '$opl'(P, T, [A|As]). '$op'(P, T, A) :- + '$op2'(P,T,A). + +'$opl'(P, T, []). +'$opl'(P, T, [A|As]) :- + '$op2'(P, T, A), + '$opl'(P, T, As). + +'$op2'(P,T,A) :- atom(A), !, '$opdec'(P,T,A,prolog). -'$op'(P, T, user:A) :- !, - '$opdec'(P,T,A,prolog). -'$op'(P, T, M:A) :- - '$opdec'(P,T,A,M). -'$op'(_, _, []). -'$op'(P, T, [A|As]) :- - '$op'(P, T, A), - '$op'(P, T, As). +'$op2'(P,T,A) :- + strip_module(A,M,N), + (M = user -> NM = prolog ; NM = M), + '$opdec'(P,T,N,NM). current_op(X,Y,V) :- var(V), !, '$current_module'(M),