more SWI stuff.

This commit is contained in:
Vitor Santos Costa 2011-06-14 09:04:03 +01:00
parent ad5e29ba72
commit a516d6ad47
4 changed files with 51 additions and 23 deletions

View File

@ -10,7 +10,6 @@
chdir/1,
compile_aux_clauses/1,
convert_time/2,
'$set_source_module'/2,
'$declare_module'/5,
'$set_predicate_attribute'/3,
stamp_date_time/3,
@ -183,25 +182,6 @@ compile_aux_clauses([Cl|Cls]) :-
assert_static(M:Cl),
compile_aux_clauses(Cls).
'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0), !,
module(SourceF).
'$set_source_module'(Source0, SourceF) :-
current_module(Source0, SourceF).
/** '$declare_module'(+Module, +Super, +File, +Line, +Redefine) is det.
Start a new (source-)module
@param Module is the name of the module to declare
@param File is the canonical name of the file from which the module
is loaded
@param Line is the line-number of the :- module/2 directive.
@param Redefine If =true=, allow associating the module to a new file
*/
'$declare_module'(Name, Context, _, _, _) :-
add_import_module(Name, Context, start).
'$set_predicate_attribute'(_, _, _).
flag(Key, Old, New) :-

View File

@ -871,8 +871,8 @@ absolute_file_name(File,Opts,TrueFileName) :-
'$type_extension'(Type,Ext),
atom_concat([File,Ext],F).
'$add_type_extensions'(Type,File,F) :-
user:prolog_file_type(Type, File),
atom_concat([File,Ext],F).
user:prolog_file_type(Ext, Type),
atom_concat([File,'.',Ext],F).
'$type_extension'(txt,'').
'$type_extension'(prolog,'.yap').
@ -1050,4 +1050,9 @@ make.
'$fetch_stream_alias'(OldStream,Alias) :-
stream_property(OldStream, alias(Alias)), !.
'$require'(_Ps, _M).
'$require'(_Ps, _M).
'$store_clause'('$source_location'(File, Line):Clause, File) :-
assert_static(Clause).

View File

@ -801,3 +801,28 @@ delete_import_module(Mod, ImportModule) :-
'$do_error'(type_error(atom,Mod),delete_import_module(Mod, ImportModule)).
delete_import_module(Mod, ImportModule) :-
'$do_error'(type_error(atom,ImportModule),delete_import_module(Mod, ImportModule)).
'$set_source_module'(Source0, SourceF) :-
prolog_load_context(module, Source0), !,
module(SourceF).
'$set_source_module'(Source0, SourceF) :-
current_module(Source0, SourceF).
/** '$declare_module'(+Module, +Super, +File, +Line, +Redefine) is det.
Start a new (source-)module
@param Module is the name of the module to declare
@param File is the canonical name of the file from which the module
is loaded
@param Line is the line-number of the :- module/2 directive.
@param Redefine If =true=, allow associating the module to a new file
*/
'$declare_module'(Name, Context, _, _, _) :-
add_import_module(Name, Context, start).
module_property(Mod, file(F)) :-
recorded('$module','$module'(F,Mod,_),_).
module_property(Mod, exports(Es)) :-
recorded('$module','$module'(_,Mod,Es),_).

View File

@ -719,3 +719,21 @@ subsumes_term(A,B) :-
\+ \+ terms:subsumes(A,B).
%% file_name_on_path(+File:atom, -OnPath) is det.
%
% True if OnPath a description of File based on the file search
% path. This performs the inverse of absolute_file_name/3.
file_name_on_path(Path, ShortId) :-
( file_alias_path(Alias, Dir),
atom_concat(Dir, Local, Path)
-> ( Alias == '.'
-> ShortId = Local
; file_name_extension(Base, pl, Local)
-> ShortId =.. [Alias, Base]
; ShortId =.. [Alias, Local]
)
; ShortId = Path
).