From a721ad3e274e7ca74af89ae800281aea671e48a4 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 18 Oct 2002 14:52:58 +0000 Subject: [PATCH] more of the same module fixes. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@643 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/absmi.c | 46 ++++++++++++++++++++++++++++++++++++++++------ C/exec.c | 25 ++++++++++++++++++++----- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index 0f76dab5b..7d9a80dca 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -120,6 +120,28 @@ push_live_regs(yamop *pco) } #endif +static Term +PushModule(Term t,SMALLUNSGN mod) { + Functor f = FunctorOfTerm(t); + Term tmod = ModuleName[mod]; + if (ArityOfFunctor(f) == 2) { + Term ti[2], tf[2]; + ti[0] = tmod; + ti[1] = ArgOfTerm(1,t); + tf[0] = MkApplTerm(FunctorModule,2,ti); + ti[0] = tmod; + ti[1] = ArgOfTerm(2,t); + tf[1] = MkApplTerm(FunctorModule,2,ti); + return(MkApplTerm(f,2,tf)); + } else { + Term ti[2], tf[1]; + ti[0] = tmod; + ti[1] = ArgOfTerm(1,t); + tf[0] = MkApplTerm(FunctorModule,2,ti); + return(MkApplTerm(f,1,tf)); + } +} + Int absmi(int inp) { @@ -11666,8 +11688,12 @@ absmi(int inp) goto execute_nvar; } } - d0 = ExecuteCallMetaCall(mod); - goto execute_nvar; + if (pen->PredFlags & PushModPredFlag) { + d0 = PushModule(d0,mod); + } else { + d0 = ExecuteCallMetaCall(mod); + goto execute_nvar; + } } BEGP(pt1); pt1 = RepAppl(d0); @@ -11785,8 +11811,12 @@ absmi(int inp) goto execute_within_nvar; } } - d0 = ExecuteCallMetaCall(mod); - goto execute_within_nvar; + if (pen->PredFlags & PushModPredFlag) { + d0 = PushModule(d0,mod); + } else { + d0 = ExecuteCallMetaCall(mod); + goto execute_within_nvar; + } } BEGP(pt1); pt1 = RepAppl(d0); @@ -11921,8 +11951,12 @@ absmi(int inp) goto last_execute_within_nvar; } } - d0 = ExecuteCallMetaCall(mod); - goto last_execute_within_nvar; + if (pen->PredFlags & PushModPredFlag) { + d0 = PushModule(d0,mod); + } else { + d0 = ExecuteCallMetaCall(mod); + goto last_execute_within_nvar; + } } BEGP(pt1); pt1 = RepAppl(d0); diff --git a/C/exec.c b/C/exec.c index d13a97c37..1e8670933 100644 --- a/C/exec.c +++ b/C/exec.c @@ -266,8 +266,9 @@ do_execute(Term t, SMALLUNSGN mod) } if (pen->PredFlags & PushModPredFlag) { t = PushModule(t,mod); + } else{ + return(CallMetaCall(mod)); } - return(CallMetaCall(mod)); } /* now let us do what we wanted to do from the beginning !! */ /* I cannot use the standard macro here because @@ -375,7 +376,11 @@ p_execute_within(void) goto restart_exec; } } - return(CallMetaCallWithin()); + if (pen->PredFlags & PushModPredFlag) { + t = PushModule(t,mod); + } else { + return(CallMetaCallWithin()); + } } /* now let us do what we wanted to do from the beginning !! */ /* I cannot use the standard macro here because @@ -473,7 +478,11 @@ p_execute_within2(void) /* You thought we would be over by now */ /* but no meta calls require special preprocessing */ if (pen->PredFlags & MetaPredFlag) { - return(CallMetaCallWithin()); + if (pen->PredFlags & PushModPredFlag) { + t = PushModule(t,mod); + } else { + return(CallMetaCallWithin()); + } } /* at this point check if we should enter creep mode */ /* now let us do what we wanted to do from the beginning !! */ @@ -568,6 +577,10 @@ p_execute0(void) goto restart_exec; } } + pe = PredPropByFunc(f, mod); + if (RepPredProp(pe)->PredFlags & PushModPredFlag) { + t = PushModule(t,mod); + } arity = ArityOfFunctor(f); /* I cannot use the standard macro here because otherwise I would dereference the argument and @@ -584,7 +597,6 @@ p_execute0(void) XREGS[i] = *pt++; #endif } - pe = PredPropByFunc(f, mod); } else { Error(TYPE_ERROR_CALLABLE,ARG3,"call/1"); return(FALSE); @@ -1249,6 +1261,10 @@ p_at_execute(void) } Error(TYPE_ERROR_ATOM, ARG1, "calling clause in debugger"); } + pe = PredPropByFunc(f,mod); + if (RepPredProp(pe)->PredFlags & PushModPredFlag) { + t = PushModule(t,mod); + } arity = ArityOfFunctor(f); a = NameOfFunctor(f); /* I cannot use the standard macro here because @@ -1267,7 +1283,6 @@ p_at_execute(void) #else XREGS[i] = *pt++; #endif - pe = PredPropByFunc(f,mod); } else return (FALSE); /* for the moment */ if (IsVarTerm(t2) || !IsIntTerm(t2))