diff --git a/C/init.c b/C/init.c index f6b1b1831..3d920d4eb 100644 --- a/C/init.c +++ b/C/init.c @@ -822,7 +822,10 @@ InitCodes(void) heap_regs->char_conversion_table2 = NULL; heap_regs->number_of_cpreds = 0; heap_regs->number_of_cmpfuncs = 0; - heap_regs->no_of_modules = 1; + /* + don't initialise this here, this is initialised by _YAP_InitModules!!!! + heap_regs->no_of_modules = 1; + */ heap_regs->primitives_module = 0; heap_regs->user_module = 1; heap_regs->db_queues = NULL; diff --git a/C/modules.c b/C/modules.c index 3e01dc5d3..8fb6c170b 100644 --- a/C/modules.c +++ b/C/modules.c @@ -50,9 +50,11 @@ LookupModule(Term a) { unsigned int i; - for (i = 0; i < NoOfModules; ++i) - if (ModuleName[i] == a) + for (i = 0; i < NoOfModules; ++i) { + if (ModuleName[i] == a) { return (i); + } + } ModuleName[i = NoOfModules++] = a; if (NoOfModules == MaxModules) { _YAP_Error(SYSTEM_ERROR,a,"number of modules overflowed"); @@ -65,24 +67,18 @@ _YAP_LookupModule(Term a) { return(LookupModule(a)); } + static Int p_current_module(void) { /* $current_module(Old,New) */ Term t; - unsigned int i; if (!_YAP_unify_constant(ARG1, ModuleName[CurrentModule])) return (0); t = Deref(ARG2); if (IsVarTerm(t) || !IsAtomTerm(t)) return (0); - for (i = 0; i < NoOfModules; ++i) - if (ModuleName[i] == t) { - CurrentModule = i; - return (TRUE); - } - CurrentModule = NoOfModules; - ModuleName[NoOfModules++] = t; + CurrentModule = LookupModule(t); return (TRUE); } diff --git a/pl/debug.yap b/pl/debug.yap index e77fc8386..93fc4289b 100644 --- a/pl/debug.yap +++ b/pl/debug.yap @@ -381,6 +381,11 @@ debugging :- '$spycalls'(Mod:G,_,Res) :- !, '$spycalls'(G,Mod,Res). +'$spycalls'(G,Mod,Res) :- + '$pred_goal_expansion_on', + % make sure we do not try to expand conjs, etc... + user:goal_expansion(G,Mod,GF), !, + '$spycalls'(GF,Mod,Res). '$spycalls'(\+ G,Mod,Res) :- !, CP is '$last_choice_pt',