6 current_source_module(
Module,
Module),
11 format(user_error,
'[~w]~n', [
Module])
13 '$system_catch'(
'$enter_top_level',
Module,
Error,
'$Error'(
Error)).
18'$read_toplevel'(
Goal,
Bindings,
Pos)
:-
20 catch(read_term(user_input,
22 [variable_names(
Bindings), syntax_errors(dec10), term_position(
Pos)]),
36 '$clean_up_dead_clauses',
40 '$set_debugger_state'(debug,
DebugOK),
41 '$set_debugger_state'.
43 get_value(
'$top_level_goal',
GA),
GA \= [],
,
49 '$run_toplevel_hooks',
51 '$read_toplevel'(
Command,
Varnames,
Pos),
54 '$init_debugger_trace',
55 '$command'(
Command,
Varnames,
Pos,top),
62 '$pred_exists'(halt(
_), user)
84 recordz(
'$corout',
'$corout'(main,main,
'$corout'([],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[])),
_Ref),
90'$execute_commands'(
V,
_,
_,
_,
_,
_)
:- var(
V),
'$error'(instantiation_error).
91'$execute_commands'([],
_,
_,
_,
_,
_)
:- '$execute_commands'.
92'$execute_commands'([
C|Cs],
M,
VL,
Pos,
Con,
Source)
:-
95 '$system_catch'(
'$execute_command'(
C,
M,
VL,
Pos,
Con,
Source),prolog,
Error,
'$LoopError'(
Error,
Con)),
98 '$execute_commands'(
Cs,
M,
VL,
Pos,
Con,
Source)
100'$execute_commands'(
C,
M,
VL,
Pos,
Con,
Source)
:-
102 '$system_catch'(
'$execute_command'(
C,
M,
VL,
Pos,
Con,
Source),prolog,
Error,
'$LoopError'(
Error,
Con)).
108'$execute_command'(end_of_file,
_,
_,
_,
_,
_)
:- '$execute_command'.
109'$execute_command'(
Command,
_,
_,
_,
_,
_)
:-
110 '__NB_getval__'(
'$if_skip_mode', skip, fail),
111 \+ '$if_directive'(
Command),
114'$execute_command'((
:-G),
M,
VL,
Pos,
Option,
_)
:-
116 '$expand_term'((
:- M:G),
O),
117 '$yap_strip_module'(
O,
NM,
NO),
122 '$process_directive'(
G1,
Option,
NM,
VL,
Pos)
124 '$execute_commands'(
G1,
NM,
VL,
Pos,
Option,
O)
127'$execute_command'((
?-G),
M,
VL,
Pos, top,
Source)
:-
129 '$execute_command'(
G,
M,
VL,
Pos, top,
Source).
130'$execute_command'(
G,
M,
VL,
Pos,
Option,
Source)
:-
131 '$continue_with_command'(
Option,
VL,
Pos,
M:G,
Source).
133'$expand_term'(
T,
O)
:-
134 '$expand_term'(
T,top,
O).
136'$expand_term'(
T,
Con,
O)
:-
137 catch(
'$expand_term0'(
T,
Con,
O),
_,(
'$disable_debugging', fail) ),
140'$expand_term0'(
T,consult,
O)
:-
142'$expand_term0'(
T,reconsult,
O)
:-
144'$expand_term0'(
T,top,
O)
:-
147 '$expand_term1'(
T1,
O).
148'$expand_term0'(
T,
_,
T).
150'$expand_term1'(
T,
O)
:-
155'$continue_with_command'(consult,
V,
Pos,
G,
Source)
:-
156 '$go_compile_clause'(
G,
V,
Pos,consult,
Source),
157 '$go_compile_clause',
158 '$go_compile_clause'.
159'$continue_with_command'(reconsult,
V,
Pos,
G,
Source)
:-
160 '$go_compile_clause'(
G,
V,
Pos,reconsult,
Source),
161 '$go_compile_clause',
162 '$go_compile_clause'.
163'$continue_with_command'(top,
Names,
_,
G,
_)
:-
164 prolog_flag(prompt_alternatives_on,
OPT),
166 query_to_answer(
G,
Names,
Port,
GVs,
LGs)
168 '$another'(
Names,
GVs,
LGs,
Port,
OPT)
189'$go_compile_clause'(
G,
_Vs,
_Pos,
Where,
Source)
:-
190 '$precompile_term'(
G,
Source,
G1),
192 '$$compile'(
G1,
Where,
Source,
_).
193'$go_compile_clause'(
G,
_Vs,
_Pos,
_Where,
_Source)
:-
194 throw(error(system, compilation_failed(
G))).
196'$$compile'(
C,
Where,
C0,
R)
:-
197 '$head_and_body'(
C,
MH,
B ),
198 strip_module(
MH,
Mod,
H),
202 '$init_pred'(
H,
Mod,
Where)
207 '$compile'((
H:-B),
Where,
C0,
Mod,
R).
209'$init_pred'(
H,
Mod,
_Where )
:-
210 recorded(
'$import',
'$import'(
NM,
Mod,
NH,
H,
_,
_),
RI),
218'$init_pred'(
H,
Mod,
Where )
:-
219 '$init_as_dynamic'(
Where),
222 '$dynamic'(
Na/Ar,
Mod).
223'$init_pred'(
_H,
_Mod,
_Where ).
225'$init_as_dynamic'( asserta ).
226'$init_as_dynamic'( assertz ).
227'$init_as_dynamic'( consult )
:-
228 '__NB_getval__'(
'$assert_all',on,fail).
229'$init_as_dynamic'( reconsult )
:-
230 '__NB_getval__'(
'$assert_all',on,fail).
232'$check_if_reconsulted'(
N,
A)
:-
233 once(recorded(
'$reconsulted',
N/A,
_)),
240'$inform_as_reconsulted'(
N,
A)
:-
243'$clear_reconsulting' :-
250'$prompt_alternatives_on'(determinism).
256query_to_answer(end_of_file,
_,exit,[],[])
:-
258query_to_answer(
G,
Vs,
Port,
GVs,
LGs)
:-
260 '$query'
:delayed_goals(
G,
Vs,
GVs,
LGs).
263 '$query'(
G,[],
_Port).
266'$query'(
G,
_Vs,
Port)
:-
267 prolog_flag(debug,true),
268 '$get_debugger_state'(trace,on),
269 '$get_debugger_state'(creep,
Creep),
270 Creep \= '$get_debugger_state',
271 '$get_debugger_state',
291'$another'([],
_,
_,
_,
_)
:-
294'$another'(
Names,
GVs,
LGs, exit, determinism)
:-
298'$another'(
_,
_,
_, fail,
_)
:-
301'$another'(
Names,
GVs,
LGs,
_,
_)
:-
303 '$clear_input'(user_input),
315 '$add_nl_outside_console'
321'$add_nl_outside_console' :-
322 format(user_error,
'~n',[]).
324'$ask_again_for_another' :-
325 prompt(
_Old,
'Action (\";\" for more choices, <return> for exit)', []),
335'$disable_debugging_on_port'(retry)
:-
336 '$disable_debugging_on_port',
338 '$set_debugger_state'(debug, true).
339'$disable_debugging_on_port'(
_Port)
:-
340 '$set_debugger_state'(debug, false).
346 prolog_flag(debug, false),
prolog_flag.
347'$enable_debugging' :-
348 '$get_debugger_state'(trace,on),
349 '$get_debugger_state',
350 '$set_debugger_state'(creep,
0, stop, on, true),
352'$enable_debugging' :-
353 '$set_debugger_state'(zip,
0, stop, on, true).
356 '$get_debugger_state'(debug, true),
357 '$set_debugger_state'(trace, on).
363 '$get_debugger_state'(debug, true),
364 '$set_debugger_state'(trace, off).
370'$call'(
G,
CP,
G0,
_,
M)
:-
371 '$iso_check_goal'(
G,
G0),
372 '$call'(
G,
CP,
G0,
M).
375'$call'(
M:_,
_,
G0,
_)
:- var(
M),
var,
376 '$do_error'(instantiation_error,call(
G0)).
378'$call'(
M:G,
CP,
G0,
_M0)
:- '$call',
379 '$yap_strip_module'(
M:G,
NM,
NC),
380 '$call'(
NC,
CP,
G0,
NM).
382'$call'(
'$call'(
X,
CP,
_G0,
M),
_,
G0,
_)
:-
385'$call'((
X,
Y),
CP,
G0,
M)
:- '$call',
388'$call'((
X->Y),
CP,
G0,
M)
:- '$call',
396'$call'((
X*->Y),
CP,
G0,
M)
:- '$call',
400'$call'((
X->Y; Z),
CP,
G0,
M)
:- '$call',
409'$call'((
X*->Y; Z),
CP,
G0,
M)
:- '$call',
418'$call'((
A;B),
CP,
G0,
M)
:- '$call',
424'$call'((
X->Y| Z),
CP,
G0,
M)
:- '$call',
433'$call'((
X*->Y| Z),
CP,
G0,
M)
:- '$call',
442'$call'((
A|B),
CP,
G0,
M)
:- '$call',
448'$call'(
\+ X,
_CP,
G0,
M)
:- '$call',
450 '$call'(
X,
CP,
G0,
M) ).
451'$call'(
not(
X),
_CP,
G0,
M)
:- '$call',
453 '$call'(
X,
CP,
G0,
M) ).
454'$call'(!,
CP,
_,
_)
:- '$call',
456'$call'([
A|B],
_,
_,
M)
:- '$call',
458'$call'(
G,
_CP,
_G0,
CurMod)
:-
470 '$execute0'(
G,
CurMod).
473'$check_callable'(
V,
G)
:- var(
V),
var,
474 '$do_error'(instantiation_error,
G).
475'$check_callable'(
M:_G1,
G)
:- var(
M),
var,
476 '$do_error'(instantiation_error,
G).
477'$check_callable'(
_:G1,
G)
:- '$check_callable',
478 '$check_callable'(
G1,
G).
479'$check_callable'(
A,
G)
:- number(
A),
number,
480 '$do_error'(type_error(callable,
A),
G).
482 '$do_error'(type_error(callable,
R),
G).
483'$check_callable'(
_,
_).
485'__$loop_'(
Stream,
Status)
:-
487 '$current_module'(
OldModule,
OldModule ),
488 '$enter_command'(
Stream,
OldModule,
Status),
491'$boot_loop'(
Stream,
Where)
:-
493 '$current_module'(
OldModule,
OldModule ),
494 read_clause(
Stream,
Command, [module(
OldModule), syntax_errors(dec10),variable_names(
Vars), term_position(
_Pos)]),
495 (
Command == end_of_file
499 Command = (
:- Goal)
->
503 Command = (
?- Goal)
->
507 Command = (
H --> B)
->
508 '$system_catch'(
'$boot_dcg'(
H,
B,
Where), prolog,
Error,
509 user
:'$LoopError'(
Error, consult) ),
513 '$system_catch'(
'$boot_clause'(
Command,
Where ), prolog,
Error,
514 user
:'$LoopError'(
Error, consult) ),
518'$boot_execute'(
Goal )
:-
521'$boot_execute'(
Goal )
:-
522 format(user_error,
':- ~w failed.~n', [
Goal]).
524'$boot_dcg'(
H,
B,
Where )
:-
525 '$translate_rule'((
H --> B), (
NH :- NB) ),
526 '$$compile'((
NH :- NB),
Where, (
H --> B),
_R),
528'$boot_dcg'(
H,
B,
_ )
:-
529 format(user_error,
' ~w --> ~w failed.~n', [
H,
B]).
531'$boot_clause'(
Command,
Where )
:-
532 '$$compile'(
Command,
Where,
Command,
_R),
534'$boot_clause'(
Command,
_ )
:-
535 format(user_error,
' ~w failed.~n', [
Command]).
539'$enter_command'(
Stream,
Mod,
Status)
:-
541 Options = [
module(
Mod),
syntax_errors(dec10),
variable_names(
Vars),
term_position(
Pos)],
545 read_term(
Stream,
Command,
Options)
549 '$command'(
Command,
Vars,
Pos,
Status).
564'$head_and_body'((
H:-B),
H,
B)
:- '$head_and_body'.
565'$head_and_body'(
H,
H,true).
568gated_call(
Setup,
Goal,
Catcher,
Cleanup)
:-
569 '$setup_call_catcher_cleanup'(
Setup),
570 '$gated_call'( true ,
Goal,
Catcher,
Cleanup) .
572'$gated_call'(
All ,
Goal,
Catcher,
Cleanup)
:-
573 Task0 = cleanup(
All,
Catcher,
Cleanup,
Tag, true,
CP0),
574 TaskF = cleanup(
All,
Catcher,
Cleanup,
Tag, false,
CP0),
575 '$tag_cleanup'(
CP0,
Task0),
577 '$cleanup_on_exit'(
CP0,
TaskF).
583'$check_head_and_body'(
C,
M,
H,
B,
_P)
:-
584 '$yap_strip_module'(
C,
M1,(
MH:-B0)),
586 '$yap_strip_module'(
M1:MH,
M,
H),
587 (
M == M1 -> B = B0 ; B = M1:B0),
590'$check_head_and_body'(
MH,
M,
H, true,
_P)
:-
591 '$yap_strip_module'(
MH,
M,
H),
598'$precompile_term'(
Term,
ExpandedUser,
Expanded)
:-
600 '$expand_clause'(
Term,
ExpandedUser,
ExpandedI),
606 Expanded = ExpandedI,
607 '$check_iso_strict_clause'(
ExpandedUser)
609 '$expand_array_accesses_in_term'(
ExpandedI,
Expanded)
610 -> '$expand_array_accesses_in_term'
614'$precompile_term'(
Term,
Term,
Term).
616'$expand_clause'(
InputCl,
C1,
CO)
:-
618 '$expand_a_clause'(
InputCl,
SM,
C1,
CO),
620'$expand_clause'(
Cl,
Cl,
Cl).
635 '$do_term_expansion'(
Term,
TermI)
641 '$expand_term_grammar'(
TermI,
Expanded).
647'$expand_term_grammar'((
A-->B),
C)
:-
648 '$expand_term_grammar'
:'$translate_rule'((
A-->B),
C),
'$translate_rule'.
649'$expand_term_grammar'(
A,
A).
654'$expand_array_accesses_in_term'(
Expanded0,
ExpandedF)
:-
655 '$array_refs_compiled',
656 '$arrays':'$c_arrays'(
Expanded0,
ExpandedF),
'$c_arrays'.
657'$expand_array_accesses_in_term'(
Expanded,
Expanded).
685 (
CP0 == CPF -> !
; true ).
687 '$drop_exception'(
E0),
691 '$run_catch'(
E0,
E,
G)
705'$system_catch'(
G,
M,
C,
A)
:-
711'$run_catch'(error(
Event,
_ ),
_,
G)
:-
714 arg(
1,
Event,
Error),
716 '$run_catch'(
Error,
Error,
G).
717'$run_catch'( abort,abort,
_)
:-
719'$run_catch'(
_E,
_E,
G)
:-
723'$run_catch'(error(
A,
B), error(
A,
B),
_)
:-
725 '$LoopError'(error(
A,
B), error).
728'$run_toplevel_hooks' :-
733 (
call(user
:H)
-> call
; call).
734'$run_toplevel_hooks'.
736'$run_at_thread_start' :-
737 recorded(
'$thread_initialization',
M:D,
_),
740'$run_at_thread_start'.
742log_event(
String,
Args )
:-
743 format( atom(
M ),
String,
Args),
753 LF = [
'[Break (level ',
BreakLevel,
')] '|LD]
757 '$get_debugger_state'(trace, on)
769 atomic_concat(
L,
PF),
774'$loop'(
Stream,
Status)
:-
776 '__$loop_'(
Stream,
Status),
785
catch( : Goal,+ Exception,+ Action)
must_be_callable( ?_Goal_ )
read_clause( +Stream, -Clause, ?Opts)
yap_flag( ?Param, ?Value)
nb_setval(+ Name,+ Value)
current_prolog_flag(? Flag,- Value)
set_prolog_flag(+ Flag,+ Value)
print_message(+ Severity, +Term)
current_choice_point( -CP )