modules stuff fixes (yes, again).

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@975 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-02-10 01:07:46 +00:00
parent 3e468eea4e
commit 31b6bedf67
8 changed files with 61 additions and 58 deletions

View File

@ -1737,7 +1737,7 @@ p_number_of_clauses(void)
return (FALSE); return (FALSE);
} }
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(RepPredProp(pe)->PRWLock); READ_LOCK(RepPredProp(pe)->PRWLock);
ncl = RepPredProp(pe)->cs.p_code.NOfClauses; ncl = RepPredProp(pe)->cs.p_code.NOfClauses;
READ_UNLOCK(RepPredProp(pe)->PRWLock); READ_UNLOCK(RepPredProp(pe)->PRWLock);
@ -1767,7 +1767,7 @@ p_in_use(void)
} else } else
return FALSE; return FALSE;
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
out = static_in_use(pe,TRUE); out = static_in_use(pe,TRUE);
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
@ -1834,7 +1834,7 @@ p_is_multifile(void)
} else } else
return(FALSE); return(FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
out = (pe->PredFlags & MultiFileFlag); out = (pe->PredFlags & MultiFileFlag);
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
@ -1861,7 +1861,7 @@ p_is_log_updatable(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
out = (pe->PredFlags & LogUpdatePredFlag); out = (pe->PredFlags & LogUpdatePredFlag);
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
@ -1888,7 +1888,7 @@ p_is_source(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
out = (pe->PredFlags & SourcePredFlag); out = (pe->PredFlags & SourcePredFlag);
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
@ -1915,7 +1915,7 @@ p_is_dynamic(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
out = (pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag)); out = (pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag));
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
@ -1942,7 +1942,7 @@ p_pred_exists(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
if (pe->PredFlags & HiddenPredFlag) if (pe->PredFlags & HiddenPredFlag)
return(FALSE); return(FALSE);
@ -1983,7 +1983,7 @@ p_set_pred_module(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return FALSE;
WRITE_LOCK(pe->PRWLock); WRITE_LOCK(pe->PRWLock);
{ {
SMALLUNSGN mod = Yap_LookupModule(Deref(ARG2)); SMALLUNSGN mod = Yap_LookupModule(Deref(ARG2));
@ -2041,18 +2041,18 @@ p_undefined(void)
return TRUE; return TRUE;
} }
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (FALSE); return TRUE;
READ_LOCK(pe->PRWLock); READ_LOCK(pe->PRWLock);
if (pe->PredFlags & (CPredFlag|UserCPredFlag|TestPredFlag|AsmPredFlag|DynamicPredFlag|LogUpdatePredFlag)) { if (pe->PredFlags & (CPredFlag|UserCPredFlag|TestPredFlag|AsmPredFlag|DynamicPredFlag|LogUpdatePredFlag)) {
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
return(FALSE); return FALSE;
} }
if (pe->OpcodeOfPred == UNDEF_OPCODE) { if (pe->OpcodeOfPred == UNDEF_OPCODE) {
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
return (TRUE); return TRUE;
} }
READ_UNLOCK(pe->PRWLock); READ_UNLOCK(pe->PRWLock);
return (FALSE); return FALSE;
} }
/* /*
@ -2088,7 +2088,7 @@ p_kill_dynamic(void)
} else } else
return (FALSE); return (FALSE);
if (EndOfPAEntr(pe)) if (EndOfPAEntr(pe))
return (TRUE); return TRUE;
WRITE_LOCK(pe->PRWLock); WRITE_LOCK(pe->PRWLock);
if (!(pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) { if (!(pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
WRITE_UNLOCK(pe->PRWLock); WRITE_UNLOCK(pe->PRWLock);

View File

@ -18,7 +18,7 @@
:- module(terms, [ :- module(terms, [
term_hash/2, term_hash/2,
term_hash/4, term_hash/4,
term_variablesb/2, term_variables/2,
variant/2, variant/2,
subsumes/2, subsumes/2,
subsumes_chk/2, subsumes_chk/2,

View File

@ -833,28 +833,28 @@ break :- get_value('$break',BL), NBL is BL+1,
'$csult'(V, _) :- var(V), !, '$csult'(V, _) :- var(V), !,
'$do_error'(instantiation_error,consult(V)). '$do_error'(instantiation_error,consult(V)).
'$csult'([], _). '$csult'([], _).
'$csult'([-F|L], M) :- !, '$reconsult'(M:F), '$csult'(L, M). '$csult'([-F|L], M) :- !, '$reconsult'(F, M), '$csult'(L, M).
'$csult'([F|L], M) :- '$consult'(M:F), '$csult'(L, M). '$csult'([F|L], M) :- '$consult'(F, M), '$csult'(L, M).
'$consult'(V) :- var(V), !, '$consult'(V, _) :- var(V), !,
'$do_error'(instantiation_error,consult(V)). '$do_error'(instantiation_error,consult(V)).
'$consult'([]) :- !. '$consult'([], _) :- !.
'$consult'([F|Fs]) :- !, '$consult'([F|Fs], M) :- !,
'$consult'(F), '$consult'(F, M),
'$consult'(Fs). '$consult'(Fs, M).
'$consult'(M:X) :- atom(M), !, '$consult'(M:X, _) :- !,
'$current_module'(M0), ( atom(M) ->
'$change_module'(M), '$consult'(X, M)
'$consult'(X), ;
'$change_module'(M0). '$do_error'(type_error(atom,M),[M:X])
'$consult'(X) :- ).
'$consult'(X, OldModule) :-
'$find_in_path'(X,Y,consult(X)), '$find_in_path'(X,Y,consult(X)),
'$open'(Y,'$csult',Stream,0), !, '$open'(Y,'$csult',Stream,0), !,
'$current_module'(OldModule),
'$consult'(X,OldModule,Stream), '$consult'(X,OldModule,Stream),
'$close'(Stream). '$close'(Stream).
'$consult'(X) :- '$consult'(X, _) :-
'$do_error'(permission_error(input,stream,X),consult(X)). '$do_error'(permission_error(input,stream,X),[X]).
'$consult'(_,Module,Stream) :- '$consult'(_,Module,Stream) :-
@ -865,6 +865,7 @@ break :- get_value('$break',BL), NBL is BL+1,
!, !,
'$reconsult'(F,Module,Stream). '$reconsult'(F,Module,Stream).
'$consult'(F,Mod,Stream) :- '$consult'(F,Mod,Stream) :-
'$current_module'(OldModule, Mod),
'$getcwd'(OldD), '$getcwd'(OldD),
get_value('$consulting_file',OldF), get_value('$consulting_file',OldF),
'$set_consulting_file'(Stream), '$set_consulting_file'(Stream),
@ -886,6 +887,7 @@ break :- get_value('$break',BL), NBL is BL+1,
'$add_multifile_clauses'(File), '$add_multifile_clauses'(File),
set_value('$consulting',Old), set_value('$consulting',Old),
set_value('$consulting_file',OldF), set_value('$consulting_file',OldF),
'$current_module'(NewMod,OldModule),
'$cd'(OldD), '$cd'(OldD),
( LC == 0 -> prompt(_,' |: ') ; true), ( LC == 0 -> prompt(_,' |: ') ; true),
H is heapused-H0, '$cputime'(TF,_), T is TF-T0, H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
@ -896,7 +898,7 @@ break :- get_value('$break',BL), NBL is BL+1,
true true
) )
; ;
'$print_message'(informational, loaded(consulted, File, Mod, T, H)) '$print_message'(informational, loaded(consulted, File, NewMod, T, H))
), ),
'$exec_initialisation_goals', '$exec_initialisation_goals',
!. !.

View File

@ -62,7 +62,8 @@ compile(P) :-
'$change_module'(M0). '$change_module'(M0).
'$compile'(A) :- '$compile'(A) :-
'$compile_mode'(Old,0), '$compile_mode'(Old,0),
'$reconsult'(A), '$current_module'(M0),
'$reconsult'(A, M0),
'$compile_mode'(_,Old). '$compile_mode'(_,Old).
consult(Fs) :- consult(Fs) :-
@ -75,32 +76,36 @@ reconsult(Fs) :-
'$has_yap_or', fail, '$has_yap_or', fail,
'$do_error'(context_error(reconsult(Fs),clause),query). '$do_error'(context_error(reconsult(Fs),clause),query).
reconsult(Fs) :- reconsult(Fs) :-
'$reconsult'(Fs).
'$reconsult'(V) :- var(V), !,
'$do_error'(instantiation_error,reconsult(V)).
'$reconsult'([]) :- !.
'$reconsult'(M:X) :- atom(M), !,
'$current_module'(M0), '$current_module'(M0),
'$change_module'(M), '$reconsult'(Fs, M0).
'$reconsult'(X),
'$change_module'(M0). '$reconsult'(V, _) :- var(V), !,
'$reconsult'([F|Fs]) :- !, '$do_error'(instantiation_error,reconsult(V)).
'$reconsult'(F), '$reconsult'([], _) :- !.
'$reconsult'(Fs). '$reconsult'(M:X, _) :-
'$reconsult'(X) :- (
atom(M)
->
'$reconsult'(X, M)
;
'$do_error'(type_error(atom,M),reconsult(M:X))
).
'$reconsult'([F|Fs], M) :- !,
'$reconsult'(F, M),
'$reconsult'(Fs, M).
'$reconsult'(X, M) :-
'$find_in_path'(X,Y,reconsult(X)), '$find_in_path'(X,Y,reconsult(X)),
'$open'(Y,'$csult',Stream,0), !, '$open'(Y,'$csult',Stream,0), !,
'$current_module'(M),
'$reconsult'(X,M,Stream), '$reconsult'(X,M,Stream),
'$close'(Stream). '$close'(Stream).
'$reconsult'(X) :- '$reconsult'(X, M) :-
'$do_error'(permission_error(input,stream,X),reconsult(X)). '$do_error'(permission_error(input,stream,X),reconsult(M:X)).
'$reconsult'(F,M,Stream) :- '$reconsult'(F,M,Stream) :-
'$record_loaded'(Stream, M), '$record_loaded'(Stream, M),
fail. fail.
'$reconsult'(F, OldModule, Stream) :- '$reconsult'(F, ContextModule, Stream) :-
'$current_module'(OldModule,ContextModule),
'$getcwd'(OldD), '$getcwd'(OldD),
get_value('$consulting_file',OldF), get_value('$consulting_file',OldF),
'$set_consulting_file'(Stream), '$set_consulting_file'(Stream),

View File

@ -83,9 +83,9 @@
'$exec_directive'(compile(F), _, M) :- '$exec_directive'(compile(F), _, M) :-
'$compile'(M:F). '$compile'(M:F).
'$exec_directive'(reconsult(Fs), _, M) :- '$exec_directive'(reconsult(Fs), _, M) :-
'$reconsult'(M:Fs). '$reconsult'(Fs, M).
'$exec_directive'(consult(Fs), _, M) :- '$exec_directive'(consult(Fs), _, M) :-
'$consult'(M:Fs). '$consult'(Fs, M).
'$exec_directive'(use_module(Fs), _, M) :- '$exec_directive'(use_module(Fs), _, M) :-
'$use_module'(M:Fs). '$use_module'(M:Fs).
'$exec_directive'(use_module(Fs,I), _, M) :- '$exec_directive'(use_module(Fs,I), _, M) :-

View File

@ -212,7 +212,7 @@ print_message(Level, Mss) :-
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$loop',_,prolog,ClNo,Gs,I,NGs) :- !, '$beautify_hidden_goal'('$loop',_,prolog,ClNo,Gs,I,NGs) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$consult',1,prolog,ClNo,Gs,I,NGs) :- !, '$beautify_hidden_goal'('$consult',3,prolog,ClNo,Gs,I,NGs) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$reconsult',_,prolog,ClNo,Gs,I,NGs) :- !, '$beautify_hidden_goal'('$reconsult',_,prolog,ClNo,Gs,I,NGs) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
@ -224,7 +224,7 @@ print_message(Level, Mss) :-
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$recorded_with_key',3,prolog,ClNo,Gs,I,[cl(recorded,3,prolog,ClNo)|NGs]) :- !, '$beautify_hidden_goal'('$recorded_with_key',3,prolog,ClNo,Gs,I,[cl(recorded,3,prolog,ClNo)|NGs]) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$consult',2,prolog,ClNo,Gs,I,[cl(consult,1,prolog,ClNo)|NGs]) :- !, '$beautify_hidden_goal'('$consult',3,prolog,ClNo,Gs,I,[cl(consult,1,prolog,ClNo)|NGs]) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).
'$beautify_hidden_goal'('$findall_with_common_vars',_,prolog,ClNo,Gs,I,[cl(findall,4,prolog,ClNo)|NGs]) :- !, '$beautify_hidden_goal'('$findall_with_common_vars',_,prolog,ClNo,Gs,I,[cl(findall,4,prolog,ClNo)|NGs]) :- !,
'$preprocess_stack'(Gs, I, NGs). '$preprocess_stack'(Gs, I, NGs).

View File

@ -105,7 +105,7 @@ system_mode(verbose,off) :- set_value('$verbose',off).
% :- yap_flag(gc_trace,verbose). % :- yap_flag(gc_trace,verbose).
:- initialization(system_mode(verbose,on)). :- initialization((system_mode(verbose,on),module(user))).
:- module(user). :- module(user).

View File

@ -774,10 +774,6 @@ version(T) :-
'$assert_version'(T) :- recordz('$version',T,_), fail. '$assert_version'(T) :- recordz('$version',T,_), fail.
'$assert_version'(_). '$assert_version'(_).
term_hash(X,Y) :-
term_hash(X,-1,16'1000000,Y).
'$set_toplevel_hook'(_) :- '$set_toplevel_hook'(_) :-
recorded('$toplevel_hooks',_,R), recorded('$toplevel_hooks',_,R),
erase(R), erase(R),