simplify module unfolding
This commit is contained in:
parent
abe1168b1d
commit
70f6080857
34
C/exec.c
34
C/exec.c
@ -209,8 +209,10 @@ 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;
|
||||||
|
t = Yap_YapStripModule(t, &mod);
|
||||||
/* first do predicate expansion, even before you process signals.
|
/* 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 &&
|
||||||
@ -218,7 +220,7 @@ inline static bool do_execute(Term t, Term mod USES_REGS) {
|
|||||||
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,23 +240,8 @@ 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) {
|
|
||||||
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);
|
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
|
||||||
otherwise I would dereference the argument and
|
otherwise I would dereference the argument and
|
||||||
@ -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