allow saving and restoring current arguments to/from slots.
This commit is contained in:
parent
f2dff606ef
commit
f1977f5dab
@ -477,6 +477,8 @@ X_API Term STD_PROTO(YAP_GetFromSlot,(Int));
|
||||
X_API Term *STD_PROTO(YAP_AddressFromSlot,(Int));
|
||||
X_API void STD_PROTO(YAP_PutInSlot,(Int, Term));
|
||||
X_API int STD_PROTO(YAP_RecoverSlots,(int));
|
||||
X_API Int STD_PROTO(YAP_ArgsToSlots,(int));
|
||||
X_API void STD_PROTO(YAP_SlotsToArgs,(int, Int));
|
||||
X_API void STD_PROTO(YAP_Throw,(Term));
|
||||
X_API void STD_PROTO(YAP_Halt,(int));
|
||||
X_API Term *STD_PROTO(YAP_TopOfLocalStack,(void));
|
||||
@ -3077,4 +3079,25 @@ YAP_Erase(void *handle)
|
||||
return 1;
|
||||
}
|
||||
|
||||
X_API Int
|
||||
YAP_ArgsToSlots(int n)
|
||||
{
|
||||
Int slot = Yap_NewSlots(n);
|
||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||
while (n--) {
|
||||
*ptr0++ = *ptr1++;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
X_API void
|
||||
YAP_SlotsToArgs(int n, Int slot)
|
||||
{
|
||||
CELL *ptr0 = LCL0+slot, *ptr1=&ARG1;
|
||||
while (n--) {
|
||||
*ptr1++ = *ptr0++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
17
docs/yap.tex
17
docs/yap.tex
@ -15674,12 +15674,12 @@ YAP that the slot @var{sl} is not needed and can be given back to the
|
||||
system. The slot functions are as follows:
|
||||
|
||||
@table @code
|
||||
@item long int YAP_NewSlots(int @var{NumberOfSlots})
|
||||
@item YAP_Int YAP_NewSlots(int @var{NumberOfSlots})
|
||||
@findex YAP_NewSlots (C-Interface function)
|
||||
Allocate @var{NumberOfSlots} from the stack and return an handle to the
|
||||
last one. The other handle can be obtained by decrementing the handle.
|
||||
|
||||
@item long int YAP_CurrentSlot(void)
|
||||
@item YAP_Int YAP_CurrentSlot(void)
|
||||
@findex YAP_CurrentSlot (C-Interface function)
|
||||
Return a handle to the system's default slot.
|
||||
|
||||
@ -15688,11 +15688,11 @@ Return a handle to the system's default slot.
|
||||
Create a new slot, initialise it with @var{t}, and return a handle to
|
||||
this slot, that also becomes the current slot.
|
||||
|
||||
@item YAP_Term *YAP_AddressFromSlot(long int @var{slot})
|
||||
@item YAP_Term *YAP_AddressFromSlot(YAP_Int @var{slot})
|
||||
@findex YAP_AddressFromSlot (C-Interface function)
|
||||
Return the address of slot @var{slot}: please use with care.
|
||||
|
||||
@item void YAP_PutInSlot(long int @var{slot}, YAP_Term @var{t})
|
||||
@item void YAP_PutInSlot(YAP_Int @var{slot}, YAP_Term @var{t})
|
||||
@findex YAP_PutInSlot (C-Interface function)
|
||||
Set the contents of slot @var{slot} to @var{t}.
|
||||
|
||||
@ -15700,6 +15700,15 @@ Set the contents of slot @var{slot} to @var{t}.
|
||||
@findex YAP_RecoverSlots (C-Interface function)
|
||||
Recover the space for @var{HowMany} slots: these will include the
|
||||
current default slot. Fails if no such slots exist.
|
||||
|
||||
@item YAP_Int YAP_ArgsToSlots(int @var{HowMany})
|
||||
@findex YAP_ArgsToSlots (C-Interface function)
|
||||
Store the current first @var{HowMany} arguments in new slots.
|
||||
|
||||
@item void YAP_SlotsToArgs(int @var{HowMany}, YAP_Int @var{slot})
|
||||
@findex YAP_SlotsToArgs (C-Interface function)
|
||||
Set the first @var{HowMany} arguments to the @var{HowMany} slots
|
||||
starting at @var{slot}.
|
||||
@end table
|
||||
|
||||
The following functions complement @var{YAP_RunGoal}:
|
||||
|
@ -426,6 +426,12 @@ extern X_API void PROTO(YAP_PutInSlot,(YAP_Int, YAP_Term));
|
||||
/* void YAP_RecoverSlots() */
|
||||
extern X_API int PROTO(YAP_RecoverSlots,(int));
|
||||
|
||||
/* void YAP_RecoverSlots() */
|
||||
extern X_API YAP_Int PROTO(YAP_ArgsToSlots,(int));
|
||||
|
||||
/* void YAP_RecoverSlots() */
|
||||
extern X_API void PROTO(YAP_SlotsToArgs,(int, YAP_Int));
|
||||
|
||||
/* void YAP_Throw() */
|
||||
extern X_API void PROTO(YAP_Throw,(YAP_Term));
|
||||
|
||||
|
@ -35,14 +35,6 @@
|
||||
run_tests/1
|
||||
]).
|
||||
|
||||
:- asserta(user:file_search_path(foreign, '../sgml')).
|
||||
:- asserta(user:file_search_path(foreign, '../semweb')).
|
||||
:- asserta(user:file_search_path(foreign, '../clib')).
|
||||
:- asserta(user:file_search_path(library, '..')).
|
||||
:- asserta(user:file_search_path(library, '../sgml')).
|
||||
:- asserta(user:file_search_path(library, '.')).
|
||||
:- asserta(user:file_search_path(library, '../plunit')).
|
||||
:- asserta(user:file_search_path(library, '../clib')).
|
||||
|
||||
:- use_module(library(plunit)).
|
||||
:- use_module(library(rdf_write)).
|
||||
@ -50,7 +42,7 @@
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(library(debug)).
|
||||
:- use_module(library(semweb/rdf_db)).
|
||||
:- use_module(rdf).
|
||||
:- use_module(library(rdf)).
|
||||
|
||||
:- expects_dialect(swi).
|
||||
:- assert(system:swi_io).
|
||||
|
@ -22,8 +22,8 @@
|
||||
% get libraries locally
|
||||
:- asserta(user:file_search_path(library, '.')).
|
||||
|
||||
:- use_module(rdf). % our RDF parser
|
||||
:- use_module(rdf_ntriples). % read .nt files
|
||||
:- use_module(library(rdf)). % our RDF parser
|
||||
:- use_module(library(rdf_ntriples)). % read .nt files
|
||||
:- load_files([ library(pce),
|
||||
library(toolbar),
|
||||
library(pce_report),
|
||||
|
Reference in New Issue
Block a user