exo support

This commit is contained in:
Vitor Santos Costa 2013-01-15 11:18:09 +00:00
parent 1207205493
commit 8c8392b5da
4 changed files with 61 additions and 1 deletions

View File

@ -1042,6 +1042,20 @@ bootstrap(F) :-
true
).
'$loop'(Stream,exo) :-
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
repeat,
'$system_catch'(dbload_from_stream(Stream, OldModule, exo), '$db_load', Error,
user:'$LoopError'(Error, Status)),
!.
'$loop'(Stream,db) :-
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
repeat,
'$system_catch'(dbload_from_stream(Stream, OldModule, db), '$db_load', Error,
user:'$LoopError'(Error, Status)),
!.
'$loop'(Stream,Status) :-
(
Status = top

View File

@ -26,7 +26,7 @@
% qcompile(true,false)
% silent(true,false) => implemented
% stream(Stream) => implemented
% consult(consult,reconsult) => implemented
% consult(consult,reconsult,exo,db) => implemented
% compilation_mode(compact,source,assert_all) => implemented
%
load_files(Files,Opts) :-
@ -114,6 +114,8 @@ load_files(Files,Opts) :-
'$process_lf_opt'(compilation_mode(compact),_,_,_,_,_,_,_,_,_,compact,_,_,_).
'$process_lf_opt'(compilation_mode(assert_all),_,_,_,_,_,_,_,_,_,assert_all,_,_,_).
'$process_lf_opt'(consult(reconsult),_,_,_,_,_,_,_,_,_,_,reconsult,_,_).
'$process_lf_opt'(consult(exo),_,_,_,_,_,_,_,_,_,_,exo,_,_).
'$process_lf_opt'(consult(db),_,_,_,_,_,_,_,_,_,_,db,_,_).
'$process_lf_opt'(consult(consult),_,_,_,_,_,_,_,_,_,_,consult,_,_).
'$process_lf_opt'(stream(Stream),_,_,_,_,_,_,Stream,_,_,_,_,Files,Call) :-
/* ( is_stream(Stream) -> true ; '$do_error'(domain_error(stream,Stream),Call) ), */
@ -204,6 +206,12 @@ consult(Fs) :-
reconsult(Fs) :-
'$load_files'(Fs, [], reconsult(Fs)).
exo_files(Fs) :-
'$load_files'(Fs, [consult(exo), if(not_loaded)], exo_files(Fs)).
db_files(Fs) :-
'$load_files'(Fs, [consult(db), if(not_loaded)], exo_files(Fs)).
use_module(F) :-
'$load_files'(F, [if(not_loaded)], use_module(F)).

View File

@ -20,6 +20,41 @@
:- dynamic dbloading/6, dbprocess/2.
dbload_from_stream(R, M0, Type) :-
read(R,T),
( T = end_of_file -> !, close_dbload(R, Type);
dbload_count(T, M0),
fail
).
close_dbload(R, exo) :-
retract(dbloading(Na,Arity,M,T,NaAr,_)),
nb_getval(NaAr,Size),
exo_db_get_space(T, M, Size, Handle),
assertz(dbloading(Na,Arity,M,T,NaAr,Handle)),
nb_setval(NaAr,0),
fail.
close_dbload(R, exo) :-
seek(R, 0, bof, _),
exodb_add_facts(R, M),
fail.
close_dbload(R, mega) :-
retract(dbloading(Na,Arity,M,T,NaAr,_)),
nb_getval(NaAr,Size),
dbload_get_space(T, M, Size, Handle),
assertz(dbloading(Na,Arity,M,T,NaAr,Handle)),
nb_setval(NaAr,0),
fail.
close_dbload(R, mega) :-
seek(R, 0, bof, _),
dbload_add_facts(R, M),
fail.
close_dbload(_, _) :-
retractall(dbloading(_Na,_Arity,_M,_T,_NaAr,_Handle)),
fail.
close_dbload(_, _).
prolog:load_db(Fs) :-
'$current_module'(M0),
prolog_flag(agc_margin,Old,0),
@ -50,6 +85,7 @@ do_dbload(F0, M0, G) :-
check_dbload_stream(R, M0),
close(R).
check_dbload_stream(R, M0) :-
repeat,
catch(read(R,T), _, fail),

View File

@ -614,9 +614,11 @@ source_module(Mod) :-
consult(:),
current_predicate(:),
current_predicate(?,:),
db_files(:),
depth_bound_call(0,+),
discontiguous(:),
ensure_loaded(:),
exo_files(:),
findall(?,0,-),
findall(?,0,-,?),
forall(0,0),