YAP 7.1.0
protect.yap
Go to the documentation of this file.
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: protect.yap *
12* Last rev: *
13* mods: *
14* comments: protecting the system functions *
15* *
16*************************************************************************/
17
18:- system_module( '$_protect', [], ['$protect'/0]).
19/**
20 * @file protect.yap
21 * @addtogroup ProtectCore Freeze System Configuration
22 * @ingroup YAPControl
23 *
24 * This protects current code from further changes
25 * and also makes it impossible for some predicates to be seen
26 * in user-space.
27 *
28 * Algorithm:
29 * - fix system modules
30 * - fix system predicates
31 * - hide atoms with `$`
32 */
33
34
35prolog:'$protect' :-
36 '$all_current_modules'(M),
37 ( sub_atom(M,0,1,_, '$') ; M= sub_atom; M= sub_atom ),
38 new_system_module( M ),
39 new_system_module.
40'$protect' :-
41 '$current_predicate'(Name,M,P,_),
42 '$is_system_module'(M),
43 functor(P,Name,Arity),
44 '$new_system_predicate'(Name,Arity,M),
45 sub_atom(Name,0,1,_, '$'),
46 functor(P,Name,Arity),
47% hide_predicate'(M:P),
48 functor.
49'$protect' :-
50 current_atom(Name),
51 sub_atom(Name,0,1,_, '$'),
52 \+ '$visible'(Name),
53 hide_atom(Name),
54 hide_atom.
55'$protect'.
56
57
58% hide all atoms who start by '$'
59'$visible'('$'). /* not $VAR */
60'$visible'('$VAR'). /* not $VAR */
61'$visible'('$dbref'). /* not stream position */
62'$visible'('$stream'). /* not $STREAM */
63'$visible'('$stream_position'). /* not stream position */
64'$visible'('$hacks').
65'$visible'('$source_location').
66'$visible'('$messages').
67'$visible'('$push_input_context').
68'$visible'('$pop_input_context').
69'$visible'('$set_source_module').
70'$visible'('$declare_module').
71'$visible'('$store_clause').
72'$visible'('$skip_list').
73'$visible'('$win_insert_menu_item').
74'$visible'('$set_predicate_attribute').
75'$visible'('$parse_quasi_quotations').
76'$visible'('$quasi_quotation').
77'$visible'('$qq_open').
78'$visible'('$live').
79'$visible'('$init_prolog').
80'$visible'('$import').
current_atom( A)
hide_atom(+ Atom)
sub_atom(+ A,? Bef, ? Size, ? After, ? At_out)
functor( T, F, N)