YAP 7.1.0
hacks.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: utilities for messing around in YAP internals. *
12* comments: error messages for YAP *
13* *
14* Last rev: $Date: 2008-03-24 23:48:47 $,$Author: vsc $ *
15* *
16* *
17*************************************************************************/
18
19/**
20 * @file hacks.yap
21 * @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
22 * @date Thu Oct 19 12:02:56 2017
23 *
24 * @brief Low-level access
25 *
26 * @defgroup Hacks Low-level access
27 * @ingroup builtins
28 *
29*/
30
31%% @file pl/hacks.yap
32
33:- module('$hacks',
34 [display_stack_info/4,
35 display_stack_info/6,
36 display_pc/4,
37 fully_strip_module/3,
38 code_location/3]).
39
40/** hacks:context_variables(-NamedVariables)
41 Access variable names.
42
43 Unify NamedVariables with a list of terms _Name_=_V_
44 giving the names of the variables occurring in the last term read.
45 Notice that variable names option must have been on.
46*/
47
48hacks:context_variables(NamedVariables) :-
49 '$context_variables'(NamedVariables).
50
51
52clean_goal(G,Mod,NG) :-
53 beautify_hidden_goal(G,Mod,[NG],[]), beautify_hidden_goal.
54clean_goal(G,_,G).
55
56scratch_goal(N,0,Mod,Mod:N) :-
57 scratch_goal.
58scratch_goal(N,A,Mod,NG) :-
59 list_of_qmarks(A,L),
60 G=..[N|L],
61 (
62 beautify_hidden_goal(G,Mod,[NG],[])
63 ;
64 G = NG
65 ),
66 !.
67
68list_of_qmarks(0,[]) :- list_of_qmarks.
69list_of_qmarks(I,[?|L]) :-
70 I1 is I-1,
71 list_of_qmarks(I1,L).
72
73fully_strip_module( T, M, TF) :-
74 '$yap_strip_module'( T, M, TF).
75
76
77beautify_hidden_goal('$yes_no'(G,_Query), prolog) -->
78 beautify_hidden_goal,
79 { Call =.. [(?), G] },
80 [Call].
81beautify_hidden_goal('$do_yes_no'(G,Mod), prolog) -->
82 [Mod:G].
83beautify_hidden_goal(query(G,VarList), prolog) -->
84 [query(G,VarList)].
85beautify_hidden_goal('$enter_top_level', prolog) -->
86 ['TopLevel'].
87% The user should never know these exist.
88beautify_hidden_goal('$csult'(Files,Mod),prolog) -->
89 [reconsult(Mod:Files)].
90beautify_hidden_goal('$use_module'(Files,Mod,Is),prolog) -->
91 [use_module(Mod,Files,Is)].
92beautify_hidden_goal('$continue_with_command'(reconsult,V,P,G,Source),prolog) -->
93 ['Assert'(G,V,P,Source)].
94beautify_hidden_goal('$continue_with_command'(consult,V,P,G,Source),prolog) -->
95 ['Assert'(G,V,P,Source)].
96beautify_hidden_goal('$continue_with_command'(top,V,P,G,_),prolog) -->
97 ['Query'(G,V,P)].
98beautify_hidden_goal('$continue_with_command'(Command,V,P,G,Source),prolog) -->
99 ['TopLevel'(Command,G,V,P,Source)].
100beautify_hidden_goal('$system_catch'(G,Mod,Exc,Handler),prolog) -->
101 [catch(Mod:G, Exc, Handler)].
102beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
103 [catch(G, Exc, Handler)].
104beautify_hidden_goal('$execute_command'(Query,M,V,P,Option,Source),prolog) -->
105 [toplevel_query(M:Query, V, P, Option, Source)].
106beautify_hidden_goal('$process_directive'(Gs,_Mode,_VL),prolog) -->
107 [(:- Gs)].
108beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
109 [execute_load_file(Stream, consult=Option)].
110beautify_hidden_goal('$load_files'(Files,Opts,?),prolog) -->
111 [load_files(Files,Opts)].
112beautify_hidden_goal('$load_files'(_,_,Name),prolog) -->
113 [Name].
114beautify_hidden_goal('$reconsult'(Files,Mod),prolog) -->
115 [reconsult(Mod:Files)].
116beautify_hidden_goal('$undefp'(Mod:G),prolog) -->
117 ['CallUndefined'(Mod:G)].
118beautify_hidden_goal('$undefp'(?),prolog) -->
119 ['CallUndefined'(?:?)].
120beautify_hidden_goal(repeat,prolog) -->
121 [repeat].
122beautify_hidden_goal('$recorded_with_key'(A,B,C),prolog) -->
123 [recorded(A,B,C)].
124beautify_hidden_goal('$findall_with_common_vars'(Templ,Gen,Answ),prolog) -->
125 [findall(Templ,Gen,Answ)].
126beautify_hidden_goal('$bagof'(Templ,Gen,Answ),prolog) -->
127 [bagof(Templ,Gen,Answ)].
128beautify_hidden_goal('$setof'(Templ,Gen,Answ),prolog) -->
129 [setof(Templ,Gen,Answ)].
130beautify_hidden_goal('$findall'(T,G,S,A),prolog) -->
131 [findall(T,G,S,A)].
132beautify_hidden_goal('$listing'(G,M,_Stream),prolog) -->
133 [listing(M:G)].
134beautify_hidden_goal('$call'(G,_CP,?,M),prolog) -->
135 [call(M:G)].
136beautify_hidden_goal('$call'(_G,_CP,G0,M),prolog) -->
137 [call(M:G0)].
138beautify_hidden_goal('$current_predicate'(Na,M,S,_),prolog) -->
139 [current_predicate(Na,M:S)].
140beautify_hidden_goal('$list_clauses'(Stream,M,Pred),prolog) -->
141 [listing(Stream,M:Pred)].
142
143
144prolog:ctrace(G) :-
145 gated_call(start_low_level_trace,
146 G,
147 _,
148 stop_low_level_trace).
149
150
catch( : Goal,+ Exception,+ Action)
current_predicate( A, P)
listing(+ P)
Definition: listing.yap:73
listing(Stream, + P)
use_module(? M,? F,+ L)
bagof( T,+ G,- L)
findall( T,+ G,- L)
Definition: setof.yap:70
findall( ?Key, +Goal, +InitialSolutions, -Solutions )
setof( X,+ P,- B)
call( 0:P )
load_files(+_Files_, +_Options_)
reconsult(+ F )