mkdir and small stuff
This commit is contained in:
parent
33de6766a5
commit
1d6f9981e1
@ -9,6 +9,7 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
# set path to additional CMake modules
|
# set path to additional CMake modules
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
set(CMAKE_PREFIX_PATH ~/Qt/5.4/clang_64/ ${CMAKE_PREFIX_PATH})
|
||||||
|
|
||||||
set(configurations Debug)
|
set(configurations Debug)
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ message(STATUS "Building YAP version ${YAP_VERSION}")
|
|||||||
#
|
#
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
include(CheckIncludeFileCXX)
|
include(CheckIncludeFileCXX)
|
||||||
INCLUDE (CheckIncludeFiles)
|
include (CheckIncludeFiles)
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
@ -528,6 +529,7 @@ configure_file ("${PROJECT_SOURCE_DIR}/YapTermConfig.h.cmake"
|
|||||||
"${PROJECT_BINARY_DIR}/YapTermConfig.h" )
|
"${PROJECT_BINARY_DIR}/YapTermConfig.h" )
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/GitSHA1.c.in" "${PROJECT_BINARY_DIR}/GitSHA1.c" @ONLY)
|
configure_file("${PROJECT_SOURCE_DIR}/GitSHA1.c.in" "${PROJECT_BINARY_DIR}/GitSHA1.c" @ONLY)
|
||||||
|
|
||||||
|
ADD_SUBDIRECTORY(console/terminal)
|
||||||
|
|
||||||
|
|
||||||
install (
|
install (
|
||||||
|
@ -196,6 +196,7 @@ typedef enum {
|
|||||||
|
|
||||||
#define YAP_CONSULT_MODE 0
|
#define YAP_CONSULT_MODE 0
|
||||||
#define YAP_RECONSULT_MODE 1
|
#define YAP_RECONSULT_MODE 1
|
||||||
|
#define YAP_BOOT_MODE 2
|
||||||
|
|
||||||
typedef struct yap_boot_params {
|
typedef struct yap_boot_params {
|
||||||
/* if NON-NULL, path where we can find the saved state */
|
/* if NON-NULL, path where we can find the saved state */
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
file_filter/3,
|
file_filter/3,
|
||||||
file_select/2,
|
file_select/2,
|
||||||
file_filter_with_initialization/5,
|
file_filter_with_initialization/5,
|
||||||
|
file_filter_with_initialization/5 as file_filter_with_init,
|
||||||
process/2
|
process/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ RL_Tree* set_in_rl(RL_Tree* tree,NUM number,STATUS status) {
|
|||||||
if ( number >0 && number <=tree->range_max)
|
if ( number >0 && number <=tree->range_max)
|
||||||
set_in(number,ROOT(tree),1,ROOT_INTERVAL(tree),tree->range_max,tree,status);
|
set_in(number,ROOT(tree),1,ROOT_INTERVAL(tree),tree->range_max,tree,status);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Setting: %ul size=%ul\n",number,tree->size);
|
printf("Setting: %lu size=%lu\n",number,tree->size);
|
||||||
#endif
|
#endif
|
||||||
/*if (status==IN && !in_rl(tree,number)) {
|
/*if (status==IN && !in_rl(tree,number)) {
|
||||||
fprintf(stderr,"Error adding %lu to tree: size=%lu max=%lu\n",number,tree->size,tree->range_max);
|
fprintf(stderr,"Error adding %lu to tree: size=%lu max=%lu\n",number,tree->size,tree->range_max);
|
||||||
|
@ -211,13 +211,6 @@ Unify _Name_ with a name for the current host. YAP uses the
|
|||||||
`GetComputerName` function in WIN32 systems.
|
`GetComputerName` function in WIN32 systems.
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
/** @pred make_directory(+ _Dir_)
|
|
||||||
|
|
||||||
|
|
||||||
Create a directory _Dir_. The name of the directory must be an atom.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/** @pred mktemp( _Spec_,- _File_)
|
/** @pred mktemp( _Spec_,- _File_)
|
||||||
|
|
||||||
|
@ -355,21 +355,6 @@ p_unlink(void)
|
|||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static YAP_Bool
|
|
||||||
p_mkdir(void)
|
|
||||||
{
|
|
||||||
char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
|
|
||||||
#if defined(__MINGW32__) || _MSC_VER
|
|
||||||
if (_mkdir(fd) == -1) {
|
|
||||||
#else
|
|
||||||
if (mkdir(fd, 0777) == -1) {
|
|
||||||
#endif
|
|
||||||
/* return an error number */
|
|
||||||
return(YAP_Unify(YAP_ARG2, YAP_MkIntTerm(errno)));
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static YAP_Bool
|
static YAP_Bool
|
||||||
p_rmdir(void)
|
p_rmdir(void)
|
||||||
{
|
{
|
||||||
@ -1131,7 +1116,6 @@ init_sys(void)
|
|||||||
YAP_UserCPredicate("list_directory", list_directory, 3);
|
YAP_UserCPredicate("list_directory", list_directory, 3);
|
||||||
YAP_UserCPredicate("file_property", file_property, 7);
|
YAP_UserCPredicate("file_property", file_property, 7);
|
||||||
YAP_UserCPredicate("unlink", p_unlink, 2);
|
YAP_UserCPredicate("unlink", p_unlink, 2);
|
||||||
YAP_UserCPredicate("mkdir", p_mkdir, 2);
|
|
||||||
YAP_UserCPredicate("rmdir", p_rmdir, 2);
|
YAP_UserCPredicate("rmdir", p_rmdir, 2);
|
||||||
YAP_UserCPredicate("dir_separator", dir_separator, 1);
|
YAP_UserCPredicate("dir_separator", dir_separator, 1);
|
||||||
YAP_UserCPredicate("p_environ", p_environ, 2);
|
YAP_UserCPredicate("p_environ", p_environ, 2);
|
||||||
|
@ -342,6 +342,7 @@ A STRING F "String"
|
|||||||
A Swi N "swi"
|
A Swi N "swi"
|
||||||
A SymbolChar N "symbol_char"
|
A SymbolChar N "symbol_char"
|
||||||
A SyntaxError N "syntax_error"
|
A SyntaxError N "syntax_error"
|
||||||
|
A SyntaxErrors N "syntax_errors"
|
||||||
A SyntaxErrorHandler N "syntax_error_handler"
|
A SyntaxErrorHandler N "syntax_error_handler"
|
||||||
A System N "system"
|
A System N "system"
|
||||||
A SystemError N "system_error"
|
A SystemError N "system_error"
|
||||||
|
@ -12,6 +12,8 @@ int c_error_stream =2
|
|||||||
|
|
||||||
bool sockets_io =false
|
bool sockets_io =false
|
||||||
|
|
||||||
|
bool within_print_message =false
|
||||||
|
|
||||||
//
|
//
|
||||||
// Used by the prompts to check if they are after a newline, and then a
|
// Used by the prompts to check if they are after a newline, and then a
|
||||||
// prompt should be output, or if we are in the middle of a line.
|
// prompt should be output, or if we are in the middle of a line.
|
||||||
@ -94,7 +96,9 @@ UInt IPredArity =0L
|
|||||||
yamop* ProfEnd =NULL
|
yamop* ProfEnd =NULL
|
||||||
int UncaughtThrow =FALSE
|
int UncaughtThrow =FALSE
|
||||||
int DoingUndefp =FALSE
|
int DoingUndefp =FALSE
|
||||||
Int StartLine =0L
|
Int StartCharCount =0L
|
||||||
|
Int StartLineCount =0L
|
||||||
|
Int StartLinePos =0L
|
||||||
scratch_block ScratchPad InitScratchPad(wid)
|
scratch_block ScratchPad InitScratchPad(wid)
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
Term WokenGoals =0L TermToGlobalAdjust
|
Term WokenGoals =0L TermToGlobalAdjust
|
||||||
|
@ -62,4 +62,3 @@ gen_decl(Inp,Out) :-
|
|||||||
%gen_decl(Inp,Out) :-
|
%gen_decl(Inp,Out) :-
|
||||||
% split(Inp," ",["F",Name,Arity]), !,
|
% split(Inp," ",["F",Name,Arity]), !,
|
||||||
% append([" Functor_",Name,Arity," = Yap_MkFunctor(Atom_",Name,",",Arity,");"],Out).
|
% append([" Functor_",Name,Arity," = Yap_MkFunctor(Atom_",Name,",",Arity,");"],Out).
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ add_implies(DdManager *manager, DdNode *x1, DdNode *x2)
|
|||||||
{
|
{
|
||||||
DdNode *tmp;
|
DdNode *tmp;
|
||||||
|
|
||||||
tmp = Cudd_addApply(manager,Cudd_addLeq,x1,x2);
|
tmp = Cudd_addConst(manager,Cudd_addLeq(manager,x1,x2));
|
||||||
Cudd_Ref(tmp);
|
Cudd_Ref(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -878,7 +878,7 @@ p_cudd_print_with_names(void)
|
|||||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||||
const char *s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3));
|
const char *s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3));
|
||||||
char **namesp;
|
const char **namesp;
|
||||||
YAP_Term names = YAP_ARG4;
|
YAP_Term names = YAP_ARG4;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
YAP_Int len;
|
YAP_Int len;
|
||||||
@ -918,7 +918,7 @@ p_cudd_print_with_names(void)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
free(namesp[i]);
|
free((void *)namesp[i]);
|
||||||
}
|
}
|
||||||
free( namesp );
|
free( namesp );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -64,7 +64,8 @@
|
|||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") YAPCallback;
|
%feature("director") YAPCallback;
|
||||||
|
|
||||||
%include "yapi.hh"
|
|
||||||
|
// %include "yapi.hh"
|
||||||
|
|
||||||
%include "yapa.hh"
|
%include "yapa.hh"
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ absolute_file_name(File0,File) :-
|
|||||||
/* our own local findall */
|
/* our own local findall */
|
||||||
nb:nb_queue(Ref),
|
nb:nb_queue(Ref),
|
||||||
(
|
(
|
||||||
'$find_in_path'(File,opts(Extensions,RelTo,Type,Access,Errors,Expand,Debug),TrueFileName,G),
|
'$find_in_path'(File,opts(Extensions,RelTo,Type,Access,FErrors,Expand,Debug),TrueFileName,G),
|
||||||
nb:nb_queue_enqueue(Ref, TrueFileName),
|
nb:nb_queue_enqueue(Ref, TrueFileName),
|
||||||
fail
|
fail
|
||||||
;
|
;
|
||||||
@ -672,4 +672,3 @@ user:file_search_path(path, C) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
%%@}
|
%%@}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
%
|
%
|
||||||
% These are the array built-in predicates. They will only work if
|
% These are the array built-in predicates. They will only work if
|
||||||
% YAP_ARRAYS is defined in Yap.h.m4.
|
% YAP_ARRAYS is defined in Yap.h
|
||||||
%
|
%
|
||||||
|
|
||||||
/** @pred array(+ _Name_, + _Size_)
|
/** @pred array(+ _Name_, + _Size_)
|
||||||
|
16
pl/boot.yap
16
pl/boot.yap
@ -442,7 +442,7 @@ true :- true.
|
|||||||
prompt(_,'|: '),
|
prompt(_,'|: '),
|
||||||
'$system_catch'(read_term(user_input,
|
'$system_catch'(read_term(user_input,
|
||||||
Goal,
|
Goal,
|
||||||
[variable_names(Bindings)]),
|
[variable_names(Bindings), syntax_errors(dec10)]),
|
||||||
prolog, E, '$handle_toplevel_error'( E) ).
|
prolog, E, '$handle_toplevel_error'( E) ).
|
||||||
|
|
||||||
'$handle_toplevel_error'( syntax_error(_)) :-
|
'$handle_toplevel_error'( syntax_error(_)) :-
|
||||||
@ -1123,10 +1123,6 @@ incore(G) :- '$execute'(G).
|
|||||||
'$creep'.
|
'$creep'.
|
||||||
'$enable_debugging'.
|
'$enable_debugging'.
|
||||||
|
|
||||||
'$disable_debugging' :-
|
|
||||||
'$stop_creeping'.
|
|
||||||
|
|
||||||
|
|
||||||
/** @pred :_P_ , :_Q_ is iso, meta
|
/** @pred :_P_ , :_Q_ is iso, meta
|
||||||
Conjunction of goals (and).
|
Conjunction of goals (and).
|
||||||
|
|
||||||
@ -1365,8 +1361,12 @@ bootstrap(F) :-
|
|||||||
user:'$LoopError'(Error, Status)),
|
user:'$LoopError'(Error, Status)),
|
||||||
!.
|
!.
|
||||||
|
|
||||||
|
'$enter_command'(Stream,Mod,top) :- !,
|
||||||
|
writeln(top),
|
||||||
|
read_term(Stream, Command, [module(Mod), syntax_errors(dec10),variable_names(Vars), term_position(Pos)]),
|
||||||
|
'$command'(Command,Vars,Pos,Status).
|
||||||
'$enter_command'(Stream,Mod,Status) :-
|
'$enter_command'(Stream,Mod,Status) :-
|
||||||
read_term(Stream, Command, [variable_names(Vars), term_position(Pos), syntax_errors(dec10) ]),
|
read_clause(Stream, Command, [variable_names(Vars), term_position(Pos)]),
|
||||||
'$command'(Command,Vars,Pos,Status).
|
'$command'(Command,Vars,Pos,Status).
|
||||||
|
|
||||||
'$abort_loop'(Stream) :-
|
'$abort_loop'(Stream) :-
|
||||||
@ -1421,8 +1421,7 @@ bootstrap(F) :-
|
|||||||
This predicate is used by YAP for preprocessing each top level
|
This predicate is used by YAP for preprocessing each top level
|
||||||
term read when consulting a file and before asserting or executing it.
|
term read when consulting a file and before asserting or executing it.
|
||||||
It rewrites a term _T_ to a term _X_ according to the following
|
It rewrites a term _T_ to a term _X_ according to the following
|
||||||
rules: first try term_expansion/2 in the current module, and then try to use the user defined predicate
|
rules: first try term_expansion/2 in the current module, and then try to use the user defined predicate user:term_expansion/2`. If this call fails then the translating process
|
||||||
`user:term_expansion/2`. If this call fails then the translating process
|
|
||||||
for DCG rules is applied, together with the arithmetic optimizer
|
for DCG rules is applied, together with the arithmetic optimizer
|
||||||
whenever the compilation of arithmetic expressions is in progress.
|
whenever the compilation of arithmetic expressions is in progress.
|
||||||
|
|
||||||
@ -1568,4 +1567,3 @@ log_event( String, Args ) :-
|
|||||||
/**
|
/**
|
||||||
@}
|
@}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -649,7 +649,6 @@ db_files(Fs) :-
|
|||||||
'$extract_minus'([-F|Fs], [F|MFs]) :-
|
'$extract_minus'([-F|Fs], [F|MFs]) :-
|
||||||
'$extract_minus'(Fs, MFs).
|
'$extract_minus'(Fs, MFs).
|
||||||
|
|
||||||
|
|
||||||
'$do_lf'(ContextModule, Stream, UserFile, File, TOpts) :-
|
'$do_lf'(ContextModule, Stream, UserFile, File, TOpts) :-
|
||||||
stream_property(OldStream, alias(loop_stream) ),
|
stream_property(OldStream, alias(loop_stream) ),
|
||||||
'$lf_opt'(encoding, TOpts, Encoding),
|
'$lf_opt'(encoding, TOpts, Encoding),
|
||||||
@ -843,18 +842,19 @@ db_files(Fs) :-
|
|||||||
b_getval('$lf_status', TOpts),
|
b_getval('$lf_status', TOpts),
|
||||||
'$msg_level'( TOpts, Verbosity),
|
'$msg_level'( TOpts, Verbosity),
|
||||||
'$full_filename'(X, Y , ( :- include(X)) ),
|
'$full_filename'(X, Y , ( :- include(X)) ),
|
||||||
|
writeln((X:Y)),
|
||||||
'$lf_opt'(stream, TOpts, OldStream),
|
'$lf_opt'(stream, TOpts, OldStream),
|
||||||
source_location(OldY, L),
|
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
( open(Y, read, Stream) ->
|
( open(Y, read, Stream) ->
|
||||||
true ;
|
true ;
|
||||||
'$do_error'(permission_error(input,stream,Y),include(X))
|
'$do_error'(permission_error(input,stream,Y),include(X))
|
||||||
),
|
),
|
||||||
|
file_directory_name(Y, Dir),
|
||||||
H0 is heapused, '$cputime'(T0,_),
|
H0 is heapused, '$cputime'(T0,_),
|
||||||
working_directory(Dir, Dir),
|
working_directory(Dir0, Dir),
|
||||||
'$lf_opt'(encoding, TOpts, Encoding),
|
'$lf_opt'(encoding, TOpts, Encoding),
|
||||||
set_stream(Stream, [encoding(Encoding),alias(loop_stream)] ),
|
set_stream(Stream, [encoding(Encoding),alias(loop_stream)] ),
|
||||||
'$loaded'(Y, X, Mod, OldY, L, include, _, Dir, []),
|
'$loaded'(Y, X, Mod, _OldY, _L, include, _, Dir, []),
|
||||||
( '$nb_getval'('$included_file', OY, fail ) -> true ; OY = [] ),
|
( '$nb_getval'('$included_file', OY, fail ) -> true ; OY = [] ),
|
||||||
nb_setval('$included_file', Y),
|
nb_setval('$included_file', Y),
|
||||||
print_message(Verbosity, loading(including, Y)),
|
print_message(Verbosity, loading(including, Y)),
|
||||||
@ -863,6 +863,7 @@ db_files(Fs) :-
|
|||||||
close(Stream),
|
close(Stream),
|
||||||
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
||||||
print_message(Verbosity, loaded(included, Y, Mod, T, H)),
|
print_message(Verbosity, loaded(included, Y, Mod, T, H)),
|
||||||
|
working_directory(_Dir, Dir0),
|
||||||
nb_setval('$included_file',OY).
|
nb_setval('$included_file',OY).
|
||||||
|
|
||||||
|
|
||||||
@ -970,6 +971,7 @@ most files in the library are from the Edinburgh Prolog library.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
prolog_load_context(directory, DirName) :-
|
prolog_load_context(directory, DirName) :-
|
||||||
|
strat_low_level_trace,
|
||||||
( source_location(F, _)
|
( source_location(F, _)
|
||||||
-> file_directory_name(F, DirName) ;
|
-> file_directory_name(F, DirName) ;
|
||||||
working_directory( DirName, DirName )
|
working_directory( DirName, DirName )
|
||||||
@ -997,6 +999,7 @@ prolog_load_context(stream, Stream) :-
|
|||||||
'$nb_getval'('$consulting_file', _, fail),
|
'$nb_getval'('$consulting_file', _, fail),
|
||||||
'$current_loop_stream'(Stream).
|
'$current_loop_stream'(Stream).
|
||||||
prolog_load_context(term_position, Position) :-
|
prolog_load_context(term_position, Position) :-
|
||||||
|
'$current_loop_stream'(Stream)
|
||||||
stream_property( Stream, [alias(loop_stream),position(Position)] ).
|
stream_property( Stream, [alias(loop_stream),position(Position)] ).
|
||||||
|
|
||||||
|
|
||||||
|
@ -848,6 +848,7 @@ be lost.
|
|||||||
fail /* to backtrack to spycalls */
|
fail /* to backtrack to spycalls */
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
'$stop_creeping',
|
||||||
'$show_trace'(fail,G,Module,GoalNumber,_), /* inform at fail port */
|
'$show_trace'(fail,G,Module,GoalNumber,_), /* inform at fail port */
|
||||||
'$continue_debugging'(fail, CalledFromDebugger),
|
'$continue_debugging'(fail, CalledFromDebugger),
|
||||||
/* fail port */
|
/* fail port */
|
||||||
|
@ -31,4 +31,3 @@ system_module( '$_depth_bound', [depth_bound_call/2], []).
|
|||||||
%write(depth_bound_call(A,D)), nl, fail.
|
%write(depth_bound_call(A,D)), nl, fail.
|
||||||
depth_bound_call(A,D) :-
|
depth_bound_call(A,D) :-
|
||||||
'$execute_under_depth_limit'(A,D).
|
'$execute_under_depth_limit'(A,D).
|
||||||
|
|
||||||
|
@ -6,10 +6,17 @@
|
|||||||
|
|
||||||
:- use_system_module( '$_errors', ['$do_error'/2]).
|
:- use_system_module( '$_errors', ['$do_error'/2]).
|
||||||
|
|
||||||
prolog:'$expects_dialect'(yap) :- !,
|
% @pred expects_dialect(+Dialect)
|
||||||
|
%
|
||||||
|
% True if YAP can enable support for a different Prolog dialect.
|
||||||
|
% Currently there is support for bprolog, hprolog and swi-prolog.
|
||||||
|
% Notice that this support may be incomplete.
|
||||||
|
%
|
||||||
|
% The
|
||||||
|
prolog:expects_dialect(yap) :- !,
|
||||||
eraseall('$dialect'),
|
eraseall('$dialect'),
|
||||||
recorda('$dialect',yap,_).
|
recorda('$dialect',yap,_).
|
||||||
prolog:'$expects_dialect'(Dialect) :-
|
prolog:expects_dialect(Dialect) :-
|
||||||
check_dialect(Dialect),
|
check_dialect(Dialect),
|
||||||
eraseall('$dialect'),
|
eraseall('$dialect'),
|
||||||
load_files(library(dialect/Dialect),[silent(true),if(not_loaded)]),
|
load_files(library(dialect/Dialect),[silent(true),if(not_loaded)]),
|
||||||
@ -84,4 +91,3 @@ open_source(File, In) :-
|
|||||||
exports(In, Exports) :-
|
exports(In, Exports) :-
|
||||||
read(In, Term),
|
read(In, Term),
|
||||||
Term = (:- module(_Name, Exports)).
|
Term = (:- module(_Name, Exports)).
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ considered.
|
|||||||
'$exec_directive'(thread_initialization(D), _, M, _, _) :-
|
'$exec_directive'(thread_initialization(D), _, M, _, _) :-
|
||||||
'$thread_initialization'(M:D).
|
'$thread_initialization'(M:D).
|
||||||
'$exec_directive'(expects_dialect(D), _, _, _, _) :-
|
'$exec_directive'(expects_dialect(D), _, _, _, _) :-
|
||||||
'$expects_dialect'(D).
|
expects_dialect(D).
|
||||||
'$exec_directive'(encoding(Enc), _, _, _, _) :-
|
'$exec_directive'(encoding(Enc), _, _, _, _) :-
|
||||||
'$set_encoding'(Enc).
|
'$set_encoding'(Enc).
|
||||||
'$exec_directive'(include(F), Status, _, _, _) :-
|
'$exec_directive'(include(F), Status, _, _, _) :-
|
||||||
@ -225,8 +225,8 @@ user_defined_directive(Dir,Action) :-
|
|||||||
functor(Dir,Na,Ar),
|
functor(Dir,Na,Ar),
|
||||||
functor(NDir,Na,Ar),
|
functor(NDir,Na,Ar),
|
||||||
'$current_module'(M, prolog),
|
'$current_module'(M, prolog),
|
||||||
assert_static('$directive'(NDir)),
|
assert_static(prolog:'$directive'(NDir)),
|
||||||
assert_static(('$exec_directive'(Dir, _, _, _, _) :- Action)),
|
assert_static(prolog:('$exec_directive'(Dir, _, _, _, _) :- Action)),
|
||||||
'$current_module'(_, M).
|
'$current_module'(_, M).
|
||||||
|
|
||||||
'$thread_initialization'(M:D) :-
|
'$thread_initialization'(M:D) :-
|
||||||
@ -235,5 +235,3 @@ user_defined_directive(Dir,Action) :-
|
|||||||
fail.
|
fail.
|
||||||
'$thread_initialization'(M:D) :-
|
'$thread_initialization'(M:D) :-
|
||||||
'$initialization'(M:D).
|
'$initialization'(M:D).
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ to allow user-control.
|
|||||||
print_message(informational,abort(user)).
|
print_message(informational,abort(user)).
|
||||||
'$process_error'(abort, _) :- !,
|
'$process_error'(abort, _) :- !,
|
||||||
throw(abort).
|
throw(abort).
|
||||||
'$process_error'(error(thread_cancel(Id), G),top) :- !.
|
'$process_error'(error(thread_cancel(_Id), _G),top) :- !.
|
||||||
'$process_error'(error(thread_cancel(Id), G), _) :- !,
|
'$process_error'(error(thread_cancel(Id), G), _) :- !,
|
||||||
throw(error(thread_cancel(Id), G)).
|
throw(error(thread_cancel(Id), G)).
|
||||||
'$process_error'(error(permission_error(module,redefined,A),B), Level) :-
|
'$process_error'(error(permission_error(module,redefined,A),B), Level) :-
|
||||||
@ -352,5 +352,3 @@ print_message(_, Term) :-
|
|||||||
flush_output(user_error),
|
flush_output(user_error),
|
||||||
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines), !,
|
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines), !,
|
||||||
print_message_lines(Stream, LinePrefix, LinesF).
|
print_message_lines(Stream, LinePrefix, LinesF).
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,7 +221,6 @@ rules.
|
|||||||
|
|
||||||
:- dynamic goal_expansion/2.
|
:- dynamic goal_expansion/2.
|
||||||
|
|
||||||
|
|
||||||
:- use_module('messages.yap').
|
:- use_module('messages.yap').
|
||||||
:- use_module('hacks.yap').
|
:- use_module('hacks.yap').
|
||||||
:- use_module('attributes.yap').
|
:- use_module('attributes.yap').
|
||||||
@ -328,13 +327,8 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th
|
|||||||
+ `undefined_global_variable`
|
+ `undefined_global_variable`
|
||||||
_Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry.
|
_Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
:- multifile user:exception/3.
|
:- multifile user:exception/3.
|
||||||
|
|
||||||
:- dynamic user:exception/3.
|
:- dynamic user:exception/3.
|
||||||
|
@ -76,14 +76,6 @@ file_position(user_input,LN) -->
|
|||||||
file_position(FileName,LN) -->
|
file_position(FileName,LN) -->
|
||||||
[ '~a:~d:0: ' - [FileName,LN] ].
|
[ '~a:~d:0: ' - [FileName,LN] ].
|
||||||
|
|
||||||
translate_message(Term) -->
|
|
||||||
generate_message(Term), !.
|
|
||||||
translate_message(Term) -->
|
|
||||||
{ Term = error(_, _) },
|
|
||||||
[ 'Unknown exception: ~p'-[Term] ].
|
|
||||||
translate_message(Term) -->
|
|
||||||
[ 'Unknown message: ~p'-[Term] ].
|
|
||||||
|
|
||||||
generate_message(Term, Lines, []) :-
|
generate_message(Term, Lines, []) :-
|
||||||
user:generate_message_hook(Term, [], Lines), !.
|
user:generate_message_hook(Term, [], Lines), !.
|
||||||
generate_message(Term) -->
|
generate_message(Term) -->
|
||||||
@ -679,11 +671,15 @@ pred_arity(H,Name,Arity) :-
|
|||||||
functor(H,Name,Arity).
|
functor(H,Name,Arity).
|
||||||
|
|
||||||
|
|
||||||
|
translate_message(Term) -->
|
||||||
|
generate_message(Term), !.
|
||||||
|
translate_message(Term) -->
|
||||||
|
{ Term = error(_, _) },
|
||||||
|
[ 'Unknown exception: ~p'-[Term] ].
|
||||||
|
translate_message(Term) -->
|
||||||
|
[ 'Unknown message: ~p'-[Term] ].
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@}
|
@}
|
||||||
@}
|
@}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
@ -158,7 +159,7 @@ not at all defined.
|
|||||||
'$do_import'/3,
|
'$do_import'/3,
|
||||||
'$extend_exports'/3,
|
'$extend_exports'/3,
|
||||||
'$get_undefined_pred'/4,
|
'$get_undefined_pred'/4,
|
||||||
'$imported_pred'/4,
|
'$imported_predicate'/4,
|
||||||
'$meta_expansion'/6,
|
'$meta_expansion'/6,
|
||||||
'$meta_predicate'/2,
|
'$meta_predicate'/2,
|
||||||
'$meta_predicate'/4,
|
'$meta_predicate'/4,
|
||||||
@ -666,7 +667,15 @@ source_module(Mod) :-
|
|||||||
'$expand_modules'((A;B),(A1;B1),(AO;BO),HM,BM,SM,HVars) :- var(A), !,
|
'$expand_modules'((A;B),(A1;B1),(AO;BO),HM,BM,SM,HVars) :- var(A), !,
|
||||||
'$expand_modules'(A,A1,AO,HM,BM,SM,HVars),
|
'$expand_modules'(A,A1,AO,HM,BM,SM,HVars),
|
||||||
'$expand_modules'(B,B1,BO,HM,BM,SM,HVars).
|
'$expand_modules'(B,B1,BO,HM,BM,SM,HVars).
|
||||||
'$expand_modules'((A*->B;C),(A1*->B1;C1),(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,BM,SM,HVars) :- !,
|
'$expand_modules'((A*->B;C),(A1*->B1;C1),
|
||||||
|
(
|
||||||
|
yap_hacks:current_choicepoint(DCP),
|
||||||
|
AO,
|
||||||
|
yap_hacks:cut_at(DCP),BO
|
||||||
|
;
|
||||||
|
CO
|
||||||
|
),
|
||||||
|
HM,BM,SM,HVars) :- !,
|
||||||
'$expand_modules'(A,A1,AOO,HM,BM,SM,HVars),
|
'$expand_modules'(A,A1,AOO,HM,BM,SM,HVars),
|
||||||
'$clean_cuts'(AOO, AO),
|
'$clean_cuts'(AOO, AO),
|
||||||
'$expand_modules'(B,B1,BO,HM,BM,SM,HVars),
|
'$expand_modules'(B,B1,BO,HM,BM,SM,HVars),
|
||||||
@ -724,18 +733,29 @@ source_module(Mod) :-
|
|||||||
'$expand_modules'(false,false,false,_,_,_,_) :- !.
|
'$expand_modules'(false,false,false,_,_,_,_) :- !.
|
||||||
% if I don't know what the module is, I cannot do anything to the goal,
|
% if I don't know what the module is, I cannot do anything to the goal,
|
||||||
% so I just put a call for later on.
|
% so I just put a call for later on.
|
||||||
'$expand_modules'(M:G,call(M:G),'$execute_wo_mod'(G,M),_,_,_,_) :- var(M), !.
|
'$expand_modules'(M:G,call(M:G),
|
||||||
|
'$execute_wo_mod'(G,M),_,_,_,_) :- var(M), !.
|
||||||
'$expand_modules'(M:G,G1,GO,HM,_M,_SM,HVars) :- !,
|
'$expand_modules'(M:G,G1,GO,HM,_M,_SM,HVars) :- !,
|
||||||
'$expand_modules'(G,G1,GO,HM,M,M,HVars).
|
'$expand_modules'(G,G1,GO,HM,M,M,HVars).
|
||||||
'$expand_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
'$expand_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
|
'$expand_goal_modules'(G, G1, GO, HM, BM, SM, HVars).
|
||||||
% is this imported from some other module M1?
|
% is this imported from some other module M1?
|
||||||
'$imported_pred'(G, BM, GG, M1),
|
|
||||||
|
'$expand_goal_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
|
'$pred_exists'(G, BM), !,
|
||||||
|
'$expand_goal_meta'(G, G1, GO, HM, BM, SM, HVars).
|
||||||
|
'$expand_goal_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
|
'$imported_predicate'(G, BM, GG, M1),
|
||||||
!,
|
!,
|
||||||
'$expand_modules'(GG, G1, GO, HM, M1, SM, HVars).
|
'$expand_goal_meta'(GG, G1, GO, HM, M1, SM, HVars).
|
||||||
'$expand_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
% we assume that if it is not defined here, it must be elsewhere.
|
||||||
|
'$expand_goal_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
|
'$expand_goal_meta'(G, G1, GO, HM, BM, SM, HVars).
|
||||||
|
|
||||||
|
'$expand_goal_meta'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
'$meta_expansion'(G, HM, BM, SM, GI, HVars), !,
|
'$meta_expansion'(G, HM, BM, SM, GI, HVars), !,
|
||||||
'$complete_goal_expansion'(GI, HM, BM, SM, G1, GO, HVars).
|
'$complete_goal_expansion'(GI, HM, BM, SM, G1, GO, HVars).
|
||||||
'$expand_modules'(G, G1, GO, HM, BM, SM, HVars) :-
|
'$expand_goal_meta'(G, G1, GO, HM, BM, SM, HVars) :-
|
||||||
'$complete_goal_expansion'(G, HM, BM, SM, G1, GO, HVars).
|
'$complete_goal_expansion'(G, HM, BM, SM, G1, GO, HVars).
|
||||||
|
|
||||||
expand_goal(G, G) :-
|
expand_goal(G, G) :-
|
||||||
@ -823,7 +843,7 @@ expand_goal(G, G).
|
|||||||
|
|
||||||
|
|
||||||
% be careful here not to generate an undefined exception.
|
% be careful here not to generate an undefined exception.
|
||||||
'$imported_pred'(G, ImportingMod, G0, ExportingMod) :-
|
'$imported_predicate'(G, ImportingMod, G0, ExportingMod) :-
|
||||||
'$enter_undefp',
|
'$enter_undefp',
|
||||||
( var(G) -> true ;
|
( var(G) -> true ;
|
||||||
var(ImportingMod) -> true ;
|
var(ImportingMod) -> true ;
|
||||||
@ -832,7 +852,7 @@ expand_goal(G, G).
|
|||||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
|
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
|
||||||
ExportingMod \= ImportingMod, !,
|
ExportingMod \= ImportingMod, !,
|
||||||
'$exit_undefp'.
|
'$exit_undefp'.
|
||||||
'$imported_pred'(_G, _ImportingMod, _, _) :-
|
'$imported_predicate'(_G, _ImportingMod, _, _) :-
|
||||||
'$exit_undefp',
|
'$exit_undefp',
|
||||||
fail.
|
fail.
|
||||||
|
|
||||||
@ -847,25 +867,27 @@ expand_goal(G, G).
|
|||||||
'$get_undefined_pred'(G, _ImportingMod, G, user) :-
|
'$get_undefined_pred'(G, _ImportingMod, G, user) :-
|
||||||
nonvar(G),
|
nonvar(G),
|
||||||
'$pred_exists'(G, user), !.
|
'$pred_exists'(G, user), !.
|
||||||
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
|
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||||
recorded('$dialect',Dialect,_),
|
recorded('$dialect',swi,_),
|
||||||
Dialect \= yap,
|
get_prolog_flag(autoload, true),
|
||||||
functor(G, Name, Arity),
|
'$autoload'(G, ImportingMod, ExportingModI, swi),
|
||||||
call(Dialect:index(Name,Arity,ExportingModI,_)), !,
|
|
||||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||||
% autoload
|
% autoload
|
||||||
|
|
||||||
|
% parent module mechanism
|
||||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||||
yap_flag(autoload, V),
|
prolog:'$parent_module'(ImportingMod,ExportingModI),
|
||||||
V = true,
|
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||||
|
|
||||||
|
'$autoload'(G, _ImportingMod, ExportingMod, Dialect) :-
|
||||||
|
functor(G, Name, Arity),
|
||||||
|
call(Dialect:index(Name,Arity,ExportingMod,_)), !.
|
||||||
|
'$autoload'(G, ImportingMod, ExportingMod, _Dialect) :-
|
||||||
functor(G, N, K),
|
functor(G, N, K),
|
||||||
functor(G0, N, K),
|
functor(G0, N, K),
|
||||||
'$autoloader_find_predicate'(G0,ExportingMod),
|
'$autoloader_find_predicate'(G0,ExportingMod),
|
||||||
ExportingMod \= ImportingMod,
|
ExportingMod \= ImportingMod,
|
||||||
(recordzifnot('$import','$import'(ExportingMod,ImportingMod,G0,G0, N ,K),_) -> true ; true ).
|
(recordzifnot('$import','$import'(ExportingMod,ImportingMod,G0,G0, N ,K),_) -> true ; true ).
|
||||||
% parent module mechanism
|
|
||||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
|
||||||
prolog:'$parent_module'(ImportingMod,ExportingModI),
|
|
||||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
|
||||||
|
|
||||||
|
|
||||||
'$autoloader_find_predicate'(G,ExportingModI) :-
|
'$autoloader_find_predicate'(G,ExportingModI) :-
|
||||||
@ -1397,7 +1419,7 @@ export_list(Module, List) :-
|
|||||||
'$do_import'(op(Prio,Assoc,Name), _Mod, ContextMod) :-
|
'$do_import'(op(Prio,Assoc,Name), _Mod, ContextMod) :-
|
||||||
op(Prio,Assoc,ContextMod:Name).
|
op(Prio,Assoc,ContextMod:Name).
|
||||||
'$do_import'(N0/K0-N0/K0, Mod, Mod) :- !.
|
'$do_import'(N0/K0-N0/K0, Mod, Mod) :- !.
|
||||||
'$do_import'(N0/K0-N0/K0, Mod, prolog) :- !.
|
'$do_import'(N0/K0-N0/K0, _Mod, prolog) :- !.
|
||||||
'$do_import'(_N/K-N1/K, _Mod, ContextMod) :-
|
'$do_import'(_N/K-N1/K, _Mod, ContextMod) :-
|
||||||
recorded('$module','$module'(_F, ContextMod, _SourceF, MyExports,_),_),
|
recorded('$module','$module'(_F, ContextMod, _SourceF, MyExports,_),_),
|
||||||
once(lists:member(N1/K, MyExports)),
|
once(lists:member(N1/K, MyExports)),
|
||||||
|
@ -574,7 +574,7 @@ predicate_property(Pred,Prop) :-
|
|||||||
'$pred_exists'(Pred,Mod), !,
|
'$pred_exists'(Pred,Mod), !,
|
||||||
'$predicate_property'(Pred,Mod,Mod,Prop).
|
'$predicate_property'(Pred,Mod,Mod,Prop).
|
||||||
'$predicate_property2'(Pred,Prop,Mod) :-
|
'$predicate_property2'(Pred,Prop,Mod) :-
|
||||||
'$imported_pred'(Pred, Mod, NPred, M),
|
'$imported_predicate'(Pred, Mod, NPred, M),
|
||||||
(
|
(
|
||||||
Prop = imported_from(M)
|
Prop = imported_from(M)
|
||||||
;
|
;
|
||||||
@ -679,7 +679,7 @@ current_predicate(A,T) :-
|
|||||||
% format('1 ~w ~16r~n', [M:T0,Flags, TFlags]),
|
% format('1 ~w ~16r~n', [M:T0,Flags, TFlags]),
|
||||||
\+ '$system_predicate'(T0, M)
|
\+ '$system_predicate'(T0, M)
|
||||||
;
|
;
|
||||||
'$imported_pred'(T0, M, SourceT, SourceMod),
|
'$imported_predicate'(T0, M, SourceT, SourceMod),
|
||||||
functor(T0, A, _),
|
functor(T0, A, _),
|
||||||
% format('2 ~w ~16r~n', [M:T0,Flags]),
|
% format('2 ~w ~16r~n', [M:T0,Flags]),
|
||||||
\+ '$system_predicate'(SourceT, SourceMod)
|
\+ '$system_predicate'(SourceT, SourceMod)
|
||||||
|
@ -237,7 +237,7 @@ qend_program :-
|
|||||||
X \= encoding.
|
X \= encoding.
|
||||||
|
|
||||||
'$init_state' :-
|
'$init_state' :-
|
||||||
recorded('$program_state', P, _), !,
|
recorded('$program_state', _P, _), !,
|
||||||
'$do_init_state'.
|
'$do_init_state'.
|
||||||
'$init_state'.
|
'$init_state'.
|
||||||
|
|
||||||
@ -325,6 +325,9 @@ qend_program :-
|
|||||||
'$init_path_extensions'.
|
'$init_path_extensions'.
|
||||||
|
|
||||||
% then we can execute the programs.
|
% then we can execute the programs.
|
||||||
|
'$startup_goals' :-
|
||||||
|
module(user),
|
||||||
|
fail.
|
||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
recorded('$startup_goal',G,_),
|
recorded('$startup_goal',G,_),
|
||||||
'$current_module'(Module),
|
'$current_module'(Module),
|
||||||
|
Reference in New Issue
Block a user