support requires/1.

This commit is contained in:
Vitor Santos Costa 2010-07-28 23:25:12 +01:00
parent 15c9d385a9
commit 617e43b9c1

View File

@ -23,6 +23,7 @@
format_time/4,
time_file/2,
flag/3,
require/1,
current_flag/1
]).
@ -81,6 +82,9 @@
cyclic_term/1,
variant/2]).
:- use_module(library(error),[must_be/2]).
:- source.
:- style_check(all).
@ -353,3 +357,26 @@ flag(Key, 0, New) :-
current_flag(Key) :-
swi:flag(Key).
require(F) :-
must_be(list, F),
% notice that this must be used as a declaration.
prolog_load_context(module, Mod),
required_predicates(F, Mod).
required_predicates([], _).
required_predicates(F.Fs, M) :-
required_predicate(F, M),
required_predicates(Fs, M).
required_predicate(Na/Ar, M) :-
functor(G, Na, Ar),
(
predicate_property(M:G, _) ->
true
;
autoloader:find_predicate(G, _)
).