From 1db83cc30d0d81da69a235c366270127b2e1c61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 24 Apr 2014 11:40:35 +0100 Subject: [PATCH] make consult reconsult the original file, so that [x]. [x]. is more like [x]. [-x]. --- C/adtdefs.c | 2 +- C/cdmgr.c | 13 +++++++++++-- pl/consult.yap | 12 +++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/C/adtdefs.c b/C/adtdefs.c index 2fd5ff7c7..9770a1c9e 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -915,7 +915,7 @@ Yap_NewThreadPred(PredEntry *ap USES_REGS) p->ExtraPredFlags = 0L; #endif p->src.OwnerFile = ap->src.OwnerFile; - p->OpcodeOfPred = UNDEF_OPCODE; + p->OpcodeOfPred = FAIL_OPCODE; p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred)); p->cs.p_code.ExpandCode = EXPAND_OP_CODE; p->ModuleOfPred = ap->ModuleOfPred; diff --git a/C/cdmgr.c b/C/cdmgr.c index 6182248b3..7111f98fb 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -2018,8 +2018,17 @@ not_was_reconsulted(PredEntry *p, Term t, int mode) } else { fp = LOCAL_ConsultBase; } - if (fp != LOCAL_ConsultBase) + if (fp != LOCAL_ConsultBase) { return FALSE; + } else if (!mode) { // consulting again a predicate in the original file. + if ((p->cs.p_code.NOfClauses && + p->src.OwnerFile == Yap_ConsultingFile( PASS_REGS1 ) && + p->src.OwnerFile != AtomNil && + p->src.OwnerFile != AtomUserIn) ) { + retract_all(p, static_in_use(p,TRUE)); + return TRUE; + } + } if (mode) { if (LOCAL_ConsultSp == LOCAL_ConsultLow+1) { expand_consult(); @@ -2339,7 +2348,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref) if (pflags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag)) spy_flag = TRUE; goal_expansion_support(p, tf); - if (mode == consult) + if (mode == consult) not_was_reconsulted(p, t, TRUE); /* always check if we have a valid error first */ if (LOCAL_ErrorMessage && LOCAL_Error_TYPE == PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE) { diff --git a/pl/consult.yap b/pl/consult.yap index 58606d838..3f9039c65 100755 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -401,7 +401,7 @@ use_module(M,F,Is) :- '$reset_if'(OldIfLevel), % take care with [a:f], a is the ContextModule '$current_module'(SourceModule, ContextModule), - '$lf_opt'(consult, TOpts, Reconsult), + '$lf_opt'(consult, TOpts, Reconsult0), '$lf_opt'('$options', TOpts, Opts), '$lf_opt'('$location', TOpts, ParentF:Line), '$loaded'(Stream, UserFile, SourceModule, ParentF, Line, Reconsult, File, Dir, Opts), @@ -413,7 +413,7 @@ use_module(M,F,Is) :- '$comp_mode'(OldCompMode, CompMode), ( get_value('$syntaxcheckflag',on) -> '$init_style_check'(File) ; true ), recorda('$initialisation','$',_), - ( Reconsult = reconsult -> + ( Reconsult \== consult -> '$start_reconsulting'(File), '$start_consult'(Reconsult,File,LC), '$remove_multifile_clauses'(File), @@ -421,6 +421,7 @@ use_module(M,F,Is) :- EndMsg = reconsulted ; '$start_consult'(Reconsult,File,LC), + ( File \= user_input, File \= [] -> '$remove_multifile_clauses'(File) ; true ), StartMsg = consulting, EndMsg = consulted ), @@ -931,9 +932,10 @@ make_library_index(_Directory). '$file_name'(Stream,F) :- stream_property(Stream, file_name(F)), !. -'$file_name'(user_input,user_input). -'$file_name'(user_output,user_ouput). -'$file_name'(user_error,user_error). +'$file_name'(user_input,user_input) :- !. +'$file_name'(user_output,user_ouput) :- !. +'$file_name'(user_error,user_error) :- !. +'$file_name'(_,[]). '$fetch_stream_alias'(OldStream,Alias) :-