diff --git a/C/stdpreds.c b/C/stdpreds.c index c61e09e60..ca8b4afab 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -3499,7 +3499,15 @@ static Int p_argv(void) { Term t = mk_argc_list(); - return(Yap_unify(t, ARG1)); + return Yap_unify(t, ARG1); +} + +static Int +p_executable(void) +{ + + Yap_TrueFileName (Yap_argv[0], Yap_FileNameBuf, FALSE); + return Yap_unify(MkAtomTerm(Yap_LookupAtom(Yap_FileNameBuf)),ARG1); } static Int @@ -3972,6 +3980,7 @@ Yap_InitCPreds(void) Yap_InitCPred("$statistics_db_size", 4, p_statistics_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag); Yap_InitCPred("$statistics_lu_db_size", 5, p_statistics_lu_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag); Yap_InitCPred("$argv", 1, p_argv, SafePredFlag|HiddenPredFlag); + Yap_InitCPred("$executable", 1, p_executable, SafePredFlag|HiddenPredFlag); Yap_InitCPred("$runtime", 2, p_runtime, SafePredFlag|SyncPredFlag|HiddenPredFlag); Yap_InitCPred("$cputime", 2, p_cputime, SafePredFlag|SyncPredFlag|HiddenPredFlag); Yap_InitCPred("$systime", 2, p_systime, SafePredFlag|SyncPredFlag|HiddenPredFlag); diff --git a/docs/yap.tex b/docs/yap.tex index b92d7d3a8..75121355e 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -7595,6 +7595,11 @@ token is converted to a list of atoms, @code{chars}, to a list of integers, @code{codes}, or to a single atom, @code{atom}. If @var{Value} is bound, set to the corresponding behavior. The default value is @code{codes}. +@item executable +@findex executable(yap_flag/2 option) +@* Read-only flag. It unifies with an atom that gives the +original program path. + @item fast @findex fast (yap_flag/2 option) @* diff --git a/pl/directives.yap b/pl/directives.yap index 43763bc7d..eb413776e 100644 --- a/pl/directives.yap +++ b/pl/directives.yap @@ -183,6 +183,9 @@ yap_flag(fast,off) :- !, set_value('$fast',[]). % do or do not machine code yap_flag(argv,L) :- '$argv'(L). +% do or do not machine code +yap_flag(executable,L) :- '$executable'(L). + % hide/unhide atoms yap_flag(hide,Atom) :- !, hide(Atom). yap_flag(unhide,Atom) :- !, unhide(Atom). @@ -887,6 +890,7 @@ yap_flag(dialect,yap). V = dollar_as_lower_case ; V = double_quotes ; V = encoding ; + V = executable ; % V = fast ; V = fileerrors ; V = float_format ;