This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/pl/protect.yap

96 lines
2.9 KiB
Plaintext
Raw Normal View History

2019-02-27 04:23:21 +00:00
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: protect.yap *
* Last rev: *
* mods: *
* comments: protecting the system functions *
* *
*************************************************************************/
2018-06-05 20:51:49 +01:00
/**
* @file protect.yap
*/
2014-04-09 12:39:29 +01:00
:- system_module( '$_protect', [], ['$protect'/0]).
2018-06-05 20:51:49 +01:00
/**
2018-06-05 20:51:49 +01:00
* * @addtogroup ProtectCore Freeze System Configuration
* @{
2017-10-27 13:50:40 +01:00
* @ingroup YAPControl
*
* This protects current code from further changes
* and also makes it impossible for some predicates to be seen
* in user-space.
*
* Algorithm:
* - fix system modules
* - fix system predicates
* - hide atoms with `$`
*/
2018-06-05 20:51:49 +01:00
2014-04-09 12:39:29 +01:00
2018-07-13 12:27:58 +01:00
prolog:'$protect' :-
'$all_current_modules'(M),
( sub_atom(M,0,1,_, '$') ; M= prolog; M= system ),
2018-06-05 20:51:49 +01:00
new_system_module( M ),
2016-03-05 12:36:54 +00:00
fail.
2018-07-13 12:27:58 +01:00
prolog:'$protect' :-
2019-01-30 10:44:28 +00:00
'$current_predicate'(Name,M,P,_),
'$is_system_module'(M),
2016-03-05 12:36:54 +00:00
functor(P,Name,Arity),
'$new_system_predicate'(Name,Arity,M),
sub_atom(Name,0,1,_, '$'),
functor(P,Name,Arity),
2018-10-18 22:00:27 +01:00
'$stash_predicate'(P,M),
% '$hide_predicate'(P,M),
2016-01-03 02:06:09 +00:00
fail.
2018-07-13 12:27:58 +01:00
prolog:'$protect' :-
current_atom(Name),
2018-04-27 13:01:08 +01:00
sub_atom(Name,0,1,_, '$'),
\+ '$visible'(Name),
hide_atom(Name),
2016-01-03 02:06:09 +00:00
fail.
2019-02-27 04:23:21 +00:00
prolog:'$protect' :-
recorded('$module','$module'(_F,_DonorM,_SourceF, _AllExports, _Line), R),erase(R), fail.
prolog:'$protect' :-
recorded('$source_file','$source_file'( _F, _Age, _M), R),erase(R), fail.
prolog:'$protect' :-
recorded('$lf_loaded','$lf_loaded'( _F, _M, _Reconsult, _UserFile, _OldF, _Line, _Opts), R),erase(R), fail.
prolog:'$protect'.
2019-02-27 04:23:21 +00:00
/*
% hide all atoms who start by '$'
'$visible'('$'). /* not $VAR */
'$visible'('$VAR'). /* not $VAR */
'$visible'('$dbref'). /* not stream position */
'$visible'('$stream'). /* not $STREAM */
'$visible'('$stream_position'). /* not stream position */
2016-01-08 03:18:36 +00:00
'$visible'('$hacks').
'$visible'('$source_location').
'$visible'('$messages').
'$visible'('$push_input_context').
'$visible'('$pop_input_context').
'$visible'('$set_source_module').
'$visible'('$declare_module').
'$visible'('$store_clause').
'$visible'('$skip_list').
'$visible'('$win_insert_menu_item').
'$visible'('$set_predicate_attribute').
'$visible'('$parse_quasi_quotations').
'$visible'('$quasi_quotation').
'$visible'('$qq_open').
'$visible'('$live').
'$visible'('$init_prolog').
2018-09-26 01:16:07 +01:00
'$visible'('$x_yap_flag' ).
2018-06-05 20:51:49 +01:00
%% @}
2019-01-30 10:44:28 +00:00