diff --git a/pl/attributes.yap b/pl/attributes.yap index 1f5e0f213..b820c6856 100644 --- a/pl/attributes.yap +++ b/pl/attributes.yap @@ -324,7 +324,7 @@ do_continuation(Continuation, Module1) :- execute_continuation(Continuation, Module1) :- '$undefined'(Continuation, Module1), !, '$current_module'( M ), - '$swi_current_prolog_flag'( M:unknown, Default ), + current_prolog_flag( M:unknown, Default ), '$undefp'([Module1|Continuation] , Default ). execute_continuation(Continuation, Mod) :- % do not do meta-expansion nor any fancy stuff. diff --git a/pl/boot.yap b/pl/boot.yap index acbc7d889..9a684c185 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -308,14 +308,14 @@ true :- true. '$init_system'. '$do_live' :- - repeat, - '$current_module'(Module), - ( Module==user -> - '$compile_mode'(_,0) - ; - format(user_error,'[~w]~n', [Module]) - ), - '$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)). + repeat, + '$current_module'(Module), + ( Module==user -> + '$compile_mode'(_,0) + ; + format(user_error,'[~w]~n', [Module]) + ), + '$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)). '$init_system' :- @@ -324,20 +324,14 @@ true :- true. set_value('$yap_inited', true), % do catch as early as possible ( - '$access_yap_flags'(15, 0), - '$access_yap_flags'(22, 0), - \+ '$uncaught_throw' + current_prolog_flag(halt_after_consult, false), + current_prolog_flag(verbose, normal), + \+ '$uncaught_throw' -> '$version' ; true ), - ( - '$access_yap_flags'(22, 0) -> - '$swi_set_prolog_flag'(verbose, normal) - ; - '$swi_set_prolog_flag'(verbose, silent) - ), % '$init_preds', % needs to be done before library_directory % ( % retractall(user:library_directory(_)), @@ -347,17 +341,16 @@ true :- true. % ; % true % ), - '$swi_current_prolog_flag'(file_name_variables, OldF), - '$swi_set_prolog_flag'(file_name_variables, true), + current_prolog_flag(file_name_variables, OldF), + set_prolog_flag(file_name_variables, true), '$init_consult', - '$swi_set_prolog_flag'(file_name_variables, OldF), - '$init_win_graphics', + set_prolog_flag(file_name_variables, OldF), '$init_globals', - '$swi_set_prolog_flag'(fileerrors, true), + set_prolog_flag(fileerrors, true), set_value('$gc',on), ('$exit_undefp' -> true ; true), prompt1(' ?- '), - '$swi_set_prolog_flag'(debug, false), + set_prolog_flag(debug, false), % simple trick to find out if this is we are booting from Prolog. % boot from a saved state ( @@ -369,7 +362,7 @@ true :- true. -> bootstrap(X), module( user ), - qsave_program( "startup.yss") + qsave_program( 'startup.yss') ; true ) @@ -385,7 +378,7 @@ true :- true. '$run_at_thread_start'. '$init_globals' :- - % '$swi_set_prolog_flag'(break_level, 0), + % set_prolog_flag(break_level, 0), % '$set_read_error_handler'(error), let the user do that nb_setval('$chr_toplevel_show_store',false). @@ -433,8 +426,9 @@ true :- true. /* main execution loop */ '$read_toplevel'(Goal, Bindings) :- + fail, '$pred_exists'(read_history(_,_,_,_,_,_), user), - '$swi_current_prolog_flag'(readline, true), !, + current_prolog_flag(readline, true), !, read_history(h, '!h', [trace, end_of_file], Prompt, Goal, Bindings), !, @@ -446,34 +440,24 @@ true :- true. '$read_toplevel'(Goal, Bindings) :- prompt1('?- '), prompt(_,'|: '), - (print_message(error, E), - '$handle_toplevel_error'(Line, E))), - ( - '$pred_exists'(rl_add_history(_), user) - -> - format(atom(CompleteLine), '~W~W', - [ Line, [partial(true)], - '.', [partial(true)] - ]), - user:rl_add_history(CompleteLine) - ; - true - ), - '$system_catch'( - atom_to_term(Line, Goal, Bindings), prolog, E, - ( print_message(error, E), - fail - ) - ), !. + '$system_catch'(read_term(user_input, + Goal, + [variable_names(Bindings)]), + prolog, E, '$handle_toplevel_error'( E) ). -'$handle_toplevel_error'(_, syntax_error(_)) :- +'$handle_toplevel_error'( syntax_error(_)) :- !, fail. -'$handle_toplevel_error'(end_of_file, error(io_error(read,user_input),_)) :- +'$handle_toplevel_error'( error(io_error(read,user_input),_)) :- !. '$handle_toplevel_error'(_, E) :- throw(E). + +/** @pred stream_property( _Stream_, _Prop_) + +*/ + % reset alarms when entering top-level. '$enter_top_level' :- '$alarm'(0, 0, _, _), @@ -482,8 +466,8 @@ true :- true. '$clean_up_dead_clauses', fail. '$enter_top_level' :- - '$swi_current_prolog_flag'(break_level, BreakLevel), - '$swi_current_prolog_flag'(debug, DBON), + current_prolog_flag(break_level, BreakLevel), + current_prolog_flag(debug, DBON), ( '$nb_getval'('$trace', on, fail) -> @@ -501,7 +485,7 @@ true :- true. get_value('$top_level_goal',GA), GA \= [], !, set_value('$top_level_goal',[]), '$run_atom_goal'(GA), - '$swi_current_prolog_flag'(break_level, BreakLevel), + current_prolog_flag(break_level, BreakLevel), ( Breaklevel \= 0 -> @@ -523,7 +507,7 @@ true :- true. nb_setval('$debug_run',off), nb_setval('$debug_jump',off), '$command'(Command,Varnames,_Pos,top), - '$swi_current_prolog_flag'(break_level, BreakLevel), + current_prolog_flag(break_level, BreakLevel), ( BreakLevel \= 0 -> @@ -545,17 +529,13 @@ true :- true. '$erase_sets'. '$version' :- - get_value('$version_name',VersionName), - print_message(help, version(VersionName)), - get_value('$myddas_version_name',MYDDASVersionName), - MYDDASVersionName \== [], - print_message(help, myddas_version(MYDDASVersionName)), - fail. - '$version' :- - recorded('$version',VersionName,_), - print_message(help, VersionName), - fail. - '$version'. + current_prolog_flag(version_git,VersionGit), + current_prolog_flag(compiled_at,AT), + current_prolog_flag(version_data, yap(Mj, Mi, Patch, _) ), + sub_atom( VersionGit, 0, 8, _, VERSIONGIT ), + format(user_error, '% YAP ~d.~d.~d-~a (compiled ~a)~n', [Mj,Mi, Patch, VERSIONGIT, AT]), + fail. +'$version'. /** @pred repeat is iso Succeeds repeatedly. @@ -604,7 +584,7 @@ number of steps. recorda('$result',going,_). '$command'(C,VL,Pos,Con) :- - '$access_yap_flags'(9,1), !, + current_prolog_flag(strict_iso, true), !, /* strict_iso on */ '$execute_command'(C,VL,Pos,Con,C). '$command'(C,VL,Pos,Con) :- ( (Con = top ; var(C) ; C = [_|_]) -> @@ -675,7 +655,7 @@ number of steps. % YAP accepts everything everywhere % '$process_directive'(G, top, M, VL, Pos) :- - '$access_yap_flags'(8, 0), !, % YAP mode, go in and do it, + current_prolog_flag(language_mode, yap), !, /* strict_iso on */ '$process_directive'(G, consult, M, VL, Pos). '$process_directive'(G, top, _, _, _) :- !, '$do_error'(context_error((:- G),clause),query). @@ -694,8 +674,8 @@ number of steps. % % ISO does not allow goals (use initialization). % - '$process_directive'(D, _, M, VL, Pos) :- - '$access_yap_flags'(8, 1), !, % ISO Prolog mode, go in and do it, +'$process_directive'(D, _, M, VL, Pos) :- + current_prolog_flag(language_mode, iso), !, % ISO Prolog mode, go in and do it, '$do_error'(context_error((:- M:D),query),directive). % % but YAP and SICStus does. @@ -718,7 +698,7 @@ number of steps. '$go_compile_clause'(G,V,Pos,5,Source), fail. '$continue_with_command'(consult,V,Pos,G,Source) :- - '$go_compile_clause'(G,V,Pos,13,Source), + '$go_compile_clause'(G,V,Pos,13,Source), fail. '$continue_with_command'(top,V,_,G,_) :- '$query'(G,V). @@ -754,18 +734,16 @@ number of steps. % process an input clause '$$compile'(G, G0, L, Mod) :- '$head_and_body'(G,H,_), - '$flags'(H, Mod, Fl, Fl), - is(NFl, /\, Fl, 0x00002000), ( - NFl \= 0 + '$is_dynamic'(H, Mod) -> - '$assertz_dynamic'(L,G,G0,Mod) + '$assertz_dynamic'(L, G, G0, Mod) ; '$nb_getval'('$assert_all',on,fail) -> functor(H,N,A), '$dynamic'(N/A,Mod), - '$assertz_dynamic'(L,G,G0,Mod) + '$assertz_dynamic'(L, G, G0, Mod) ; '$not_imported'(H, Mod), '$compile'(G, L, G0, Mod) @@ -897,7 +875,7 @@ number of steps. flush_output, fail. '$present_answer'((?-), Answ) :- - '$swi_current_prolog_flag'(break_level, BL ), + current_prolog_flag(break_level, BL ), ( BL \= 0 -> format(user_error, '[~p] ',[BL]) ; true ), ( recorded('$print_options','$toplevel'(Opts),_) -> @@ -1139,7 +1117,7 @@ incore(G) :- '$execute'(G). ). '$enable_debugging' :- - '$swi_current_prolog_flag'(debug, false), !. + current_prolog_flag(debug, false), !. '$enable_debugging' :- '$nb_getval'('$trace', on, fail), !, '$creep'. @@ -1334,12 +1312,12 @@ bootstrap(F) :- % '$open'(F, '$csult', Stream, 0, 0, F), % '$file_name'(Stream,File), open(F, read, Stream), - stream_property(Stream, file_name(File)), + stream_property(Stream, [file_name(File)]), '$start_consult'(consult, File, LC), file_directory_name(File, Dir), working_directory(OldD, Dir), ( - '$swi_current_prolog_flag'(verbose_load, silent) + current_prolog_flag(verbose_load, silent) -> true ; @@ -1351,7 +1329,7 @@ bootstrap(F) :- '$current_module'(_, prolog), '$end_consult', ( - '$swi_current_prolog_flag'(verbose_load, silent) + current_prolog_flag(verbose_load, silent) -> true ; @@ -1388,7 +1366,7 @@ bootstrap(F) :- !. '$enter_command'(Stream,Mod,Status) :- - read_clause(Stream, Command, [variable_names(Vars), term_position(Pos), syntax_errors(dec10) ]), + read_term(Stream, Command, [variable_names(Vars), term_position(Pos), syntax_errors(dec10) ]), '$command'(Command,Vars,Pos,Status). '$abort_loop'(Stream) :- @@ -1426,7 +1404,7 @@ bootstrap(F) :- '$module_expansion'(Term, Expanded0, ExpandedI, HeadMod, BodyMod, SourceMod), !, %format(' -> ~w~n',[Expanded0]), ( - '$access_yap_flags'(9,1) /* strict_iso on */ + current_prolog_flag(strict_iso, true) /* strict_iso on */ -> Expanded = ExpandedI, '$check_iso_strict_clause'(Expanded0) @@ -1571,7 +1549,7 @@ catch_ball(Ball, V) :- catch_ball(C, C). '$run_toplevel_hooks' :- - '$swi_current_prolog_flag'(break_level, 0 ), + current_prolog_flag(break_level, 0 ), recorded('$toplevel_hooks',H,_), H \= fail, !, ( call(user:H1) -> true ; true). diff --git a/pl/consult.yap b/pl/consult.yap index 7bd7ec4ac..e0d163d02 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -214,8 +214,8 @@ load_files(Files,Opts) :- '$lf_option'(silent, 8, _). '$lf_option'(skip_unix_header, 9, true). '$lf_option'(compilation_mode, 10, Flag) :- - '$access_yap_flags'(11,YF), - ( YF == 0 -> Flag = compact ; Flag = source ). + current_prolog_flag(source, YFlag), + ( YFlag == false -> Flag = compact ; Flag = source ). '$lf_option'(consult, 11, reconsult). '$lf_option'(stream, 12, _). '$lf_option'(register, 13, true). @@ -227,7 +227,8 @@ load_files(Files,Opts) :- '$lf_option'('$location', 19, _). '$lf_option'(dialect, 20, yap). '$lf_option'(format, 21, source). -'$lf_option'(redefine_module, 22, false). +'$lf_option'(redefine_module, 22, Warn) :- + ( var(Warn) -> current_prolog_flag( redefine_warnings, Redefine ), Redefine = Warn ; true )). '$lf_option'(reexport, 23, false). '$lf_option'(sandboxed, 24, false). '$lf_option'(scope_settings, 25, false). @@ -436,13 +437,15 @@ load_files(Files,Opts) :- ; stream_property(Stream, file_name(Y)) ), !, - ( '$size_stream'(Stream, Pos) -> true ; Pos = 0), + % start_low_level_trace, + ( file_size(Stream, Pos) -> true ; Pos = 0), '$set_lf_opt'('$source_pos', TOpts, Pos), '$lf_opt'(reexport, TOpts, Reexport), '$lf_opt'(if, TOpts, If), ( var(If) -> If = true ; true ), '$lf_opt'(imports, TOpts, Imports), '$start_lf'(If, Mod, Stream, TOpts, File, Y, Reexport, Imports), +% stop_low_level_trace, close(Stream). '$lf'(X, _, Call, _) :- '$do_error'(permission_error(input,stream,X),Call). @@ -461,6 +464,7 @@ load_files(Files,Opts) :- '$reexport'( TOpts, ParentF, Reexport, Imports, File ). '$start_lf'(_, Mod, PlStream, TOpts, _UserFile, File, Reexport, ImportList) :- % check if there is a qly file +% start_low_level_trace, '$absolute_file_name'(File,[access(read),file_type(qly),file_errors(fail),solutions(first),expand(true)],F,qload_file(File)), open( F, read, Stream , [type(binary)] ), H0 is heapused, '$cputime'(T0,_), @@ -483,6 +487,7 @@ load_files(Files,Opts) :- '$lf_opt'('$location', TOpts, ParentF:_Line), '$reexport'( TOpts, ParentF, Reexport, ImportList, File ), print_message(Verbosity, loaded( loaded, F, M, T, H)), +% stop_low_level_trace, '$exec_initialisation_goals' ; close( Stream), @@ -503,7 +508,7 @@ loaded, otherwise advertises the user about the existing name clashes are not public remain invisible. When the files are not module files, ensure_loaded/1 loads them -if they have not been loaded before, and naes nothing otherwise. +if they have not been loaded before, and does nothing otherwise. _F_ must be a list containing the names of the files to load. */ @@ -543,7 +548,7 @@ consult(Fs) :- '$consult'(Fs, M0). '$consult'(Fs,Module) :- - '$access_yap_flags'(8, 2), % SICStus Prolog compatibility + current_prolog_flag(language_mode, iso), % SICStus Prolog compatibility !, '$load_files'(Module:Fs,[],consult(Fs)). '$consult'(Fs, Module) :- @@ -646,6 +651,9 @@ db_files(Fs) :- '$do_lf'(ContextModule, Stream, UserFile, File, TOpts) :- + stream_property(OldStream, alias(loop_stream) ), + '$lf_opt'(encoding, TOpts, Encoding), + set_stream( Stream, [alias(loop_stream), encoding(Encoding)] ), '$lf_opt'('$context_module', TOpts, ContextModule), '$lf_opt'(reexport, TOpts, Reexport), '$msg_level'( TOpts, Verbosity), @@ -653,8 +661,6 @@ db_files(Fs) :- '$nb_getval'('$qcompile', ContextQCompiling, ContextQCompiling = never), nb_setval('$qcompile', QCompiling), % format( 'I=~w~n', [Verbosity=UserFile] ), - '$lf_opt'(encoding, TOpts, Encoding), - '$set_encoding'(Stream, Encoding), % export to process b_setval('$lf_status', TOpts), '$reset_if'(OldIfLevel), @@ -666,8 +672,7 @@ db_files(Fs) :- '$loaded'(File, UserFile, SourceModule, ParentF, Line, Reconsult0, Reconsult, Dir, Opts), working_directory(OldD, Dir), H0 is heapused, '$cputime'(T0,_), - '$set_current_loop_stream'(OldStream, Stream), - '$swi_current_prolog_flag'(generate_debug_info, GenerateDebug), + current_prolog_flag(generate_debug_info, GenerateDebug), '$lf_opt'(compilation_mode, TOpts, CompMode), '$comp_mode'(OldCompMode, CompMode), recorda('$initialisation','$',_), @@ -705,8 +710,8 @@ db_files(Fs) :- ; true ), - '$set_current_loop_stream'(Stream, OldStream), - '$swi_set_prolog_flag'(generate_debug_info, GenerateDebug), + set_stream( OldStream, alias(loop_stream) ), + set_prolog_flag(generate_debug_info, GenerateDebug), '$comp_mode'(_CompMode, OldCompMode), working_directory(_,OldD), % surely, we were in run mode or we would not have included the file! @@ -735,13 +740,13 @@ db_files(Fs) :- '$msg_level'( TOpts, Verbosity) :- '$lf_opt'(autoload, TOpts, AutoLoad), AutoLoad == true, - '$swi_current_prolog_flag'(verbose_autoload, false), !, + current_prolog_flag(verbose_autoload, false), !, Verbosity = silent. '$msg_level'( _TOpts, Verbosity) :- - '$swi_current_prolog_flag'(verbose_load, false), !, + current_prolog_flag(verbose_load, false), !, Verbosity = silent. '$msg_level'( _TOpts, Verbosity) :- - '$swi_current_prolog_flag'(verbose, silent), !, + current_prolog_flag(verbose, silent), !, Verbosity = silent. '$msg_level'( TOpts, Verbosity) :- '$lf_opt'(silent, TOpts, Silent), @@ -845,17 +850,16 @@ db_files(Fs) :- true ; '$do_error'(permission_error(input,stream,Y),include(X)) ), - '$set_current_loop_stream'(OldStream, Stream), H0 is heapused, '$cputime'(T0,_), working_directory(Dir, Dir), + '$lf_opt'(encoding, TOpts, Encoding), + set_stream(Stream, [encoding(Encoding),alias(loop_stream)] ), '$loaded'(Y, X, Mod, OldY, L, include, _, Dir, []), ( '$nb_getval'('$included_file', OY, fail ) -> true ; OY = [] ), - '$lf_opt'(encoding, TOpts, Encoding), - '$set_encoding'(Stream, Encoding), nb_setval('$included_file', Y), print_message(Verbosity, loading(including, Y)), '$loop'(Stream,Status), - '$set_current_loop_stream'(Stream, OldStream), + set_stream(OldStream, alias(loop_stream) ), close(Stream), H is heapused-H0, '$cputime'(TF,_), T is TF-T0, print_message(Verbosity, loaded(included, Y, Mod, T, H)), @@ -870,16 +874,16 @@ db_files(Fs) :- '$init_win_graphics', fail. '$do_startup_reconsult'(X) :- - ( '$access_yap_flags'(15, 0) -> + ( current_prolog_flag(language_mode, yap) -> '$system_catch'(load_files(X, [silent(true)]), Module, Error, '$Error'(Error)) ; - '$swi_set_prolog_flag'(verbose, silent), + set_prolog_flag(verbose, silent), '$system_catch'(load_files(X, [silent(true),skip_unix_header(true)]),Module,_,fail) ; true ), !, - ( '$access_yap_flags'(15, 0) -> true ; halt). + ( current_prolog_flag(language_mode, yap) -> true ; halt). '$do_startup_reconsult'(_). '$skip_unix_header'(Stream) :- @@ -993,8 +997,7 @@ prolog_load_context(stream, Stream) :- '$nb_getval'('$consulting_file', _, fail), '$current_loop_stream'(Stream). prolog_load_context(term_position, Position) :- - '$current_loop_stream'(Stream), - stream_property(Stream, position(Position) ). + stream_property( Stream, [alias(loop_stream),position(Position)] ). % if the file exports a module, then we can @@ -1075,13 +1078,6 @@ prolog_load_context(term_position, Position) :- true ), recorda('$lf_loaded','$lf_loaded'( F, M, Reconsult, UserFile, OldF, Line, Opts), _). -'$set_encoding'(Encoding) :- - '$current_loop_stream'(Stream), - '$set_encoding'(Stream, Encoding). - -'$set_encoding'(Stream, Encoding) :- - ( Encoding == default -> true ; set_stream(Stream, encoding(Encoding)) ). - /** @pred make is det SWI-Prolog originally included this built-in as a Prolog version of the Unix `make` @@ -1099,14 +1095,6 @@ make. make_library_index(_Directory). -'$file_name'(Stream,F) :- - stream_property(Stream, file_name(F)), !. -'$file_name'(user_input,user_input) :- !. -'$file_name'(user_output,user_ouput) :- !. -'$file_name'(user_error,user_error) :- !. -'$file_name'(_,[]). - - '$fetch_stream_alias'(OldStream,Alias) :- stream_property(OldStream, alias(Alias)), !. @@ -1116,22 +1104,6 @@ make_library_index(_Directory). assert_static(Clause). -'$set_current_loop_stream'(OldStream, Stream) :- - '$current_loop_stream'(OldStream), !, - '$new_loop_stream'(Stream). -'$set_current_loop_stream'(_OldStream, Stream) :- - '$new_loop_stream'(Stream). - -'$new_loop_stream'(Stream) :- - (var(Stream) -> - nb_delete('$loop_stream') - ; - nb_setval('$loop_stream',Stream) - ). - -'$current_loop_stream'(Stream) :- - '$nb_getval'('$loop_stream',Stream, fail). - exists_source(File) :- '$full_filename'(File, _AbsFile, exists_source(File)). @@ -1664,15 +1636,15 @@ End of conditional compilation. nb_setval('$assert_all',on). '$comp_mode'(OldCompMode, source) :- '$fetch_comp_status'(OldCompMode), - '$set_yap_flags'(11,1). + set_prolog_flag(source, true). '$comp_mode'(OldCompMode, compact) :- '$fetch_comp_status'(OldCompMode), - '$set_yap_flags'(11,0). + set_prolog_flag(source, false). '$fetch_comp_status'(assert_all) :- '$nb_getval'('$assert_all',on, fail), !. '$fetch_comp_status'(source) :- - '$access_yap_flags'(11,1), !. + current_prolog_flag(source, true), !. '$fetch_comp_status'(compact). consult_depth(LV) :- '$show_consult_level'(LV). diff --git a/pl/debug.yap b/pl/debug.yap index 43c0feca3..7d1711da0 100644 --- a/pl/debug.yap +++ b/pl/debug.yap @@ -148,8 +148,8 @@ mode and the existing spy-points, when the debugger is on. ). '$do_suspy'(S, F, N, T, M) :- '$system_predicate'(T,M), - '$flags'(T,M,F,F), - F /\ 0x118dd080 =\= 0, + '$predicate_flags'(T,M,F,F), + F /\ 0x118dd080 =\= 0, ( S = spy -> '$do_error'(permission_error(access,private_procedure,T),spy(M:F/N)) ; @@ -243,16 +243,16 @@ debug :- '$start_debugging'(Mode) :- (Mode == on -> - '$swi_set_prolog_flag'(debug, true) + set_prolog_flag(debug, true) ; - '$swi_set_prolog_flag'(debug, false) + set_prolog_flag(debug, false) ), nb_setval('$debug_run',off), nb_setval('$debug_jump',false). nodebug :- '$init_debugger', - '$swi_set_prolog_flag'(debug, false), + set_prolog_flag(debug, false), nb_setval('$trace',off), print_message(informational,debug(off)). @@ -402,7 +402,7 @@ debugging :- '$init_debugger', prolog:debug_action_hook(nospyall), !. debugging :- - ( '$swi_current_prolog_flag'(debug, true) -> + ( current_prolog_flag(debug, true) -> print_message(help,debug(debug)) ; print_message(help,debug(off)) @@ -572,7 +572,7 @@ top-level. YAP disactivates debug mode, but spypoints are not removed. + `n` - nodebug stop debugging and continue execution. The command will not clear active -spy-points. +§spy-points. + `e` - exit @@ -667,7 +667,7 @@ be lost. % % $spy may be called from user code, so be careful. '$spy'([Mod|G]) :- - '$swi_current_prolog_flag'(debug, false), !, + current_prolog_flag(debug, false), !, '$execute_nonstop'(G,Mod). '$spy'([Mod|G]) :- CP is '$last_choice_pt', @@ -917,7 +917,7 @@ be lost. '$spycall_expanded'(G, M, CalledFromDebugger, InRedo). '$spycall_expanded'(G, M, _CalledFromDebugger, InRedo) :- - '$flags'(G,M,F,F), + '$predicate_flags'(G,M,F,F), F /\ 0x08402000 =\= 0, !, % dynamic procedure, logical semantics, or source % use the interpreter CP is '$last_choice_pt', @@ -955,7 +955,7 @@ be lost. ). '$tabled_predicate'(G,M) :- - '$flags'(G,M,F,F), + '$predicate_flags'(G,M,F,F), F /\ 0x00000040 =\= 0. %'$trace'(P,G,Module,L,Deterministic) :- @@ -964,7 +964,7 @@ be lost. % at this point we are done with leap or skip nb_setval('$debug_run',off), % make sure we run this code outside debugging mode. - '$swi_set_prolog_flag'(debug, false), + set_prolog_flag(debug, false), repeat, '$trace_msg'(P,G,Module,L,Deterministic), ( @@ -977,13 +977,13 @@ be lost. ), (Debug = on -> - '$swi_set_prolog_flag'(debug, true) + set_prolog_flag(debug, true) ; Debug = zip -> - '$swi_set_prolog_flag'(debug, true) + set_prolog_flag(debug, true) ; - '$swi_set_prolog_flag'(debug, false) + set_prolog_flag(debug, false) ), !. @@ -1027,10 +1027,10 @@ be lost. '$action'(0'!,_,_,_,_,_) :- !, % ! 'g execute read(debugger_input, G), % don't allow yourself to be caught by creep. - '$swi_current_prolog_flag'(debug, OldDeb), - '$swi_set_prolog_flag'(debug, false), + current_prolog_flag(debug, OldDeb), + set_prolog_flag(debug, false), ( '$execute'(G) -> true ; true), - '$swi_set_prolog_flag'(debug, OldDeb), + set_prolog_flag(debug, OldDeb), % '$skipeol'(0'!), % ' fail. '$action'(0'<,_,_,_,_,_) :- !, % <'Depth @@ -1109,7 +1109,7 @@ be lost. nodebug. '$action'(0'r,_,CallId,_,_,_) :- !, % 'r retry '$scan_number'(0'r,CallId,ScanNumber), % ' - '$swi_set_prolog_flag'(debug, true), + set_prolog_flag(debug, true), throw(error('$retry_spy'(ScanNumber),[])). '$action'(0's,P,CallNumber,_,_,on) :- !, % 's skip '$skipeol'(0's), % ' diff --git a/pl/directives.yap b/pl/directives.yap index 761596f2a..59f3cb1f9 100644 --- a/pl/directives.yap +++ b/pl/directives.yap @@ -115,8 +115,8 @@ '$exec_directive'(G, Mode, M, VL, Pos). '$save_directive'(G, Mode, M, VL, Pos) :- - prolog_load_context(file, FileName), !, - recordz('$directive', directive(FileName,M:G, Mode, VL, Pos),_). + prolog_load_context(file, FileName), !, + recordz('$directive', directive(FileName,M:G, Mode, VL, Pos),_). '$exec_directive'(multifile(D), _, M, _, _) :- '$system_catch'('$multifile'(D, M), M, diff --git a/pl/flags.yap b/pl/flags.yap index abfccfddb..118c1b228 100644 --- a/pl/flags.yap +++ b/pl/flags.yap @@ -26,623 +26,6 @@ yap_flag/2, yap_flag/3], []). -/** @defgroup Flags YAP Execution Flags - @ingroup builtins - @{ -*/ - -:- use_system_module( '$_boot', ['$prompt_alternatives_on'/1]). - -:- use_system_module( '$_checker', ['$syntax_check_discontiguous'/2, - '$syntax_check_multiple'/2, - '$syntax_check_single_var'/2]). - -:- use_system_module( '$_control', ['$set_toplevel_hook'/1]). - -:- use_system_module( '$_errors', ['$do_error'/2]). - -:- use_system_module( '$_yio', ['$default_expand'/1, - '$set_default_expand'/1]). - -yap_flag(V,Out) :- - '$user_defined_flag'(V,_,_,_), - (nonvar(V) -> - ! - ; - true - ), - '$user_flag_value'(V, Out). - -yap_flag(V,Out) :- - ( var(V) -> - '$swi_current_prolog_flag'(V, Out) - ; - '$swi_current_prolog_flag'(V, Current) - -> - (var(Out) -> - Current = Out - ; - '$swi_set_prolog_flag'(V, Out) - ) - ). -yap_flag(V,Out) :- - var(V), !, - '$show_yap_flag_opts'(V,Out). - -% do or do not machine code -yap_flag(fast,on) :- set_value('$fast',true). -yap_flag(fast,off) :- !, set_value('$fast',[]). - -% hide/unhide atoms -yap_flag(hide,Atom) :- !, hide(Atom). -yap_flag(unhide,Atom) :- !, unhide(Atom). - -% control garbage collection -yap_flag(gc,V) :- - var(V), !, - ( get_value('$gc',[]) -> V = off ; V = on). -yap_flag(gc,on) :- !, set_value('$gc',true). -yap_flag(gc,off) :- !, set_value('$gc',[]). - -yap_flag(gc_margin,N) :- - ( var(N) -> - get_value('$gc_margin',N) - ; - integer(N), N >=0 -> - set_value('$gc_margin',N) - ; - '$do_error'(domain_error(flag_value,gc_margin+X),yap_flag(gc_margin,X)) - ). -yap_flag(gc_trace,V) :- - var(V), !, - get_value('$gc_trace',N1), - get_value('$gc_verbose',N2), - get_value('$gc_very_verbose',N3), - '$yap_flag_show_gc_tracing'(N1, N2, N3, V). -yap_flag(gc_trace,on) :- !, - set_value('$gc_trace',true), - set_value('$gc_verbose',[]), - set_value('$gc_very_verbose',[]). -yap_flag(gc_trace,verbose) :- !, - set_value('$gc_trace',[]), - set_value('$gc_verbose',true), - set_value('$gc_very_verbose',[]). -yap_flag(gc_trace,very_verbose) :- !, - set_value('$gc_trace',[]), - set_value('$gc_verbose',true), - set_value('$gc_very_verbose',true). -yap_flag(gc_trace,off) :- - set_value('$gc_trace',[]), - set_value('$gc_verbose',[]), - set_value('$gc_very_verbose',[]). -yap_flag(syntax_errors, V) :- var(V), !, - '$get_read_error_handler'(V). -yap_flag(syntax_errors, Option) :- - '$set_read_error_handler'(Option). -% compatibility flag -yap_flag(enhanced,on) :- !, set_value('$enhanced',true). -yap_flag(enhanced,off) :- set_value('$enhanced',[]). - -% compatibility flag -yap_flag(agc_margin,Margin) :- - '$agc_threshold'(Margin). - - -% -% show state of $ -% -yap_flag(dollar_as_lower_case,V) :- - var(V), !, - '$type_of_char'(36,T), - (T = 3 -> V = on ; V = off). -% -% make $a a legit atom -% -yap_flag(dollar_as_lower_case,on) :- !, - '$change_type_of_char'(36,3). -% -% force quoting of '$a' -% -yap_flag(dollar_as_lower_case,off) :- - '$change_type_of_char'(36,7). - -yap_flag(call_counting,X) :- (var(X); X = on; X = off), !, - '$is_call_counted'(X). - -:- set_value('$associate',yap). - -yap_flag(associate,X) :- - var(X), !, - get_value('$associate',X). -yap_flag(associate,X) :- - atom(X), !, - set_value('$associate',X). -yap_flag(associate,X) :- - '$do_error'(type_error(atom,X),associate(X)). - -% do or do not indexation -yap_flag(index,X) :- var(X), - '$access_yap_flags'(19, X1), - '$transl_to_index_mode'(X1,X), !. -yap_flag(index,X) :- - '$transl_to_index_mode'(X1,X), !, - '$set_yap_flags'(19,X1). -yap_flag(index,X) :- - '$do_error'(domain_error(flag_value,index+X),yap_flag(index,X)). - -% do or do not indexation -yap_flag(index_sub_term_search_depth,X) :- - var(X), - '$access_yap_flags'(23, X), !. -yap_flag(index_sub_term_search_depth,X) :- - integer(X), - X > 0, - '$set_yap_flags'(23,X). -yap_flag(index_sub_term_search_depth,X) :- - \+ integer(X), - '$do_error'(type_error(integer,X),yap_flag(index_sub_term_search_depth,X)). -yap_flag(index_sub_term_search_depth,X) :- - '$do_error'(domain_error(out_of_range,index_sub_term_search_depth+X),yap_flag(index_sub_term_search_depth,X)). - -% tabling mode -yap_flag(tabling_mode,Options) :- - var(Options), !, - '$access_yap_flags'(20,Options). -yap_flag(tabling_mode,[]) :- !, - yap_flag(tabling_mode,default). -yap_flag(tabling_mode,[HOption|TOption]) :- !, - yap_flag(tabling_mode,TOption), - yap_flag(tabling_mode,HOption). -yap_flag(tabling_mode,Option) :- - '$transl_to_yap_flag_tabling_mode'(Flag,Option), !, - '$set_yap_flags'(20,Flag). -yap_flag(tabling_mode,Options) :- - '$do_error'(domain_error(flag_value,tabling_mode+Options),yap_flag(tabling_mode,Options)). - -yap_flag(informational_messages,X) :- var(X), !, - yap_flag(verbose, X). - -yap_flag(version,X) :- - var(X), !, - get_value('$version_name',X). -yap_flag(version,X) :- - '$do_error'(permission_error(modify,flag,version),yap_flag(version,X)). - -/* ISO Core Revision DTR: new float flags - -yap_flag(float_mantissa_digits,X) :- - var(X), !, - ????? -yap_flag(float_mantissa_digits,X) :- - integer(X), X > 0, !, - '$do_error'(permission_error(modify,flag,float_mantissa_digits),yap_flag(float_mantissa_digits,X)). -yap_flag(float_mantissa_digits,X) :- - '$do_error'(domain_error(flag_value,float_mantissa_digits+X),yap_flag(float_mantissa_digits,X)). - -yap_flag(float_epsilon,X) :- - var(X), !, - ????? -yap_flag(float_epsilon,X) :- - float(X), X > 0, !, - '$do_error'(permission_error(modify,flag,float_epsilon),yap_flag(float_epsilon,X)). -yap_flag(float_epsilon,X) :- - '$do_error'(domain_error(flag_value,float_epsilon+X),yap_flag(float_epsilon,X)). - -yap_flag(float_min_exponent,X) :- - var(X), !, - ????? -yap_flag(float_min_exponent,X) :- - integer(X), X > 0, !, - '$do_error'(permission_error(modify,flag,float_min_exponent),yap_flag(float_min_exponent,X)). -yap_flag(float_epsilon,X) :- - '$do_error'(domain_error(flag_value,float_min_exponent+X),yap_flag(float_min_exponent,X)). - -yap_flag(float_max_exponent,X) :- - var(X), !, - ????? -yap_flag(float_max_exponent,X) :- - integer(X), X > 0, !, - '$do_error'(permission_error(modify,flag,float_max_exponent),yap_flag(flo - at_max_exponent,X)). -yap_flag(float_max_exponent,X) :- - '$do_error'(domain_error(flag_value,float_max_exponent+X),yap_flag(float_max_exponent,X)). -*/ - -yap_flag(n_of_integer_keys_in_db,X) :- - var(X), !, - '$resize_int_keys'(X). -yap_flag(n_of_integer_keys_in_db,X) :- integer(X), X > 0, !, - '$resize_int_keys'(X). -yap_flag(n_of_integer_keys_in_db,X) :- - '$do_error'(domain_error(flag_value,n_of_integer_keys_in_db+X),yap_flag(n_of_integer_keys_in_db,X)). - -yap_flag(n_of_integer_keys_in_bb,X) :- - var(X), !, - '$resize_bb_int_keys'(X). -yap_flag(n_of_integer_keys_in_bb,X) :- integer(X), X > 0, !, - '$resize_bb_int_keys'(X). -yap_flag(n_of_integer_keys_in_bb,X) :- - '$do_error'(domain_error(flag_value,n_of_integer_keys_in_bb+X),yap_flag(n_of_integer_keys_in_bb,X)). - -yap_flag(profiling,X) :- (var(X); X = on; X = off), !, - '$is_profiled'(X). - -yap_flag(strict_iso,OUT) :- - var(OUT), !, - '$access_yap_flags'(9,X), - '$transl_to_on_off'(X,OUT). -yap_flag(strict_iso,on) :- !, - yap_flag(language,iso), - '$transl_to_on_off'(X,on), - '$set_yap_flags'(9,X). -yap_flag(strict_iso,off) :- !, - '$transl_to_on_off'(X,off), - '$set_yap_flags'(9,X). -yap_flag(strict_iso,X) :- - '$do_error'(domain_error(flag_value,strict_iso+X),yap_flag(strict_iso,X)). - -yap_flag(variable_names_may_end_with_quotes,OUT) :- - var(OUT), !, - '$access_yap_flags'(21,X), - '$transl_to_on_off'(X,OUT). -yap_flag(variable_names_may_end_with_quotes,on) :- !, - '$transl_to_on_off'(X,on), - '$set_yap_flags'(21,X). -yap_flag(variable_names_may_end_with_quotes,off) :- !, - '$transl_to_on_off'(X,off), - '$set_yap_flags'(21,X). -yap_flag(variable_names_may_end_with_quotes,X) :- - '$do_error'(domain_error(flag_value,strict_iso+X),yap_flag(strict_iso,X)). - -yap_flag(language,X) :- - var(X), !, - '$access_yap_flags'(8, X1), - '$trans_to_lang_flag'(X1,X). -yap_flag(language,X) :- - '$trans_to_lang_flag'(N,X), !, - '$set_yap_flags'(8,N), - '$adjust_language'(X). -yap_flag(language,X) :- - '$do_error'(domain_error(flag_value,language+X),yap_flag(language,X)). - -yap_flag(discontiguous_warnings,X) :- - var(X), !, - style_check(?(Disc)), - ( Disc = +discontiguous, - X = on - ; - Disc = -discontiguous, - X = off - ), !. -yap_flag(discontiguous_warnings,X) :- - '$transl_to_on_off'(_,X), !, - (X == on -> - style_check(discontiguous) - ; - style_check(-discontiguous) - ). -yap_flag(discontiguous_warnings,X) :- - '$do_error'(domain_error(flag_value,discontiguous_warnings+X),yap_flag(discontiguous_warnings,X)). - -yap_flag(redefine_warnings,X) :- - var(X), !, - style_check(?(Disc)), - ( Disc = +multiple, - X = on - ; - Disc = -multiple, - X = off - ), !. -yap_flag(redefine_warnings,X) :- - '$transl_to_on_off'(_,X), !, - (X == on -> - style_check(multiple) - ; - style_check(-multiple) - ). -yap_flag(redefine_warnings,X) :- - '$do_error'(domain_error(flag_value,redefine_warnings+X),yap_flag(redefine_warnings,X)). - -yap_flag(chr_toplevel_show_store,X) :- - var(X), !, - '$nb_getval'('$chr_toplevel_show_store', X, fail). -yap_flag(chr_toplevel_show_store,X) :- - (X = true ; X = false), !, - nb_setval('$chr_toplevel_show_store',X). -yap_flag(chr_toplevel_show_store,X) :- - '$do_error'(domain_error(flag_value,chr_toplevel_show_store+X),yap_flag(chr_toplevel_show_store,X)). - -yap_flag(qcompile,X) :- - var(X), !, - '$nb_getval'('$qcompile', X, X=never). -yap_flag(qcompile,X) :- - (X == never ; X == auto ; X == large ; X == part), !, - nb_setval('$qcompile',X). -yap_flag(qcompile,X) :- - '$do_error'(domain_error(flag_value,qcompile+X),yap_flag(qcompile,X)). - -yap_flag(source,X) :- - var(X), !, - source_mode( X, X ). -yap_flag(source,X) :- - (X == off -> true ; X == on), !, - source_mode( _, X ). -yap_flag(source,X) :- - '$do_error'(domain_error(flag_value,source+X),yap_flag(source,X)). - -yap_flag(open_expands_filename,Expand) :- - var(Expand), !, - '$default_expand'(Expand). -yap_flag(open_expands_filename,Expand) :- - '$set_default_expand'(Expand). - -yap_flag(single_var_warnings,X) :- - var(X), !, - style_check(?(Disc)), - ( Disc = +singletons, - X = on - ; - Disc = -singletons, - X = off - ), !. -yap_flag(single_var_warnings,X) :- - '$transl_to_on_off'(_,X), !, - (X == on -> - style_check(single_var) - ; - style_check(-single_var) - ). -yap_flag(single_var_warnings,X) :- - '$do_error'(domain_error(flag_value,single_var_warnings+X),yap_flag(single_var_warnings,X)). - -yap_flag(system_options,X) :- - '$system_options'(X). - -yap_flag(update_semantics,X) :- - var(X), !, - ( '$log_upd'(I) -> '$convert_upd_sem'(I,X) ). -yap_flag(update_semantics,logical) :- !, - '$switch_log_upd'(1). -yap_flag(update_semantics,logical_assert) :- !, - '$switch_log_upd'(2). -yap_flag(update_semantics,immediate) :- !, - '$switch_log_upd'(0). -yap_flag(update_semantics,X) :- - '$do_error'(domain_error(flag_value,update_semantics+X),yap_flag(update_semantics,X)). - -yap_flag(toplevel_hook,G) :- - var(G), !, - ( recorded('$toplevel_hooks',G,_) -> G ; G = fail ). -yap_flag(toplevel_hook,G) :- !, - '$set_toplevel_hook'(G). - -yap_flag(typein_module,X) :- - var(X), !, - '$current_module'(X). -yap_flag(typein_module,X) :- - module(X). - -yap_flag(write_strings,OUT) :- - var(OUT), !, - '$access_yap_flags'(13,X), - '$transl_to_on_off'(X,OUT). -yap_flag(write_strings,on) :- !, - '$transl_to_on_off'(X,on), - '$set_yap_flags'(13,X). -yap_flag(write_strings,off) :- !, - '$transl_to_on_off'(X,off), - '$set_yap_flags'(13,X). -yap_flag(write_strings,X) :- - '$do_error'(domain_error(flag_value,write_strings+X),yap_flag(write_strings,X)). - -yap_flag(arithmetic_exceptions,OUT) :- - var(OUT), !, - '$access_yap_flags'(12,X), - '$transl_to_true_false'(X,OUT). -yap_flag(arithmetic_exceptions,true) :- !, - '$transl_to_true_false'(X,true), - '$set_yap_flags'(12,X). -yap_flag(arithmetic_exceptions,false) :- !, - '$transl_to_true_false'(X,false), - '$set_yap_flags'(12,X). -yap_flag(arithmetic_exceptions,X) :- - '$do_error'(domain_error(flag_value,arithmetic_exceptions+X),yap_flag(arithmetic_exceptions,[true,false])). - -yap_flag(prompt_alternatives_on,OUT) :- - var(OUT), !, - '$prompt_alternatives_on'(OUT). -yap_flag(prompt_alternatives_on,determinism) :- !, - '$purge_clauses'('$prompt_alternatives_on'(_),prolog), - '$compile'('$prompt_alternatives_on'(determinism),0,'$prompt_alternatives_on'(determinism),prolog). -yap_flag(prompt_alternatives_on,groundness) :- !, - '$purge_clauses'('$prompt_alternatives_on'(_),prolog), - '$compile'('$prompt_alternatives_on'(groundness),0,'$prompt_alternatives_on'(groundness),prolog). -yap_flag(prompt_alternatives_on,X) :- - '$do_error'(domain_error(flag_value,prompt_alternatives_on+X),yap_flag(prompt_alternatives_on,X)). - -yap_flag(stack_dump_on_error,OUT) :- - var(OUT), !, - '$access_yap_flags'(17,X), - '$transl_to_on_off'(X,OUT). -yap_flag(stack_dump_on_error,on) :- !, -'$transl_to_on_off'(X,on), - '$set_yap_flags'(17,X). -yap_flag(stack_dump_on_error,off) :- !, - '$transl_to_on_off'(X,off), - '$set_yap_flags'(17,X). -yap_flag(stack_dump_on_error,X) :- - '$do_error'(domain_error(flag_value,stack_dump_on_error+X),yap_flag(stack_dump_on_error,X)). - -yap_flag(user_input,OUT) :- - var(OUT), !, - stream_property(OUT,alias(user_input)). -yap_flag(user_input,Stream) :- - set_stream(Stream, alias(user_input)). - -yap_flag(user_output,OUT) :- - var(OUT), !, - stream_property(OUT,alias(user_output)). -yap_flag(user_output,Stream) :- - set_stream(Stream, alias(user_output)). - -yap_flag(user_error,OUT) :- - var(OUT), !, - stream_property(OUT,alias(user_error)). -yap_flag(user_error,Stream) :- - set_stream(Stream, alias(user_error)). - -yap_flag(debugger_print_options,OUT) :- - var(OUT), - recorded('$print_options','$debugger'(OUT),_), !. -yap_flag(debugger_print_options,Opts) :- - recorda('$print_options','$debugger'(Opts),_). - -:- recorda('$print_options','$debugger'([quoted(true),numbervars(true),portrayed(true),max_depth(10)]),_). - -yap_flag(toplevel_print_options,OUT) :- - var(OUT), - recorded('$print_options','$toplevel'(OUT),_), !. -yap_flag(toplevel_print_options,Opts) :- - recorda('$print_options','$toplevel'(Opts),_). - -:- recorda('$print_options','$toplevel'([quoted(true),numbervars(true),portrayed(true)]),_). - -yap_flag(host_type,X) :- - '$host_type'(X). - -yap_flag(host_type,X) :- - '$host_type'(X). - -yap_flag(argv,X) :- - '$argv'(X). - -yap_flag(os_argv,X) :- - '$os_argv'(X). - -yap_flag(float_format,X) :- - var(X), !, - '$float_format'(X). -yap_flag(float_format,X) :- - atom(X), !, - '$float_format'(X). -yap_flag(float_format,X) :- - '$do_error'(type_error(atom,X),yap_flag(float_format,X)). - -yap_flag(max_workers,X) :- - var(X), !, - '$max_workers'(X). -yap_flag(max_workers,X) :- - integer(X), X > 0, !, - '$do_error'(permission_error(modify,flag,max_workers),yap_flag(max_workers,X)). -yap_flag(max_workers,X) :- - '$do_error'(domain_error(flag_value,max_workers+X),yap_flag(max_workers,X)). - -yap_flag(max_threads,X) :- - var(X), !, - '$max_threads'(X). -yap_flag(max_threads,X) :- - integer(X), X > 0, !, - '$do_error'(permission_error(modify,flag,max_threads),yap_flag(max_threads,X)). -yap_flag(max_threads,X) :- - '$do_error'(domain_error(flag_value,max_threads+X),yap_flag(max_threads,X)). - -% should match definitions in Yap.h -'$transl_to_index_mode'(0, off). -'$transl_to_index_mode'(1, single). -'$transl_to_index_mode'(2, compact). -'$transl_to_index_mode'(3, multi). -'$transl_to_index_mode'(3, on). % default is multi argument indexing -'$transl_to_index_mode'(4, max). - - -% should match with code in stdpreds.c -'$transl_to_yap_flag_tabling_mode'(0,default). -'$transl_to_yap_flag_tabling_mode'(1,batched). -'$transl_to_yap_flag_tabling_mode'(2,local). -'$transl_to_yap_flag_tabling_mode'(3,exec_answers). -'$transl_to_yap_flag_tabling_mode'(4,load_answers). -'$transl_to_yap_flag_tabling_mode'(5,local_trie). -'$transl_to_yap_flag_tabling_mode'(6,global_trie). -'$transl_to_yap_flag_tabling_mode'(7,coinductive). - -'$system_options'(big_numbers) :- - '$has_bignums'. -'$system_options'(coroutining) :- - '$yap_has_coroutining'. -'$system_options'(depth_limit) :- - \+ '$undefined'(get_depth_limit(_), prolog). -'$system_options'(low_level_tracer) :- - \+ '$undefined'(start_low_level_trace, prolog). -'$system_options'(or_parallelism) :- - \+ '$undefined'('$c_yapor_start', prolog). -'$system_options'(rational_trees) :- - '$yap_has_rational_trees'. -'$system_options'(readline) :- - '$swi_current_prolog_flag'(readline, true). -'$system_options'(tabling) :- - \+ '$undefined'('$c_table'(_,_,_), prolog). -'$system_options'(threads) :- - \+ '$undefined'('$thread_join'(_), prolog). -'$system_options'(wam_profiler) :- - \+ '$undefined'(reset_op_counters, prolog). - -'$yap_system_flag'(agc_margin). -'$yap_system_flag'(arithmetic_exceptions). -'$yap_system_flag'(argv). -'$yap_system_flag'(chr_toplevel_show_store). -'$yap_system_flag'(debugger_print_options). -'$yap_system_flag'(discontiguous_warnings). -'$yap_system_flag'(dollar_as_lower_case). -% V = fast ; -% '$yap_system_flag'(file_name_variables). -% '$yap_system_flag'(fileerrors ). -'$yap_system_flag'(float_format). -% V = float_mantissa_digits ; -% V = float_epsilon ; -% V = float_min_exponent ; -% V = float_max_exponent ; -'$yap_system_flag'(gc ). -'$yap_system_flag'(gc_margin ). -'$yap_system_flag'(gc_trace ). -% V = hide ; -'$yap_system_flag'(host_type ). -'$yap_system_flag'(index). -'$yap_system_flag'(index_sub_term_search_depth). -'$yap_system_flag'(tabling_mode). -'$yap_system_flag'(informational_messages). -'$yap_system_flag'(language). -'$yap_system_flag'(max_workers). -'$yap_system_flag'(max_threads). -'$yap_system_flag'(n_of_integer_keys_in_db). -'$yap_system_flag'(open_expands_filename). -'$yap_system_flag'(os_argv). -'$yap_system_flag'(profiling). -'$yap_system_flag'(prompt_alternatives_on). -'$yap_system_flag'(redefine_warnings). -'$yap_system_flag'(single_var_warnings). -'$yap_system_flag'(source). -'$yap_system_flag'(stack_dump_on_error). -'$yap_system_flag'(strict_iso). -'$yap_system_flag'(syntax_errors). -'$yap_system_flag'(system_options). -'$yap_system_flag'(toplevel_hook). -'$yap_system_flag'(toplevel_print_options). -'$yap_system_flag'(typein_module). -'$yap_system_flag'(update_semantics). -'$yap_system_flag'(user_error). -'$yap_system_flag'(user_input). -'$yap_system_flag'(user_output). -'$yap_system_flag'(variable_names_may_end_with_quotes). -'$yap_system_flag'(version). -'$yap_system_flag'(write_strings). - -'$show_yap_flag_opts'(V,Out) :- - '$yap_system_flag'(V), - yap_flag(V, Out). - -'$trans_to_lang_flag'(0,cprolog). -'$trans_to_lang_flag'(1,iso). -'$trans_to_lang_flag'(2,sicstus). '$adjust_language'(cprolog) :- % '$switch_log_upd'(0), @@ -686,218 +69,20 @@ yap_flag(max_threads,X) :- unknown(_,error). -'$convert_upd_sem'(0,immediate). -'$convert_upd_sem'(1,logical). -'$convert_upd_sem'(2,logical_assert). - -'$transl_to_true_false'(0,false). -'$transl_to_true_false'(1,true). - -'$transl_to_on_off'(0,off). -'$transl_to_on_off'(1,on). - -'$transl_to_rounding_function'(0,toward_zero). -'$transl_to_rounding_function'(1,down). - -'$yap_flag_show_gc_tracing'(true, _, _, on) :- !. -'$yap_flag_show_gc_tracing'(_, true, _, verbose) :- !. -'$yap_flag_show_gc_tracing'(_, _, on, very_verbose) :- !. -'$yap_flag_show_gc_tracing'(_, _, _, off). - -'$flag_check_alias'(OUT, Alias) :- - stream_property(OUT,alias(Alias)), !. - -/** @pred current_prolog_flag(? _Flag_,- _Value_) is iso - -Obtain the value for a YAP Prolog flag. Equivalent to calling -yap_flag/2 with the second argument unbound, and unifying the -returned second argument with _Value_. - - -*/ -current_prolog_flag(V,Out) :- - var(V), !, - yap_flag(V,NOut), - NOut = Out. -current_prolog_flag(V,Out) :- - atom(V), !, - yap_flag(V,NOut), - NOut = Out. -current_prolog_flag(M:V,Out) :- - current_module(M), atom(V), !, - yap_flag(M:V,NOut), - NOut = Out. -current_prolog_flag(V,Out) :- - '$do_error'(type_error(atom,V),current_prolog_flag(V,Out)). - -/** @pred set_prolog_flag(+ _Flag_,+ _Value_) is iso - - - -Set the value for YAP Prolog flag `Flag`. Equivalent to -calling yap_flag/2 with both arguments bound. - - -*/ -set_prolog_flag(F,V) :- - var(F), !, - '$do_error'(instantiation_error,set_prolog_flag(F,V)). -set_prolog_flag(F,V) :- - var(V), !, - '$do_error'(instantiation_error,set_prolog_flag(F,V)). -set_prolog_flag(M:V,Out) :- - current_module(M), atom(V), !, - '$swi_set_prolog_flag'(M:V,Out). -set_prolog_flag(F,V) :- - \+ atom(F), !, - '$do_error'(type_error(atom,F),set_prolog_flag(F,V)). -set_prolog_flag(F, Val) :- - '$swi_current_prolog_flag'(F, _), !, - '$swi_set_prolog_flag'(F, Val). -set_prolog_flag(F,V) :- - '$yap_system_flag'(F), !, - yap_flag(F,V). -set_prolog_flag(F,V) :- - '$swi_current_prolog_flag'(user_flags, UFlag), - ( - UFlag = silent -> - create_prolog_flag(F, V, []) - ; - UFlag = warning -> - print_message(warning,existence_error(prolog_flag, F)), - create_prolog_flag(F, V, []) - ; - UFlag = error -> - '$do_error'(existence_error(prolog_flag, F),set_prolog_flag(F,V)) - ). - -/** @pred prolog_flag(? _Flag_,- _OldValue_,+ _NewValue_) - - - -Obtain the value for a YAP Prolog flag and then set it to a new -value. Equivalent to first calling current_prolog_flag/2 with the -second argument _OldValue_ unbound and then calling -set_prolog_flag/2 with the third argument _NewValue_. - - -*/ -prolog_flag(F, Old, New) :- - var(F), !, - '$do_error'(instantiation_error,prolog_flag(F,Old,New)). -prolog_flag(F, Old, New) :- - current_prolog_flag(F, Old), - set_prolog_flag(F, New). - -prolog_flag(F, Old) :- - current_prolog_flag(F, Old). - /** @pred create_prolog_flag(+ _Flag_,+ _Value_,+ _Options_) +Create a new YAP Prolog flag. _Options_ include + * `type(+_Type_)` with _Type_ one of `boolean`, `integer`, `float`, `atom` +and `term` (that is, any ground term) -Create a new YAP Prolog flag. _Options_ include `type(+Type)` and `access(+Access)` with _Access_ -one of `read_only` or `read_write` and _Type_ one of `boolean`, `integer`, `float`, `atom` -and `term` (that is, no type). + * `access(+_Access_)` with _Access_ one of `read_only` or `read_write` - + * `keeep(+_Keep_) protect existing flag. */ create_prolog_flag(Name, Value, Options) :- - '$check_flag_name'(Name, create_prolog_flag(Name, Value, Options)), - '$check_flag_options'(Options, Domain, RW, create_prolog_flag(Name, Value, Options)), - '$check_flag_value'(Value, Domain, create_prolog_flag(Name, Value, Options)), - retractall(prolog:'$user_defined_flag'(Name,_,_,_)), - assert(prolog:'$user_defined_flag'(Name,Domain,RW,Value)). - -'$check_flag_name'(V, G) :- - var(V), - '$do_error'(instantiation_error,G). -'$check_flag_name'(Name, _) :- - atom(Name), !. -'$check_flag_name'(Name, G) :- - '$do_error'(type_error(atom,Name),G). - -'$check_flag_options'(O, _, _, G) :- - var(O), - '$do_error'(instantiation_error,G). -'$check_flag_options'([], _, read_write, _) :- !. -'$check_flag_options'([O1|Os], Domain, RW, G) :- !, - '$check_flag_optionsl'([O1|Os], Domain, RW, G). -'$check_flag_options'(O, _, _, G) :- - '$do_error'(type_error(list,O),G). - - -'$check_flag_optionsl'([], _, read_write, _G). -'$check_flag_optionsl'([V|_Os], _Domain, _RW, G) :- - var(V), - '$do_error'(instantiation_error,G). -'$check_flag_optionsl'([type(Type)|Os], Domain, RW, G) :- !, - '$check_flag_type'(Type, Domain, G), - '$check_flag_optionsl'(Os, _, RW, G). -'$check_flag_optionsl'([access(Access)|Os], Domain, RW, G) :- !, - '$check_flag_access'(Access, RW, G), - '$check_flag_optionsl'(Os, Domain, _, G). -'$check_flag_optionsl'(Os, _Domain, _RW, G) :- - '$do_error'(domain_error(create_prolog_flag,Os),G). - -'$check_flag_type'(V, _, G) :- - var(V), - '$do_error'(instantiation_error,G). -'$check_flag_type'(boolean, boolean, _) :- !. -'$check_flag_type'(integer, integer, _) :- !. -'$check_flag_type'(float, float, _) :- !. -'$check_flag_type'(atom, atom, _) :- !. -'$check_flag_type'(term, term, _) :- !. -'$check_flag_type'(Atom, _, G) :- - '$do_error'(domain_error(create_prolog_flag_option(type),Atom),G). - -'$check_flag_access'(V, _, G) :- - var(V), - '$do_error'(instantiation_error,G). -'$check_flag_access'(read_write, read_write, _) :- !. -'$check_flag_access'(read_only, read_only, _) :- !. -'$check_flag_access'(Atom, _, G) :- - '$do_error'(domain_error(create_prolog_flag_option(access),Atom),G). - -'$user_flag_value'(F, Val) :- - var(Val), !, - '$user_defined_flag'(F,_,_,Val). -'$user_flag_value'(F, Val) :- - atomic(Val), !, - prolog:'$user_defined_flag'(F,Domain,RW,V0), - ( - Val == V0 - -> - true - ; - RW = read_only - -> - '$do_error'(permission_error(modify,flag,F),yap_flag(F,Val)) - ; - '$check_flag_value'(Val, Domain, yap_flag(F,Val)), - retractall(prolog:'$user_defined_flag'(F,_,_,_)), - assert(prolog:'$user_defined_flag'(F,Domain,RW,Val)) - ). -'$user_flag_value'(F, Val) :- - '$do_error'(type_error(atomic,Val),yap_flag(F,Val)). - -'$check_flag_value'(Value, _, G) :- - \+ ground(Value), !, - '$do_error'(instantiation_error,G). -'$check_flag_value'(Value, Domain, _G) :- - var(Domain), !, - '$flag_domain_from_value'(Value, Domain). -'$check_flag_value'(_, term, _) :- !. -'$check_flag_value'(Value, atom, _) :- - atom(Value), !. -'$check_flag_value'(Value, integer, _) :- - integer(Value), !. -'$check_flag_value'(Value, float, _) :- - float(Value), !. -'$check_flag_value'(true, boolean, _) :- !. -'$check_flag_value'(false, boolean, _) :- !. -'$check_flag_value'(Value, Domain, G) :- - '$do_error'(domain_error(Domain,Value),G). + '$flag_domain_from_value'( Value, Type ), + '$create_prolog_flag'(Name, Value, [type(Type)|Options]). '$flag_domain_from_value'(true, boolean) :- !. '$flag_domain_from_value'(false, boolean) :- !. @@ -906,47 +91,6 @@ create_prolog_flag(Name, Value, Options) :- '$flag_domain_from_value'(Value, atom) :- atom(Value), !. '$flag_domain_from_value'(_, term). - -/** - @pred source_mode(- _O_,+ _N_) - -The state of source mode can either be on or off. When the source mode -is on, all clauses are kept both as compiled code and in a "hidden" -database. _O_ is unified with the previous state and the mode is set -according to _N_. - -*/ - - -% if source_mode is on, then the source for the predicates -% is stored with the code -source_mode(Old,New) :- - '$access_yap_flags'(11,X), - '$transl_to_on_off'(X,Old), - '$transl_to_on_off'(XN,New), - '$set_yap_flags'(11,XN). - -/** @pred source - -After executing this goal, YAP keeps information on the source -of the predicates that will be consulted. This enables the use of -[listing/0](@ref listing), `listing/1` and [clause/2](@ref clause) for those -clauses. - -The same as `source_mode(_,on)` or as declaring all newly defined -static procedures as `public`. -*/ -source :- '$set_yap_flags'(11,1). - - -/** @pred no_source - The opposite to `source`. - -The same as `source_mode(_,off)`. - -*/ -no_source :- '$set_yap_flags'(11,0). - /** @} */ diff --git a/pl/init.yap b/pl/init.yap index 0a6cee7f9..36f9707a7 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -22,7 +22,6 @@ @{ */ - :- system_module( '$_init', [!/0, (:-)/1, (?-)/1, @@ -109,17 +108,20 @@ otherwise. :- '$handle_throw'(_,_,_), !. +:- $all_current_modules(M), yap_flag(M:unknown, error) ; true. + :- bootstrap('errors.yap'). :- bootstrap('lists.yap'). :- bootstrap('consult.yap'). :- bootstrap('preddecls.yap'). +:- bootstrap('preddyns.yap'). :- bootstrap('atoms.yap'). :- bootstrap('os.yap'). :- bootstrap('absf.yap'). -:-'$swi_set_prolog_flag'(verbose, normal). +:-set_prolog_flag(verbose, normal). :- [ 'directives.yap', 'utils.yap', @@ -127,7 +129,7 @@ otherwise. 'arith.yap', 'flags.yap' ]. - + :- [ 'preds.yap', 'modules.yap' ]. @@ -185,6 +187,41 @@ version(yap,[6,3]). :- ['undefined.yap']. +:- multifile user:portray_message/2. + +:- dynamic user:portray_message/2. + +/** @pred _CurrentModule_:goal_expansion(+ _G_,+ _M_,- _NG_), user:goal_expansion(+ _G_,+ _M_,- _NG_) + + +YAP now supports goal_expansion/3. This is an user-defined +procedure that is called after term expansion when compiling or +asserting goals for each sub-goal in a clause. The first argument is +bound to the goal and the second to the module under which the goal + _G_ will execute. If goal_expansion/3 succeeds the new +sub-goal _NG_ will replace _G_ and will be processed in the same +way. If goal_expansion/3 fails the system will use the default +rules. + + +*/ +:- multifile user:goal_expansion/3. + +:- dynamic user:goal_expansion/3. + +:- multifile user:goal_expansion/2. + +:- dynamic user:goal_expansion/2. + +:- multifile system:goal_expansion/2. + +:- dynamic system:goal_expansion/2. + +:- multifile goal_expansion/2. + +:- dynamic goal_expansion/2. + + :- use_module('messages.yap'). :- use_module('hacks.yap'). :- use_module('attributes.yap'). @@ -197,13 +234,11 @@ version(yap,[6,3]). :- use_module('../swi/library/menu.pl'). :- use_module('../library/ypp.yap'). - - yap_hacks:cut_by(CP) :- '$$cut_by'(CP). :- '$change_type_of_char'(36,7). % Make $ a symbol character -:- '$swi_set_prolog_flag'(generate_debug_info,true). +:- set_prolog_flag(generate_debug_info,true). :- recorda('$dialect',yap,_). @@ -233,36 +268,6 @@ yap_hacks:cut_by(CP) :- '$$cut_by'(CP). :- module(user). -/** @pred _CurrentModule_:goal_expansion(+ _G_,+ _M_,- _NG_), user:goal_expansion(+ _G_,+ _M_,- _NG_) - - -YAP now supports goal_expansion/3. This is an user-defined -procedure that is called after term expansion when compiling or -asserting goals for each sub-goal in a clause. The first argument is -bound to the goal and the second to the module under which the goal - _G_ will execute. If goal_expansion/3 succeeds the new -sub-goal _NG_ will replace _G_ and will be processed in the same -way. If goal_expansion/3 fails the system will use the default -rules. - - -*/ -:- multifile goal_expansion/3. - -:- dynamic goal_expansion/3. - -:- multifile goal_expansion/2. - -:- dynamic goal_expansion/2. - -:- multifile system:goal_expansion/2. - -:- dynamic system:goal_expansion/2. - -:- multifile goal_expansion/2. - -:- dynamic goal_expansion/2. - /** @pred _CurrentModule_:term_expansion( _T_,- _X_), user:term_expansion( _T_,- _X_) @@ -312,10 +317,6 @@ modules defining clauses for it too. :- dynamic user:message_hook/3. -:- multifile user:portray_message/2. - -:- dynamic user:portray_message/2. - /** @pred exception(+ _Exception_, + _Context_, - _Action_) @@ -338,12 +339,10 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th :- dynamic user:exception/3. -:- yap_flag(unknown,error). +:- yap_flag(user:unknown,error). :- stream_property(user_input, tty(true)) -> set_prolog_flag(readline, true) ; true. - - /** @} */ diff --git a/pl/listing.yap b/pl/listing.yap index 7591d5550..ec8b7a4f7 100644 --- a/pl/listing.yap +++ b/pl/listing.yap @@ -117,7 +117,7 @@ listing(Stream, [MV|MVs]) :- !, ). % -% at this point we are ground and wew know who we want to list. +% at this point we are ground and we know who we want to list. % '$listing'(Name, Arity, M, Stream) :- % skip by default predicates starting with $ @@ -131,7 +131,7 @@ listing(Stream, [MV|MVs]) :- !, '$do_error'(domain_error(predicate_spec,Name),listing(Name)). '$list_clauses'(Stream, M, Pred) :- - '$flags'(Pred,M,Flags,Flags), + '$predicate_flags'(Pred,M,Flags,Flags), (Flags /\ 0x48602000 =\= 0 -> nl(Stream), @@ -192,7 +192,7 @@ listing(Stream, [MV|MVs]) :- !, nl( Stream ), fail. '$list_clauses'(Stream, M, Pred) :- - '$flags'(Pred,M,Flags,Flags), + '$predicate_flags'(Pred,M,Flags,Flags), % has to be dynamic, source, or log update. Flags /\ 0x08402000 =\= 0, '$clause'(Pred, M, Body, _),