simplify module unfolding
This commit is contained in:
parent
abe1168b1d
commit
70f6080857
38
C/exec.c
38
C/exec.c
@ -209,16 +209,18 @@ static Int save_env_b(USES_REGS1) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static bool do_execute(Term t, Term mod USES_REGS) {
|
inline static bool do_execute(Term t, Term mod USES_REGS) {
|
||||||
Term t0 = t;
|
Term t0 = t;
|
||||||
/* first do predicate expansion, even before you process signals.
|
t = Yap_YapStripModule(t, &mod);
|
||||||
|
/* first do predicate expansion, even before you process signals.
|
||||||
This way you don't get to spy goal_expansion(). */
|
This way you don't get to spy goal_expansion(). */
|
||||||
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
if (Yap_has_a_signal() && !LOCAL_InterruptsDisabled &&
|
||||||
!(LOCAL_PrologMode & (AbortMode | InterruptMode | SystemMode))) {
|
!(LOCAL_PrologMode & (AbortMode | InterruptMode | SystemMode))) {
|
||||||
return EnterCreepMode(t, mod PASS_REGS);
|
return EnterCreepMode(t, mod PASS_REGS);
|
||||||
}
|
}
|
||||||
restart_exec:
|
restart_exec:
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t) || IsVarTerm(mod)) {
|
||||||
return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS);
|
return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS);
|
||||||
} else if (IsApplTerm(t)) {
|
} else if (IsApplTerm(t)) {
|
||||||
register Functor f = FunctorOfTerm(t);
|
register Functor f = FunctorOfTerm(t);
|
||||||
@ -238,22 +240,7 @@ restart_exec:
|
|||||||
/* You thought we would be over by now */
|
/* You thought we would be over by now */
|
||||||
/* but no meta calls require special preprocessing */
|
/* but no meta calls require special preprocessing */
|
||||||
if (pen->PredFlags & MetaPredFlag) {
|
if (pen->PredFlags & MetaPredFlag) {
|
||||||
if (f == FunctorModule) {
|
return CallMetaCall(t, mod PASS_REGS);
|
||||||
Term tmod = ArgOfTerm(1, t);
|
|
||||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
|
||||||
mod = tmod;
|
|
||||||
t = ArgOfTerm(2, t);
|
|
||||||
goto restart_exec;
|
|
||||||
} else {
|
|
||||||
if (IsVarTerm(tmod)) {
|
|
||||||
return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS);
|
|
||||||
} else {
|
|
||||||
return CallError(TYPE_ERROR_ATOM, t0, mod PASS_REGS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return CallMetaCall(t, mod PASS_REGS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* now let us do what we wanted to do from the beginning !! */
|
/* now let us do what we wanted to do from the beginning !! */
|
||||||
/* I cannot use the standard macro here because
|
/* I cannot use the standard macro here because
|
||||||
@ -1209,6 +1196,7 @@ static Int execute_nonstop(USES_REGS1) { /* '$execute_nonstop'(Goal,Mod)
|
|||||||
unsigned int arity;
|
unsigned int arity;
|
||||||
Prop pe;
|
Prop pe;
|
||||||
|
|
||||||
|
t = Yap_YapStripModule(t, &mod);
|
||||||
restart_exec:
|
restart_exec:
|
||||||
if (IsVarTerm(mod)) {
|
if (IsVarTerm(mod)) {
|
||||||
mod = CurrentModule;
|
mod = CurrentModule;
|
||||||
@ -1229,20 +1217,6 @@ restart_exec:
|
|||||||
|
|
||||||
if (IsExtensionFunctor(f))
|
if (IsExtensionFunctor(f))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (f == FunctorModule) {
|
|
||||||
Term tmod = ArgOfTerm(1, t);
|
|
||||||
if (!IsVarTerm(tmod) && IsAtomTerm(tmod)) {
|
|
||||||
mod = tmod;
|
|
||||||
t = ArgOfTerm(2, t);
|
|
||||||
goto restart_exec;
|
|
||||||
} else {
|
|
||||||
if (IsVarTerm(tmod)) {
|
|
||||||
return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS);
|
|
||||||
} else {
|
|
||||||
return CallError(TYPE_ERROR_ATOM, t, mod PASS_REGS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pe = PredPropByFunc(f, mod);
|
pe = PredPropByFunc(f, mod);
|
||||||
arity = ArityOfFunctor(f);
|
arity = ArityOfFunctor(f);
|
||||||
if (arity > MaxTemps) {
|
if (arity > MaxTemps) {
|
||||||
|
Reference in New Issue
Block a user