meta
This commit is contained in:
parent
fadf853e96
commit
b02c775915
@ -8,7 +8,6 @@ set(PL_BOOT_SOURCES
|
||||
boot.yap
|
||||
bootlists.yap
|
||||
bootutils.yap
|
||||
builtins.yap
|
||||
callcount.yap
|
||||
checker.yap
|
||||
consult.yap
|
||||
@ -27,7 +26,7 @@ set(PL_BOOT_SOURCES
|
||||
grammar.yap
|
||||
ground.yap
|
||||
hacks.yap
|
||||
imports.yap
|
||||
init.yap
|
||||
listing.yap
|
||||
load_foreign.yap
|
||||
messages.yap
|
||||
@ -52,7 +51,6 @@ set(PL_BOOT_SOURCES
|
||||
swi.yap
|
||||
tabling.yap
|
||||
threads.yap
|
||||
top.yap
|
||||
udi.yap
|
||||
undefined.yap
|
||||
utils.yap
|
||||
@ -61,29 +59,39 @@ set(PL_BOOT_SOURCES
|
||||
|
||||
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
||||
|
||||
if (ANDROID)
|
||||
add_custom_target(STARTUP
|
||||
DEPENDS ${PL_BOOT_SOURCES}
|
||||
)
|
||||
file (INSTALL ${PL_BOOT_SOURCES} DESTINATION ${libpl}/pl)
|
||||
elif(CMAKE_CROSSCOMPILING)
|
||||
add_custom_target(STARTUP ALL SOURCES
|
||||
DEPENDS ${PL_BOOT_SOURCES}
|
||||
)
|
||||
else ()
|
||||
add_custom_target(STARTUP ALL
|
||||
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
)
|
||||
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
COMMAND yap-bin -B${CMAKE_SOURCE_DIR}/pl --output-saved-state=${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
VERBATIM
|
||||
DEPENDS ${PL_BOOT_SOURCES} yap-bin
|
||||
)
|
||||
|
||||
# install(CODE "execute_process(COMMAND ./yap -B
|
||||
# WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR})"
|
||||
# DEPENDS Py4YAP ${PL_BOOT_SOURCES} yap-bin )
|
||||
|
||||
|
||||
install(FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
install(FILES ${PL_BOOT_SOURCES}
|
||||
DESTINATION ${libpl}/pl
|
||||
)
|
||||
install(FILES ../library/ypp.yap
|
||||
DESTINATION ${libpl}/library)
|
||||
# )
|
||||
# if (ANDROID OR CMAKE_CROSSCOMPILING)
|
||||
# add_custom_target(STARTUP
|
||||
# )
|
||||
# else()
|
||||
add_custom_target(STARTUP ALL
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/startup.yss)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/startup.yss
|
||||
COMMAND yap-bin -B${CMAKE_CURRENT_SOURCE_DIR} --output-saved-state=${CMAKE_CURRENT_BINARY_DIR}/startup.yss
|
||||
DEPENDS ${PL_BOOT_SOURCES} yap-bin
|
||||
DESTINATION ${libpl}/library
|
||||
)
|
||||
#else ()
|
||||
#add_custom_target(STARTUP ALL
|
||||
# DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
# )
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/startup.yss DESTINATION ${dlls} )
|
||||
|
||||
|
||||
#endif()
|
||||
|
@ -513,7 +513,7 @@ path(Path) :-
|
||||
'$in_path'(X) :-
|
||||
recorded('$path',Path,_),
|
||||
atom_codes(Path,S),
|
||||
( S = "" -> X = '.' ;
|
||||
( S = [] -> X = '.' ;
|
||||
atom_codes(X,S) ).
|
||||
|
||||
/**
|
||||
|
16
pl/boot.yap
16
pl/boot.yap
@ -120,6 +120,7 @@ print_message(L,E) :-
|
||||
).
|
||||
|
||||
|
||||
|
||||
'$undefp0'([M|G], _Action) :-
|
||||
stream_property( loop_stream, file_name(F)),
|
||||
stream_property( loop_stream, line_number(L)),
|
||||
@ -165,6 +166,9 @@ print_message(L,E) :-
|
||||
% This is the YAP init file
|
||||
% should be consulted first step after booting
|
||||
|
||||
|
||||
:- yap_flag(prolog:unknown, error).
|
||||
|
||||
:- c_compile('top.yap').
|
||||
|
||||
% These are pseudo declarations
|
||||
@ -200,14 +204,17 @@ print_message(L,E) :-
|
||||
|
||||
'$command'(C,VL,Pos,Con) :-
|
||||
current_prolog_flag(strict_iso, true), !, /* strict_iso on */
|
||||
'$execute_command'(C,VL,Pos,Con,_Source).
|
||||
'$yap_strip_module'(C, EM, EG),
|
||||
'$execute_command'(EM,EG,VL,Pos,Con,_Source).
|
||||
'$command'(C,VL,Pos,Con) :-
|
||||
( (Con = top ; var(C) ; C = [_|_]) ->
|
||||
'$execute_command'(C,VL,Pos,Con,C), ! ;
|
||||
'$yap_strip_module'(C, EM, EG),
|
||||
'$execute_command'(EG,EM,VL,Pos,Con,C), ! ;
|
||||
% do term expansion
|
||||
'$expand_term'(C, EC),
|
||||
'$yap_strip_module'(EC, EM, EG),
|
||||
% execute a list of commands
|
||||
'$execute_commands'(EC,VL,Pos,Con,_Source),
|
||||
'$execute_commands'(EG,EM,VL,Pos,Con,_Source),
|
||||
% succeed only if the *original* was at end of file.
|
||||
C == end_of_file
|
||||
).
|
||||
@ -217,8 +224,6 @@ print_message(L,E) :-
|
||||
|
||||
:- '$init_prolog'.
|
||||
|
||||
:- '$all_current_modules'(M), yap_flag(M:unknown, error) ; true.
|
||||
|
||||
:- compile_expressions.
|
||||
|
||||
|
||||
@ -453,4 +458,3 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th
|
||||
:- ensure_loaded('../pl/pathconf.yap').
|
||||
|
||||
:- yap_flag(user:unknown,error).
|
||||
|
||||
|
@ -1403,16 +1403,17 @@ Similar to initialization/1, but allows for specifying when
|
||||
Do not execute _Goal_ while loading the program, but only when restoring a state (not implemented yet).
|
||||
|
||||
*/
|
||||
initialization(G0,OPT) :-
|
||||
expand_goal(G0, G),
|
||||
initialization(G,OPT) :-
|
||||
catch('$initialization'(G, OPT), Error, '$LoopError'( Error, consult ) ),
|
||||
fail.
|
||||
initialization(_G,_OPT).
|
||||
|
||||
'$initialization'(G,OPT) :-
|
||||
must_be_of_type(callable, G, initialization(G,OPT)),
|
||||
'$initialization'(G0,OPT) :-
|
||||
must_be_of_type(callable, G0, initialization(G0,OPT)),
|
||||
must_be_of_type(oneof([after_load, now, restore]),
|
||||
OPT, initialization(G,OPT)),
|
||||
OPT, initialization(G0,OPT)),
|
||||
'$yap_strip_module'(G0,M,G1),
|
||||
'$expand_term'((M:G1), G),
|
||||
(
|
||||
OPT == now
|
||||
->
|
||||
@ -1426,7 +1427,7 @@ initialization(_G,_OPT).
|
||||
->
|
||||
recordz('$call_at_restore', G, _ )
|
||||
).
|
||||
:- .
|
||||
|
||||
/**
|
||||
|
||||
@}
|
||||
|
@ -222,8 +222,8 @@ beautify_hidden_goal('$system_catch'(G,Mod,Exc,Handler),prolog) -->
|
||||
[catch(Mod:G, Exc, Handler)].
|
||||
beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
|
||||
[catch(G, Exc, Handler)].
|
||||
beautify_hidden_goal('$execute_command'(Query,V,P,Option,Source),prolog) -->
|
||||
[toplevel_query(Query, V, P, Option, Source)].
|
||||
beautify_hidden_goal('$execute_command'(Query,M,V,P,Option,Source),prolog) -->
|
||||
[toplevel_query(M:Query, V, P, Option, Source)].
|
||||
beautify_hidden_goal('$process_directive'(Gs,_Mode,_VL),prolog) -->
|
||||
[(:- Gs)].
|
||||
beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
|
||||
|
58
pl/top.yap
58
pl/top.yap
@ -117,7 +117,7 @@ live :- '$live'.
|
||||
throw(E).
|
||||
|
||||
|
||||
/** @pred stream_property( _Stream_, _Prop_)
|
||||
/** @pred stream_property( Stream, Prop )
|
||||
|
||||
*/
|
||||
|
||||
@ -161,7 +161,7 @@ current_prolog_flag(break_level, BreakLevel),
|
||||
eraseall('$$set'),
|
||||
eraseall('$$one'),
|
||||
eraseall('$reconsulted'), fail.
|
||||
'$erase_sets' :- \+ recorded('$path',_,_), recorda('$path',"",_).
|
||||
'$erase_sets' :- \+ recorded('$path',_,_), recorda('$path',[],_).
|
||||
'$erase_sets'.
|
||||
|
||||
'$start_corouts' :-
|
||||
@ -176,59 +176,59 @@ current_prolog_flag(break_level, BreakLevel),
|
||||
%
|
||||
% Hack in case expand_term has created a list of commands.
|
||||
%
|
||||
'$execute_commands'(V,_,_,_,Source) :- var(V), !,
|
||||
'$execute_commands'(V,_,_,_,_,Source) :- var(V), !,
|
||||
'$do_error'(instantiation_error,meta_call(Source)).
|
||||
'$execute_commands'([],_,_,_,_) :- !.
|
||||
'$execute_commands'([C|Cs],VL,Pos,Con,Source) :-
|
||||
'$execute_commands'([],_,_,_,_,_) :- !.
|
||||
'$execute_commands'([C|Cs],M,VL,Pos,Con,Source) :-
|
||||
!,
|
||||
(
|
||||
'$system_catch'('$execute_command'(C,VL,Pos,Con,Source),prolog,Error,'$LoopError'(Error, Con)),
|
||||
'$system_catch'('$execute_command'(C,M,VL,Pos,Con,Source),prolog,Error,'$LoopError'(Error, Con)),
|
||||
fail
|
||||
;
|
||||
'$execute_commands'(Cs,VL,Pos,Con,Source)
|
||||
'$execute_commands'(Cs,M,VL,Pos,Con,Source)
|
||||
).
|
||||
'$execute_commands'(C,VL,Pos,Con,Source) :-
|
||||
'$execute_command'(C,VL,Pos,Con,Source).
|
||||
'$execute_commands'(C,M,VL,Pos,Con,Source) :-
|
||||
'$execute_command'(C,M,VL,Pos,Con,Source).
|
||||
|
||||
%
|
||||
%
|
||||
%
|
||||
|
||||
'$execute_command'(C,_,_,top,Source) :-
|
||||
'$execute_command'(C,_,_,_,_,Source) :-
|
||||
var(C),
|
||||
!,
|
||||
'$do_error'(instantiation_error,meta_call(Source)).
|
||||
'$execute_command'(C,_,_,top,Source) :-
|
||||
'$execute_command'(C,_,_,_,_top,Source) :-
|
||||
number(C),
|
||||
!,
|
||||
'$do_error'(type_error(callable,C),meta_call(Source)).
|
||||
'$execute_command'(R,_,_,top,Source) :-
|
||||
'$execute_command'(R,_,_,_,_top,Source) :-
|
||||
db_reference(R),
|
||||
!,
|
||||
'$do_error'(type_error(callable,R),meta_call(Source)).
|
||||
'$execute_command'(end_of_file,_,_,_,_) :- !.
|
||||
'$execute_command'(Command,_,_,_,_) :-
|
||||
'$execute_command'(end_of_file,_,_,_,_,_) :- !.
|
||||
'$execute_command'(Command,_,_,_,_,_) :-
|
||||
'__NB_getval__'('$if_skip_mode', skip, fail),
|
||||
\+ '$if_directive'(Command),
|
||||
!.
|
||||
'$execute_command'((:-G),VL,Pos,Option,_) :-
|
||||
'$execute_command'((:-G),M,VL,Pos,Option,_) :-
|
||||
Option \= top,
|
||||
!, % allow user expansion
|
||||
'$expand_term'((:- G), O),
|
||||
'$expand_term'((:- M:G), O),
|
||||
'$yap_strip_module'(O, NM, NO),
|
||||
(
|
||||
O = (:- G1)
|
||||
NO = (:- G1)
|
||||
->
|
||||
'$yap_strip_module'(G1, M, NG),
|
||||
'$process_directive'(NG, Option, M, VL, Pos)
|
||||
'$process_directive'(G1, Option, NM, VL, Pos)
|
||||
;
|
||||
'$execute_commands'(G1,VL,Pos,Option,O)
|
||||
'$execute_commands'(G1,NM,VL,Pos,Option,O)
|
||||
).
|
||||
'$execute_command'((?-G), VL, Pos, Option, Source) :-
|
||||
'$execute_command'((?-G), M, VL, Pos, Option, Source) :-
|
||||
Option \= top,
|
||||
!,
|
||||
'$execute_command'(G, VL, Pos, top, Source).
|
||||
'$execute_command'(G, VL, Pos, Option, Source) :-
|
||||
'$continue_with_command'(Option, VL, Pos, G, Source).
|
||||
'$execute_command'(G, M, VL, Pos, top, Source).
|
||||
'$execute_command'(G, M, VL, Pos, Option, Source) :-
|
||||
'$continue_with_command'(Option, VL, Pos, M:G, Source).
|
||||
|
||||
'$expand_term'(T,O) :-
|
||||
catch( '$expand_term0'(T,O), _,( '$disable_debugging', fail) ),
|
||||
@ -241,9 +241,7 @@ current_prolog_flag(break_level, BreakLevel),
|
||||
'$expand_term0'(T,T).
|
||||
|
||||
'$expand_term1'(T,O) :-
|
||||
'$yap_strip_module'(T1, M, G2),
|
||||
'$is_metapredicate'(G2,M),
|
||||
'$expand_meta_call'(M:G2, [], O),
|
||||
'$expand_meta_call'(T, [], O),
|
||||
!.
|
||||
'$expand_term1'(O,O).
|
||||
|
||||
@ -680,8 +678,10 @@ write_query_answer( Bindings ) :-
|
||||
|
||||
'$call'(M:_,_,G0,_) :- var(M), !,
|
||||
'$do_error'(instantiation_error,call(G0)).
|
||||
'$call'(M:G,CP,G0,_) :- !,
|
||||
'$call'(G,CP,G0,M).
|
||||
'$call'(M:G,CP,G0,_M0) :- !,
|
||||
'$expand_meta_call'(M:G, [], NG),
|
||||
'$yap_strip_module'(NG,NM,NC),
|
||||
'$call'(NC,CP,G0,NM).
|
||||
'$call'((X,Y),CP,G0,M) :- !,
|
||||
'$call'(X,CP,G0,M),
|
||||
'$call'(Y,CP,G0,M).
|
||||
|
Reference in New Issue
Block a user