patch module code (by Paulo Moura)

This commit is contained in:
Vítor Santos Costa 2012-10-22 10:18:26 +01:00
parent 14796f5d90
commit 7fa7c8b92a
2 changed files with 26 additions and 15 deletions

View File

@ -2358,7 +2358,8 @@ Add predicates to the public list of the context module. This implies
the predicate will be imported into another module if this module is
imported with @code{use_module/[1,2]}. Note that predicates are normally
exported using the directive @code{module/2}. @code{export/1} is meant
to handle export from dynamically created modules.
to handle export from dynamically created modules. The directive argument
may also be a list of predicates.
@item export_list(?@var{Mod},?@var{ListOfPredicateIndicator})
@findex export_list/2

View File

@ -685,32 +685,42 @@ abolish_module(Mod) :-
fail.
abolish_module(_).
export(P) :-
var(P),
'$do_error'(instantiation_error,export(P)).
export(P) :-
P = F/N, atom(F), number(N), N > 0, !,
export(Resource) :-
var(Resource),
'$do_error'(instantiation_error,export(Resource)).
export([]) :- !.
export([Resource| Resources]) :- !,
export_resource(Resource),
export(Resources).
export(Resource) :-
export_resource(Resource).
export_resource(Resource) :-
var(Resource),
'$do_error'(instantiation_error,export(Resource)).
export_resource(P) :-
P = F/N, atom(F), number(N), N >= 0, !,
'$current_module'(Mod),
( recorded('$module','$module'(F,Mod,ExportedPreds),R) ->
( recorded('$module','$module'(File,Mod,ExportedPreds),R) ->
erase(R),
recorda('$module','$module'(F,Mod,[P|ExportedPreds]),_)
recorda('$module','$module'(File,Mod,[P|ExportedPreds]),_)
;
recorda('$module','$module'(user_input,Mod,[P]),_)
).
export(P0) :-
P0 = F//N, atom(F), number(N), N > 0, !,
export_resource(P0) :-
P0 = F//N, atom(F), number(N), N >= 0, !,
N1 is N+2, P = F/N1,
'$current_module'(Mod),
( recorded('$module','$module'(F,Mod,ExportedPreds),R) ->
( recorded('$module','$module'(File,Mod,ExportedPreds),R) ->
erase(R),
recorda('$module','$module'(F,Mod,[P|ExportedPreds]),_)
recorda('$module','$module'(File,Mod,[P|ExportedPreds]),_)
;
recorda('$module','$module'(user_input,Mod,[P]),_)
).
export(op(Prio,Assoc,Name)) :- !,
export_resource(op(Prio,Assoc,Name)) :- !,
op(Prio,Assoc,prolog:Name).
export(P) :-
'$do_error'(type_error(predicate_indicator,P),export(P)).
export_resource(Resource) :-
'$do_error'(type_error(predicate_indicator,Resource),export(Resource)).
export_list(Module, List) :-
recorded('$module','$module'(_,Module,List),_).