This commit is contained in:
Vitor Santos Costa 2018-02-02 11:50:07 +00:00
parent 5ea47853ac
commit 66db3d53f8
12 changed files with 122 additions and 124 deletions

View File

@ -165,7 +165,6 @@ static void consult(const char *b_file USES_REGS) {
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
Functor functor_compile2 = Yap_MkFunctor(Yap_LookupAtom("c_compile"), 1);
Functor functor_bc = Yap_MkFunctor(Yap_LookupAtom("$bc"), 3);
/* consult boot.pl */
char *full = malloc(YAP_FILENAME_MAX + 1);
@ -238,7 +237,7 @@ typedef struct config {
const char **dll;
const char **ss;
const char **oss;
const char **bootpl;
const char **plbootdir;
} config_t;
const char *gd_root[] = {"@RootDir", "[root]", "(execdir)/.."};
@ -250,7 +249,8 @@ const char *gd_pl[] = {"@PlDir", "(share)/Yap"};
const char *gd_commons[] = {"@CommonsDir", "(share)/PrologCommons"};
const char *gd_ss[] = {"(dll)"};
const char *gd_oss[] = {"."};
const char *gd_bootpl[] = {"(pl)/pl"};
const char *gd_plbootdir[] = {"@BootPlDi",
"(pl)/pl"};
static config_t *gnu(config_t *i) {
i->root = gd_root;
@ -262,34 +262,11 @@ static config_t *gnu(config_t *i) {
i->commons = gd_commons;
i->ss = gd_ss;
i->oss = gd_oss;
i->bootpl = gd_bootpl;
i->plbootdir = gd_plbootdir;
return i;
}
const char *build_root[] = {"."};
const char *build_lib[] = {"."};
const char *build_share[] = {"(src)"};
const char *build_include[] = {"(src/include]"};
const char *build_dll[] = {"."};
const char *build_pl[] = {"pl"};
const char *build_commons[] = {"PrologCommons"};
const char *build_ss[] = {NULL};
const char *build_bootpl[] = {"(pl)boot.yap"};
static config_t *build(config_t *i) {
i->root = build_root;
i->lib = build_lib;
i->share = build_share;
i->include = build_include;
i->dll = build_dll;
i->pl = build_pl;
i->commons = build_commons;
i->ss = build_ss;
i->bootpl = build_bootpl;
return i;
}
/**
* Search
*/
@ -355,7 +332,11 @@ char *location(YAP_init_args *iap, const char *inp, char *out) {
if (tmp && tmp[0])
strcpy(out, tmp);
} else if (strstr(inp + 1, "PlDir") == inp + 1) {
const char *tmp = iap->SavedState;
const char *tmp = iap->PlDir;
if (tmp && tmp[0])
strcpy(out, tmp);
} else if (strstr(inp + 1, "PlBootDir") == inp + 1) {
const char *tmp = iap->PlBootDir;
if (tmp && tmp[0])
strcpy(out, tmp);
} else if (strstr(inp + 1, "PrologBootFile") == inp + 1) {
@ -485,6 +466,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
Yap_SHAREDIR = find_directory(iap, template->share, NULL);
Yap_DLLDIR = find_directory(iap, template->dll, NULL);
Yap_PLDIR = find_directory(iap, template->pl, NULL);
Yap_BOOTPLDIR = find_directory(iap, template->plbootdir, NULL);
Yap_COMMONSDIR = find_directory(iap, template->commons, NULL);
if (iap->SavedState == NULL)
iap->SavedState = "startup.yss";
@ -494,7 +476,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
Yap_OUTPUT_STARTUP = find_directory(iap, template->ss, iap->OutputSavedState);
if (iap->PrologBootFile == NULL)
iap->PrologBootFile = "boot.yap";
Yap_BOOTFILE = find_directory(iap, template->bootpl, iap->PrologBootFile);
Yap_BOOTFILE = find_directory(iap, template->plbootdir, iap->PrologBootFile);
if (Yap_ROOTDIR)
setAtomicGlobalPrologFlag(HOME_FLAG,
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
@ -641,19 +623,15 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
else if (argv[1] && *argv[1] != '-') {
iap->PrologBootFile = *++argv;
argc--;
} else {
iap->PrologBootFile = "boot.yap";
}
break;
case 'B':
iap->boot_file_type = YAP_BOOT_PL;
if (p[1])
iap->PrologBootFile = p + 1;
iap->PlDir = p + 1;
else if (argv[1] && *argv[1] != '-') {
iap->PrologBootFile = *++argv;
iap->PlDir = *++argv;
argc--;
} else {
iap->PrologBootFile = "boot.yap";
}
iap->install = true;
break;

View File

@ -198,6 +198,8 @@ typedef struct yap_boot_params {
const char *PlDir;
//> if NON-NULL, name for a Prolog file to use when booting
const char *PrologBootFile;
//> if NON-NULL, directory for a Prolog file to be when booting
const char *PlBootDir;
//> if NON-NULL, path where we can find the saved state
const char *SavedState;
//> bootstrapping mode: YAP is not properly installed

View File

@ -1399,7 +1399,7 @@ writable.
*/
static Int open3(USES_RfEGS1) {
static Int open3(USES_REGS1) {
/* '$open'(+File,+Mode,?Stream,-ReturnCode) */
return do_open(Deref(ARG1), Deref(ARG2), TermNil PASS_REGS);
}

View File

@ -1130,7 +1130,6 @@ static Int p_expand_file_name(USES_REGS1) {
static Int true_file_name3(USES_REGS1) {
Term t = Deref(ARG1), t2 = Deref(ARG2);
char *root = NULL;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR, t, "argument to true_file_name unbound");
@ -1145,7 +1144,7 @@ static Int true_file_name3(USES_REGS1) {
Yap_Error(TYPE_ERROR_ATOM, t2, "argument to true_file_name");
return FALSE;
}
root = RepAtom(AtomOfTerm(t2))->StrOfAE;
// root = RepAtom(AtomOfTerm(t2))->StrOfAE;
}
char tmp[YAP_FILENAME_MAX + 1];
if (!Yap_AbsoluteFile(RepAtom(AtomOfTerm(t))->StrOfAE, tmp, true))

View File

@ -224,13 +224,13 @@
:- yap_flag(unknown,error).
:- style_check(single_var).
:- start_low_level_trace.
:- initialization((
bb_put(logger_filename,'out.dat'),
bb_put(logger_delimiter,';'),
bb_put(logger_variables,[])
)).
:- stopS_low_level_trace.
%========================================================================
%= Defines a new variable, possible types are: int, float and time

View File

@ -75,7 +75,7 @@ DESTINATION ${libpl}/library)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/startup.yss)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/startup.yss
COMMAND yap-bin -B${CMAKE_CURRENT_SOURCE_DIR}/boot.yap --output-saved-state=${CMAKE_CURRENT_BINARY_DIR}/startup.yss
COMMAND yap-bin -B${CMAKE_CURRENT_SOURCE_DIR} --output-saved-state=${CMAKE_CURRENT_BINARY_DIR}/startup.yss
DEPENDS ${PL_BOOT_SOURCES} yap-bin
)
#else ()

View File

@ -205,7 +205,7 @@ print_message(L,E) :-
( (Con = top ; var(C) ; C = [_|_]) ->
'$execute_command'(C,VL,Pos,Con,C), ! ;
% do term expansion
expand_term(C, EC),
'$expand_term'(C, EC),
% execute a list of commands
'$execute_commands'(EC,VL,Pos,Con,_Source),
% succeed only if the *original* was at end of file.
@ -453,3 +453,4 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th
:- ensure_loaded('../pl/pathconf.yap').
:- yap_flag(user:unknown,error).

View File

@ -1588,7 +1588,7 @@ End of conditional compilation.
catch('$eval_if'(G), E, (print_message(error, E), fail)).
'$eval_if'(Goal) :-
expand_term(Goal,TrueGoal),
'$expand_term'(Goal,TrueGoal),
once(TrueGoal).
'$if_directive'((:- if(_))).

View File

@ -238,6 +238,7 @@ user_defined_directive(Dir,Action) :-
'$thread_initialization'(M:D) :-
eraseall('$thread_initialization'),
writeln(M:D),
recorda('$thread_initialization',M:D,_),
fail.
'$thread_initialization'(M:D) :-

View File

@ -179,7 +179,8 @@ current_prolog_flag(break_level, BreakLevel),
'$execute_commands'(V,_,_,_,Source) :- var(V), !,
'$do_error'(instantiation_error,meta_call(Source)).
'$execute_commands'([],_,_,_,_) :- !.
'$execute_commands'([C|Cs],VL,Pos,Con,Source) :- !,
'$execute_commands'([C|Cs],VL,Pos,Con,Source) :-
!,
(
'$system_catch'('$execute_command'(C,VL,Pos,Con,Source),prolog,Error,'$LoopError'(Error, Con)),
fail
@ -211,15 +212,14 @@ current_prolog_flag(break_level, BreakLevel),
\+ '$if_directive'(Command),
!.
'$execute_command'((:-G),VL,Pos,Option,_) :-
% !,
Option \= top,
!, % allow user expansion
catch(expand_term((:- G), O),_O, fail),
'$expand_term'((:- G), O),
(
O = (:- G1)
->
'$yap_strip_module'(G1, M, G2),
'$process_directive'(G2, Option, M, VL, Pos)
'$yap_strip_module'(G1, M, NG),
'$process_directive'(NG, Option, M, VL, Pos)
;
'$execute_commands'(G1,VL,Pos,Option,O)
).
@ -230,6 +230,23 @@ current_prolog_flag(break_level, BreakLevel),
'$execute_command'(G, VL, Pos, Option, Source) :-
'$continue_with_command'(Option, VL, Pos, G, Source).
'$expand_term'(T,O) :-
catch( '$expand_term0'(T,O), _,( '$disable_debugging', fail) ),
!.
'$expand_term0'(T,O) :-
expand_term( T, T1),
!,
'$expand_term1'(T1,O).
'$expand_term0'(T,T).
'$expand_term1'(T,O) :-
'$yap_strip_module'(T1, M, G2),
'$is_metapredicate'(G2,M),
'$expand_meta_call'(M:G2, [], O),
!.
'$expand_term1'(O,O).
'$continue_with_command'(Where,V,'$stream_position'(C,_P,A1,A2,A3),'$source_location'(_F,L):G,Source) :-
!,
'$continue_with_command'(Where,V,'$stream_position'(C,L,A1,A2,A3),G,Source).