This commit is contained in:
Vitor Santos Costa 2018-03-23 18:48:16 +00:00
parent c2f2490fee
commit 56e676ef65

View File

@ -916,9 +916,7 @@ static int interrupt_dexecute(USES_REGS1) {
static void undef_goal(USES_REGS1) { static void undef_goal(USES_REGS1) {
PredEntry *pe = PredFromDefCode(P); PredEntry *pe = PredFromDefCode(P);
CELL *b;
CELL *b0;
BEGD(d0); BEGD(d0);
/* avoid trouble with undefined dynamic procedures */ /* avoid trouble with undefined dynamic procedures */
/* I assume they were not locked beforehand */ /* I assume they were not locked beforehand */
@ -928,6 +926,15 @@ static void undef_goal(USES_REGS1) {
PP = pe; PP = pe;
} }
#endif #endif
if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) ) {
#if defined(YAPOR) || defined(THREADS)
UNLOCKPE(19, PP);
PP = NULL;
#endif
CalculateStackGap(PASS_REGS1);
P = FAILCODE;
return;
}
if (UndefCode == NULL || UndefCode->OpcodeOfPred == UNDEF_OPCODE) { if (UndefCode == NULL || UndefCode->OpcodeOfPred == UNDEF_OPCODE) {
fprintf(stderr,"call to undefined Predicates %s ->", IndicatorOfPred(pe)); fprintf(stderr,"call to undefined Predicates %s ->", IndicatorOfPred(pe));
Yap_DebugPlWriteln(ARG1); Yap_DebugPlWriteln(ARG1);
@ -937,15 +944,6 @@ static void undef_goal(USES_REGS1) {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
UNLOCKPE(19, PP); UNLOCKPE(19, PP);
PP = NULL; PP = NULL;
#endif
CalculateStackGap(PASS_REGS1);
P = FAILCODE;
return;
}
if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) ) {
#if defined(YAPOR) || defined(THREADS)
UNLOCKPE(19, PP);
PP = NULL;
#endif #endif
CalculateStackGap(PASS_REGS1); CalculateStackGap(PASS_REGS1);
P = FAILCODE; P = FAILCODE;
@ -955,27 +953,16 @@ static void undef_goal(USES_REGS1) {
UNLOCKPE(19, PP); UNLOCKPE(19, PP);
PP = NULL; PP = NULL;
#endif #endif
d0 = pe->ArityOfPE; if (pe->ArityOfPE == 0) {
if (pe->ModuleOfPred == PROLOG_MODULE) { d0 = MkAtomTerm((Atom)(pe->FunctorOfPred));
if (CurrentModule == PROLOG_MODULE)
HR[0] = MkAtomTerm(Yap_LookupAtom("prolog"));
else
HR[0] = CurrentModule;
} else { } else {
HR[0] = Yap_Module_Name(pe); d0 = AbsAppl(HR);
}
b = b0 = HR;
HR += 2;
if (d0 == 0) {
b[1] = MkAtomTerm((Atom)(pe->FunctorOfPred));
} else {
b[1] = AbsAppl(b+2);
*HR++ = (CELL)pe->FunctorOfPred; *HR++ = (CELL)pe->FunctorOfPred;
b += 3; CELL *ip=HR, *imax = HR+pe->ArityOfPE;
HR += d0; HR = imax;
BEGP(pt1); BEGP(pt1);
pt1 = XREGS + 1; pt1 = XREGS + 1;
for (; d0 > 0; --d0) { for (; ip < imax; ip++) {
BEGD(d1); BEGD(d1);
BEGP(pt0); BEGP(pt0);
pt0 = pt1++; pt0 = pt1++;
@ -983,18 +970,17 @@ static void undef_goal(USES_REGS1) {
deref_head(d1, undef_unk); deref_head(d1, undef_unk);
undef_nonvar: undef_nonvar:
/* just copy it to the heap */ /* just copy it to the heap */
*b++ = d1; *ip = d1;
continue; continue;
derefa_body(d1, pt0, undef_unk, undef_nonvar); derefa_body(d1, pt0, undef_unk, undef_nonvar);
if (pt0 <= HR) { if (pt0 <= HR) {
/* variable is safe */ /* variable is safe */
*b++ = (CELL)pt0; *ip = (CELL)pt0;
} else { } else {
/* bind it, in case it is a local variable */ /* bind it, in case it is a local variable */
d1 = Unsigned(HR); d1 = Unsigned(ip);
RESET_VARIABLE(HR); RESET_VARIABLE(ip);
HR += 1;
Bind_Local(pt0, d1); Bind_Local(pt0, d1);
} }
ENDP(pt0); ENDP(pt0);
@ -1002,9 +988,20 @@ static void undef_goal(USES_REGS1) {
} }
ENDP(pt1); ENDP(pt1);
} }
ENDD(d0); ARG1 = AbsPair(HR);
ARG1 = AbsPair(b0); HR[1] = d0;
ARG2 = Yap_getUnknownModule(Yap_GetModuleEntry(b0[0])); ENDD(d0);
if (pe->ModuleOfPred == PROLOG_MODULE) {
if (CurrentModule == PROLOG_MODULE)
HR[0] = TermProlog;
else
HR[0] = CurrentModule;
} else {
HR[0] = Yap_Module_Name(pe);
}
ARG2 = Yap_getUnknownModule(Yap_GetModuleEntry(HR[0]));
HR += 2;
#ifdef LOW_LEVEL_TRACER #ifdef LOW_LEVEL_TRACER
if (Yap_do_low_level_trace) if (Yap_do_low_level_trace)
low_level_trace(enter_pred, UndefCode, XREGS + 1); low_level_trace(enter_pred, UndefCode, XREGS + 1);