small changes
This commit is contained in:
parent
f41a8c19ef
commit
880a9989c3
@ -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 $<$<CONFIG:Debug>:DEBUG=1;LOW_LEVEL_TRACER=1> )
|
||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>: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
|
||||
|
@ -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 <string.h>
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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 <readline/history.h> header file. */
|
||||
#ifndef HAVE_READLINE_HISTORY_H
|
||||
#define HAVE_READLINE_HISTORY_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <readline/readline.h> 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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e0e072ad7fbe7558e69197135cc657a02365224a
|
||||
Subproject commit e9135f8b6e2058f7133a7c16e2eb33ffa47749fc
|
36
pl/boot.yap
36
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 *
|
||||
* *
|
||||
@ -253,6 +253,8 @@ private(_).
|
||||
'$undefp'/1,
|
||||
'$version'/0]).
|
||||
|
||||
'$undefp'(G, _) :- writeln(G), fail.
|
||||
|
||||
:- use_system_module( '$_absf', ['$system_library_directories'/2]).
|
||||
|
||||
:- use_system_module( '$_checker', ['$check_term'/5,
|
||||
@ -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 ->
|
||||
@ -1383,7 +1382,7 @@ bootstrap(F) :-
|
||||
'$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
|
||||
'$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]).
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -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).
|
||||
@ -466,10 +466,10 @@ load_files(Files,Opts) :-
|
||||
% 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
|
||||
'$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),
|
||||
|
38
pl/init.yap
38
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,10 +123,13 @@ otherwise.
|
||||
|
||||
:-set_prolog_flag(verbose, normal).
|
||||
|
||||
:- [ 'directives.yap',
|
||||
:-set_prolog_flag(gc_trace, verbose).
|
||||
|
||||
:- [
|
||||
'arith.yap',
|
||||
'directives.yap',
|
||||
'utils.yap',
|
||||
'control.yap',
|
||||
'arith.yap',
|
||||
'flags.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 ).
|
||||
*/
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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) :-
|
||||
|
Reference in New Issue
Block a user