Skip to content

Commit

Permalink
keep on simplifying modules
Browse files Browse the repository at this point in the history
  • Loading branch information
vscosta committed Mar 5, 2016
1 parent 2fe198f commit fdcc75d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pl/boot.yap
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ bootstrap(F) :-
!,
'$yap_strip_module'(M1:MH,M,H),
( M == M1 -> B = B0 ; B = M1:B0),
error:is_callable(M:H,P).
is_callable(M:H,P).

'$check_head_and_body'(MH, M, H, true, P) :-
'$yap_strip_module'(MH,M,H),
Expand Down
4 changes: 2 additions & 2 deletions pl/consult.yap
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,8 @@ initialization(_G,_OPT) :-
stop_low_level_trace.

'$initialization'(G,OPT) :-
error:must_be_of_type(callable, G, initialization(G,OPT)),
error:must_be_of_type(oneof([after_load, now, restore]),
must_be_of_type(callable, G, initialization(G,OPT)),
must_be_of_type(oneof([after_load, now, restore]),
OPT, initialization(G,OPT)),
(
OPT == now
Expand Down
12 changes: 8 additions & 4 deletions pl/newmod.yap
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,24 @@ to other modules; they can, however, be accessed by prefixing the module
name with the `:/2` operator.
**/
'$module_dec'(system(N, Ss), Ps) :- !,
new_system_module(N),
'$mk_system_predicates'( Ss , N ),
'$module_dec'(N, Ps).
'$module_dec'(system(N), Ps) :- !,
new_system_module(N),
recordz('$system_initialization', prolog:'$mk_system_predicates'( Ps , N ), _),
'$current_module'(_,N).
% '$mk_system_predicates'( Ps , N ),
'$module_dec'(N, Ps).
'$module_dec'(N, Ps) :-
source_location(F,_Line),
source_location(F,_Line),
'$nb_getval'( '$user_source_file', F0 , fail),
'$add_module_on_file'(N, F, F0, Ps),
'$current_module'(_,N).

'$mk_system_predicates'( Ps, N ) :-
lists:member(Name/A , Ps),
functor(P,Name,A),
'$mk_system_predicate'(P, N),
'$new_system_predicate'(P, prolog),
fail.
'$mk_system_predicates'( _Ps, _N ).

Expand Down
11 changes: 10 additions & 1 deletion pl/protect.yap
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@
% This protects all code from further changes
% and also makes it impossible from some predicates to be seen
'$protect' :-
'$current_predicate'(Name,M,P,_),
'$current_predicate'(Name,prolog,P,_),
M \= user,
functor(P,Name,Arity),
'$new_system_predicate'(Name,Arity,M),
sub_atom(Name,0,1,_, '$'),
functor(P,Name,Arity),
'$hide_predicate'(P,M),
fail.
'$protect' :-
'$system_module'(M),
'$current_predicate'(Name,M,P,_),
M \= user,
functor(P,Name,Arity),
'$new_system_predicate'(Name,Arity,M),
fail.
'$protect' :-
current_atom(Name),
Expand Down

0 comments on commit fdcc75d

Please sign in to comment.