34
35:- module(assrt_meta, []). 36
37:- use_module(library(lists)). 38:- use_module(library(assertions)). 39:- use_module(library(assertions_op)). 40:- use_module(library(location_utils)). 41:- use_module(library(predicate_from)). 42:- use_module(library(globprops)). 43:- init_expansors. 44
45:- create_prolog_flag(assrt_meta_pred, none, [type(atom)]). 46
47:- meta_predicate
48 with_amp(0, +, +). 49
50:- table
51 am_head_prop_idx/5. 52
53meta_has_mode_info(Meta) :-
54 arg(_, Meta, Spec),
55 memberchk(Spec, [+,-]),
56 !.
57
58with_amp(Goal, OldFlag, NewFlag) :-
59 setup_call_cleanup(
60 set_prolog_flag(assrt_meta_pred, NewFlag),
61 Goal,
62 set_prolog_flag(assrt_meta_pred, OldFlag)).
63
64am_head_prop_idx(Head, M, Meta, From) :-
65 current_prolog_flag(assrt_meta_pred, Flag),
66 Flag \= none,
67 copy_term_nat(Head, Term),
68 with_amp(am_head_prop_idx(Flag, Term, M, Meta, From), Flag, none),
69 Head = Term.
70
71black_list_module(rtchecks_rt).
72black_list_module(ctrtchecks).
73black_list_module(qualify_meta_goal).
74black_list_module(assertions).
75
76am_head_prop_idx(Flag, Head, M, Meta, From) :-
77 var(Meta),
78 !,
79 Pred = M:Head,
80 ( var(Head)
81 ->module_property(M, class(user)),
82 current_predicate(M:F/A),
83 functor(Head, F, A)
84 ; functor(Head, F, A),
85 current_predicate(M:F/A), 86 module_property(M, class(user))
87 ),
88 \+ black_list_module(M),
89 predicate_property(Pred, implementation_module(M)),
90 91 \+ predicate_property(Pred, nodebug),
92 '$predicate_property'(meta_predicate(Meta), Pred),
93 94 meta_has_mode_info(Meta),
95 ( Flag = all
96 ->
97 \+ ( prop_asr(Head, M, check, _, _, _, Asr),
98 prop_asr(glob, no_meta_modes(_), _, Asr)
99 )
100 ; Flag = specific
101 ->once(( prop_asr(Head, M, check, _, _, _, Asr),
102 prop_asr(glob, meta_modes(_), _, Asr)
103 ))
104 ),
105 findall(From1,
106 once(( property_from(M:Pred, meta_predicate, From1)
107 ; predicate_from(Pred, From1)
108 )), [From]).
109am_head_prop_idx(_, _, _, _, _).
110
111assertions:asr_head_prop(am_asr(M, H, S, F), M, H, check, (comp), [], M, F) :-
112 am_head_prop_idx(H, M, S, F).
113assertions:asr_glob(am_asr(M, H, S, F), assrt_meta,
114 check_call(rt, [am_asr2(M, H, S, F)], _), F) :-
115 am_head_prop_idx(H, M, S, F).
116
117assertions:asr_aprop(am_asr2(M, H, _, From), head, M:H, From).
118assertions:asr_aprop(am_asr2(_, _, _, From), stat, check, From).
119assertions:asr_aprop(am_asr2(_, _, _, From), type, pred, From).
120assertions:asr_aprop(am_asr2(M, H, Meta, From), Type, Prop, From) :-
121 (nonvar(Type) -> memberchk(Type, [call, succ]) ; true),
122 assertions:current_decomposed_assertion(pred