diff --git a/C/args.c b/C/args.c index ae6c282f9..10f316299 100644 --- a/C/args.c +++ b/C/args.c @@ -63,7 +63,7 @@ Yap_ArgListToVector (Term listl, const param_t *def, int n) arity_t arity = ArityOfFunctor( f ); if (arity != 1) { LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE; - LOCAL_Error_Term = hd; + LOCAL_Error_Term = hd; free( a ); return NULL; } diff --git a/CMakeLists.txt b/CMakeLists.txt index e11591e9e..945e6a2cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,7 @@ set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _YAP_NOT_INSTALLED_ #add_definitions( -Wall -Wstrict-prototypes -Wmissing-prototypes) # Model Specific -#set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG=1;LOW_LEVEL_TRACER=1> ) +set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:DEBUG=1;LOW_LEVEL_TRACER=1> ) set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEBUG=1;LOW_LEVEL_TRACER=1 ) #ensure cells are properly aligned in code diff --git a/OPTYap/opt.preds.c b/OPTYap/opt.preds.c index c515ae72c..fd2ce8c26 100644 --- a/OPTYap/opt.preds.c +++ b/OPTYap/opt.preds.c @@ -19,7 +19,6 @@ #if defined(YAPOR) || defined(TABLING) #include "Yatom.h" #include "YapHeap.h" -#include "SWI-Prolog.h" #ifdef YAPOR #if HAVE_STRING_H #include diff --git a/library/dialect/swi/fli/swi.c b/library/dialect/swi/fli/swi.c index 833330cd9..8cfd487ce 100755 --- a/library/dialect/swi/fli/swi.c +++ b/library/dialect/swi/fli/swi.c @@ -249,8 +249,6 @@ int PL_get_wchars(term_t l, size_t *lengthp, wchar_t **s, unsigned flags) CACHE_REGS seq_tv_t inp, out; size_t leng; - encoding_t enc; - int minimal; void *buf = NULL; inp.val.t = Yap_GetFromSlot( l ); inp.type = cvtFlags( flags ); @@ -721,6 +719,8 @@ X_API int PL_get_functor(term_t ts, functor_t *f) Term t = Yap_GetFromSlot(ts); if ( IsAtomTerm(t)) { *f = t; + } else if ( IsPairTerm(t)) { + *f = FunctorToSWIFunctor(FunctorDot); } else { *f = FunctorToSWIFunctor(FunctorOfTerm(t)); } diff --git a/os/YapIOConfig.h b/os/YapIOConfig.h index 1825782cf..b1e3b24c5 100644 --- a/os/YapIOConfig.h +++ b/os/YapIOConfig.h @@ -1,6 +1,16 @@ /* Define if you have libreadline */ #ifndef HAVE_LIBREADLINE -#define HAVE_LIBREADLINE YES +#define HAVE_LIBREADLINE 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_READLINE_HISTORY_H +#define HAVE_READLINE_HISTORY_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef HAVE_READLINE_READLINE_H +#define HAVE_READLINE_READLINE_H 1 #endif /* Define to 1 if you have the declaration of `rl_catch_signals ', and to 0 if @@ -96,4 +106,3 @@ you don't. */ #ifndef HAVE_RL_SET_PROMPT #define HAVE_RL_SET_PROMPT 1 #endif - diff --git a/os/format.c b/os/format.c index 038d3ac51..e48a7bd2a 100644 --- a/os/format.c +++ b/os/format.c @@ -491,8 +491,9 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS) ptr[1] = '\0'; { char *tmp2; - if (!(tmp2 = Yap_AllocCodeSpace(repeats+10))) + if (!(tmp2 = Yap_AllocCodeSpace(repeats+10))) { goto do_type_int_error; + } #if HAVE_SNPRINTF snprintf (tmp2, repeats+10, tmp1, fl); #else @@ -545,6 +546,7 @@ doformat(volatile Term otail, volatile Term oargs, int sno USES_REGS) tmpbase = NULL; } else { tmpbase = res; + goto do_type_int_error; } } diff --git a/packages/real b/packages/real index e0e072ad7..e9135f8b6 160000 --- a/packages/real +++ b/packages/real @@ -1 +1 @@ -Subproject commit e0e072ad7fbe7558e69197135cc657a02365224a +Subproject commit e9135f8b6e2058f7133a7c16e2eb33ffa47749fc diff --git a/pl/boot.yap b/pl/boot.yap index d8f417df3..76e88f46f 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -2,7 +2,7 @@ * * * YAP Prolog * * * - * Yap Prolog was developed at NCCUP - Universidade do Porto * +* Yap Prolog was developed at NCCUP - Universidade do Porto * * * * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2014 * * * @@ -251,7 +251,9 @@ private(_). '$run_at_thread_start'/0, '$system_catch'/4, '$undefp'/1, - '$version'/0]). + '$version'/0]). + +'$undefp'(G, _) :- writeln(G), fail. :- use_system_module( '$_absf', ['$system_library_directories'/2]). @@ -433,7 +435,7 @@ true :- true. [trace, end_of_file], Prompt, Goal, Bindings), !, (nonvar(Err) -> - print_message(error,Err), fail + '$early_print'(error,Err), fail ; true ). @@ -479,7 +481,7 @@ true :- true. ; true ), - print_message(informational,prompt(BreakLevel,TraceDebug)), + '$early_print'(informational,prompt(BreakLevel,TraceDebug)), fail. '$enter_top_level' :- get_value('$top_level_goal',GA), GA \= [], !, @@ -757,7 +759,7 @@ number of steps. recorded('$import','$import'(NM,Mod,NH,H,_,_),R), NM \= Mod, functor(NH,N,Ar), - print_message(warning,redefine_imported(Mod,NM,N/Ar)), + '$early_print'(warning,redefine_imported(Mod,NM,N/Ar)), erase(R), fail. '$not_imported'(_, _). @@ -848,13 +850,10 @@ number of steps. ). '$out_neg_answer' :- - ( '$undefined'(print_message(_,_),prolog) -> - '$present_answer'(user_error,'false.~n') - ; - print_message(help,false) - ), + '$early_print'( help, false), fail. + '$do_yes_no'([X|L], M) :- !, '$csult'([X|L], M). @@ -895,10 +894,10 @@ number of steps. fail ; C== 10 -> '$add_nl_outside_console', - ( '$undefined'(print_message(_,_),prolog) -> + ( '$undefined'('$early_print'(_,_),prolog) -> format(user_error,'yes~n', []) ; - print_message(help,yes) + '$early_print'(help,yes) ) ; C== 13 -> @@ -1380,10 +1379,10 @@ bootstrap(F) :- '$enter_command'(Stream,Mod,top) :- !, read_term(Stream, Command, [module(Mod), syntax_errors(dec10),variable_names(Vars), term_position(Pos)]), - '$command'(Command,Vars,Pos,Status). + '$command'(Command,Vars,Pos,Status). '$enter_command'(Stream,Mod,Status) :- - read_clause(Stream, Command, [variable_names(Vars), term_position(Pos)]), - '$command'(Command,Vars,Pos,Status).1 + read_clause(Stream, Command, [variable_names(Vars), term_position(Pos)]), + '$command'(Command,Vars,Pos,Status). '$abort_loop'(Stream) :- '$do_error'(permission_error(input,closed_stream,Stream), loop). @@ -1580,6 +1579,19 @@ log_event( String, Args ) :- format( atom( M ), String, Args), log_event( M ). +'$early_print'( Lev, Msg ) :- + ( '$undefined'(print_message(_,_),prolog) -> + '$show'(Lev, Msg) + ; + print_message(Lev, Msg) + ). + +'$show'(_,Msg) :- + format(user_error, '~w~n', [Msg]). + + + + /** @} */ diff --git a/pl/consult.yap b/pl/consult.yap index 73553b60a..a1dd10db0 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -227,7 +227,7 @@ load_files(Files,Opts) :- '$lf_option'(dialect, 20, yap). '$lf_option'(format, 21, source). '$lf_option'(redefine_module, 22, Warn) :- - ( var(Warn) -> current_prolog_flag( redefine_warnings, Redefine ), Redefine = Warn ; true )). + ( 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). @@ -465,11 +465,11 @@ load_files(Files,Opts) :- % 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,_), - ( '$q_header'( Stream, Type ), - Type == file + open( F, read, Stream , [type(binary)] ), + '$q_header'( Stream, Type ), + ( Type == file -> + H0 is heapused, '$cputime'(T0,_), time_file64(F, T0F), stream_property(PlStream, file_name(FilePl)), time_file64(FilePl, T0Fl), @@ -485,7 +485,7 @@ load_files(Files,Opts) :- working_directory( _, OldD), '$lf_opt'('$location', TOpts, ParentF:_Line), '$reexport'( TOpts, ParentF, Reexport, ImportList, File ), - print_message(Verbosity, loaded( loaded, F, M, T, H)), + '$early_print'(Verbosity, loaded( loaded, F, M, T, H)), % stop_low_level_trace, '$exec_initialisation_goals' ; @@ -686,7 +686,7 @@ db_files(Fs) :- StartMsg = consulting, EndMsg = consulted ), - print_message(Verbosity, loading(StartMsg, UserFile)), + '$early_print'(Verbosity, loading(StartMsg, UserFile)), '$lf_opt'(skip_unix_header , TOpts, SkipUnixHeader), ( SkipUnixHeader == true -> @@ -699,7 +699,7 @@ db_files(Fs) :- '$import_to_current_module'(File, ContextModule, Imports, _, TOpts), '$current_module'(Mod, SourceModule), H is heapused-H0, '$cputime'(TF,_), T is TF-T0, - print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)), + '$early_print'(Verbosity, loaded(EndMsg, File, Mod, T, H)), '$end_consult', '$q_do_save_file'(File, UserFile, TOpts ), ( @@ -855,12 +855,12 @@ db_files(Fs) :- '$loaded'(Y, X, Mod, _OldY, _L, include, _, Dir, []), ( '$nb_getval'('$included_file', OY, fail ) -> true ; OY = [] ), nb_setval('$included_file', Y), - print_message(Verbosity, loading(including, Y)), + '$early_print'(Verbosity, loading(including, Y)), '$loop'(Stream,Status), 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)), + '$early_print'(Verbosity, loaded(included, Y, Mod, T, H)), working_directory(_Dir, Dir0), nb_setval('$included_file',OY). @@ -993,8 +993,7 @@ prolog_load_context(source, F0) :- F0 = user_input ). prolog_load_context(stream, Stream) :- - '$nb_getval'('$consulting_file', _, fail), - '$current_loop_stream'(Stream). + stream_property(Stream, alias(loop_stream) ). % if the file exports a module, then we can @@ -1032,7 +1031,7 @@ prolog_load_context(stream, Stream) :- '$file_is_unchanged'(F, R, Age), !, % ( F = '/usr/local/share/Yap/rbtrees.yap' ->start_low_level_trace ; true), - recorded('$module','$module'(F,NM,_ASource,_P,_),_) + recorded('$module','$module'(F,NM,_ASource,_P,_),_), ( M == NM -> true ; recorded('$module','$module'(F,NM,_Source,_P,_),_) ), !. '$file_is_unchanged'(F, R, Age) :- @@ -1345,7 +1344,7 @@ last one, onto underscores. '$add_multifile'(File,Name,Arity,Module) :- recorded('$multifile_defs','$defined'(File,Name,Arity,Module), _), !. -% print_message(warning,declaration((multifile Module:Name/Arity),ignored)). +% '$early_print'(warning,declaration((multifile Module:Name/Arity),ignored)). '$add_multifile'(File,Name,Arity,Module) :- recordz('$multifile_defs','$defined'(File,Name,Arity,Module),_), !, fail. @@ -1617,7 +1616,7 @@ End of conditional compilation. '$if_call'(G) :- - catch('$eval_if'(G), E, (print_message(error, E), fail)). + catch('$eval_if'(G), E, ('$early_print'(error, E), fail)). '$eval_if'(Goal) :- expand_term(Goal,TrueGoal), diff --git a/pl/init.yap b/pl/init.yap index 7e4a8ce6a..b58a9c586 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -2,7 +2,7 @@ * * * YAP Prolog * * * -* Yap Prolog was developed at NCCUP - Universidade do Porto * +** Yap Prolog was developed at NCCUP - Universidade do Porto * * * * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * * * @@ -123,11 +123,14 @@ otherwise. :-set_prolog_flag(verbose, normal). -:- [ 'directives.yap', - 'utils.yap', - 'control.yap', - 'arith.yap', - 'flags.yap' +:-set_prolog_flag(gc_trace, verbose). + +:- [ + 'arith.yap', + 'directives.yap', + 'utils.yap', + 'control.yap', + 'flags.yap' ]. :- [ 'preds.yap', @@ -332,10 +335,39 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th :- dynamic user:exception/3. +/* + Add some tests +*/ :- yap_flag(user:unknown,error). :- stream_property(user_input, tty(true)) -> set_prolog_flag(readline, true) ; true. +aa b. + +p(X,Y) :- Y is X*X. + +prefix(information, '% ', S, user_error) --> []. + +:- format('~d~n', [a]). + +:- format('~d~n', []). + +:- p(X,Y). + +a(1). + +a. + +a(2). +a(2). + +lists:member(1,[1]). + +clause_to_indicator(T, M:Name/Arity) :- , + strip_module(T, M, T1), + pred_arity( T1, Name, Arity ). +*/ + /** @} */ diff --git a/pl/lists.yap b/pl/lists.yap index 682d31d26..6644280f0 100644 --- a/pl/lists.yap +++ b/pl/lists.yap @@ -52,7 +52,7 @@ lists:append([H|T], L, [H|R]) :- lists:append(T, L, R). -:- set_prolog_flag(source, false)). % :- no_source. +:- set_prolog_flag(source, false). % :- no_source. % lists:delete(List, Elem, Residue) % is true when List is a list, in which Elem may or may not occur, and diff --git a/pl/qly.yap b/pl/qly.yap index b6db8d9da..c9005ae94 100755 --- a/pl/qly.yap +++ b/pl/qly.yap @@ -527,13 +527,15 @@ qload_module(Mod) :- ). '$qload_module'(Mod, File, SourceModule) :- open(File, read, S, [type(binary)]), - '$q_header'( S, Type ), + %check verifies if a saved state; + '$q_header'( S, Type ), !, ( Type == module -> '$qload_module'(S , Mod, File, SourceModule) ; Type == file -> '$qload_file'(S, File) ), + !, close(S). '$qload_module'(_S, Mod, _File, _SourceModule) :-