extend SWI interface with PL_toplevel and to handle C++ code.

prolog/0 built-in
fixes to parms.h changes.
This commit is contained in:
Vitor Santos Costa 2009-10-23 16:50:43 +01:00
parent 0179998d60
commit 0ea348c26d
8 changed files with 30 additions and 13 deletions

View File

@ -5543,7 +5543,7 @@ p_choicepoint_info(void)
break;
case _Nstop:
{
Atom at = AtomProlog;
Atom at = AtomLive;
t = MkAtomTerm(at);
pe = RepPredProp(PredPropByAtom(at, CurrentModule));
}

View File

@ -111,7 +111,7 @@ p_load_foreign(void)
static Int
p_obj_suffix(void) {
return(Yap_unify(TailOfTerm(Yap_StringToList(YAP_SHLIB_SUFFIX)),ARG1));
return(Yap_unify(Yap_StringToList(YAP_SHLIB_SUFFIX),ARG1));
}
void

View File

@ -291,7 +291,7 @@ config.h: parms.h
parms.h: Makefile
@echo "#define YAP_ROOTDIR \"$(prefix)\"" > $@%
@echo "#define YAP_BINDIR \"$(BINDIR)\"" >> $@%
@echo "#define YAP_LIBDIR \"$(LIBDIR)\"" >> $@%
@echo "#define YAP_LIBDIR \"$(YAPLIBDIR)\"" >> $@%
@echo "#define YAP_SHAREDIR \"$(SHAREDIR)\"" >> $@%
@echo "#define YAP_PL_SRCDIR \"$(SHAREDIR)/Yap/pl\"" >> $@%
@echo "#define YAP_STARTUP \"$(YAPSTARTUP)\"" >> $@%

View File

@ -816,7 +816,7 @@ exec_top_level(int BootMode, YAP_init_args *iap)
YAP_Atom livegoal;
/* read the bootfile */
do_bootfile (iap->YapPrologBootFile ? iap->YapPrologBootFile : BootFile);
livegoal = YAP_FullLookupAtom("prolog");
livegoal = YAP_FullLookupAtom("$live");
/* initialise the top-level */
if (BootMode == YAP_FULL_BOOT_FROM_PROLOG) {
char init_file[256];
@ -855,7 +855,7 @@ exec_top_level(int BootMode, YAP_init_args *iap)
/* read it before case someone, that is, Ashwin, hides
the atom false away ;-).
*/
livegoal = YAP_FullLookupAtom("prolog");
livegoal = YAP_FullLookupAtom("$live");
atomfalse = YAP_MkAtomTerm (YAP_FullLookupAtom("$false"));
while (YAP_GetValue (livegoal) != atomfalse) {
YAP_Reset();

View File

@ -13,6 +13,10 @@
#ifndef _FLI_H_INCLUDED
#define _FLI_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
//=== includes ===============================================================
#include "config.h"
#include <YapInterface.h>
@ -406,12 +410,13 @@ extern X_API qid_t PL_open_query(module_t, int, predicate_t, term_t);
extern X_API int PL_next_solution(qid_t);
extern X_API void PL_cut_query(qid_t);
extern X_API void PL_close_query(qid_t);
extern X_API int PL_toplevel(void);
extern X_API term_t PL_exception(qid_t);
extern X_API int PL_call_predicate(module_t, int, predicate_t, term_t);
extern X_API int PL_call(term_t, module_t);
extern X_API void PL_register_foreign_in_module(const char *, const char *, int, foreign_t (*)(void), int);
extern X_API void PL_register_extensions(PL_extension *);
extern X_API void PL_load_extensions(PL_extension *);
extern X_API void PL_register_extensions(const PL_extension *);
extern X_API void PL_load_extensions(const PL_extension *);
extern X_API int PL_handle_signals(void);
extern X_API int PL_thread_self(void);
extern X_API int PL_thread_attach_engine(const PL_thread_attr_t *);
@ -472,5 +477,9 @@ void swi_install(void);
X_API int PL_error(const char *pred, int arity, const char *msg, int id, ...);
#ifdef __cplusplus
}
#endif
#endif /* _FLI_H_INCLUDED */

View File

@ -2010,6 +2010,11 @@ X_API int PL_call_predicate(module_t ctx, int flags, predicate_t p, term_t t0)
return ret;
}
X_API int PL_toplevel(void)
{
return YAP_RunGoal(MkAtomTerm(Yap_FullLookupAtom("$live")));
}
X_API int PL_call(term_t tp, module_t m)
{
YAP_Term t[2], g;
@ -2047,12 +2052,12 @@ X_API void PL_register_foreign_in_module(const char *module, const char *name, i
}
}
X_API void PL_register_extensions(PL_extension *ptr)
X_API void PL_register_extensions(const PL_extension *ptr)
{
PL_load_extensions(ptr);
}
X_API void PL_load_extensions(PL_extension *ptr)
X_API void PL_load_extensions(const PL_extension *ptr)
{
/* ignore flags for now */
while(ptr->predicate_name != NULL) {

View File

@ -21,7 +21,7 @@
true :- true.
prolog :-
'$live' :-
'$init_system',
'$do_live'.
@ -161,7 +161,7 @@ prolog :-
get_value('$top_level_goal',GA), GA \= [], !,
set_value('$top_level_goal',[]),
'$run_atom_goal'(GA),
set_value(prolog,'$false').
set_value('$live','$false').
'$enter_top_level' :-
prompt(_,' ?- '),
prompt(' | '),
@ -174,7 +174,7 @@ prolog :-
prompt(_,' |: '),
'$command'((?-Command),Varnames,Pos,top),
'$sync_mmapped_arrays',
set_value(prolog,'$false').
set_value('$live','$false').
'$startup_goals' :-
get_value('$extend_file_search_path',P), P \= [],
@ -958,7 +958,7 @@ break :-
format(user_error, '% Break (level ~w)~n', [NBL]),
'$do_live',
!,
set_value(prolog,'$true'),
set_value('$live','$true'),
b_setval('$spy_glist',GList),
nb_setval('$spy_gn',SPY_GN),
'$set_input'(InpStream), '$set_output'(OutStream),

View File

@ -222,6 +222,9 @@ restore(A) :- var(A), !,
restore(A) :- atom(A), !, name(A,S), '$restore'(S).
restore(S) :- '$restore'(S).
prolog :-
'$live'.
%%% current ....
recordaifnot(K,T,R) :-