related changes

This commit is contained in:
V'itor Santos Costa 2016-02-11 06:20:16 -08:00
parent 255da61029
commit 485d20d908
12 changed files with 71 additions and 93 deletions

View File

@ -1,4 +1,10 @@
# Be sure to also update these in Makefile!
set(SO_MAJOR 1)
set(SO_MINOR 0)
set(SO_PATCH 0)
add_library (Yap++ SHARED
yapa.hh
yapdb.hh
@ -11,7 +17,7 @@ add_library (Yap++ SHARED
include_directories (H include ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIR})
target_link_libraries(Yap++ libYap)
target_link_libraries(Yap++ ${CMAKE_DL_LIBS})
install(TARGETS Yap++
LIBRARY DESTINATION ${libdir}

View File

@ -139,7 +139,6 @@ set(C_INTERFACE_SOURCES
H/generated/ilocals.h
H/index.h
H/inline-only.h
H/iswiatoms.h
H/qly.h
H/rclause.h
H/generated/rglobals.h

View File

@ -152,6 +152,8 @@ typedef int (*YAP_agc_hook)(void *_Atom);
typedef encoding_t YAP_encoding_t;
#endif
typedef struct YAP_thread_attr_struct {

View File

@ -42,6 +42,29 @@ struct yami *Yap_Error__(const char *file, const char *function, int lineno, ya
#define Yap_Error( id, inp, ...) Yap_Error__(__FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
#ifdef YAP_TERM_H
/**
* make sure next argument is a bound instance of type
* atom.
*/
#define Yap_ensure_atom( T0, TF ) { if ( (TF = Yap_ensure_atom__(__FILE__, __FUNCTION__, __LINE__, T0 ) == 0L ) return false; }
INLINE_ONLY extern inline Term
Yap_ensure_atom__( const char *fu, const char *fi, int line, Term in )
{
Term t = Deref(in);
//Term Context = Deref(ARG2);
if (!IsVarTerm(t) && IsAtomTerm(t))
return t;
if (IsVarTerm(t)) {
Yap_Error__(fu, fi, line, INSTANTIATION_ERROR, t, NULL);
} else {
if ( IsAtomTerm(t) ) return t ;
Yap_Error__(fu, fi, line, TYPE_ERROR_ATOM, t, NULL);
return 0L;
}
#endif
#define JMP_LOCAL_ERROR(v, LAB) \
if (H + 2 * (v) > ASP - 1024) { \

View File

@ -47,6 +47,7 @@ E(DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION, DOMAIN_ERROR,
"absolute_file_name_option")
E(DOMAIN_ERROR_ARRAY_OVERFLOW, DOMAIN_ERROR, "array_overflow")
E(DOMAIN_ERROR_ARRAY_TYPE, DOMAIN_ERROR, "array_type")
E(DOMAIN_ERROR_CLOSE_OPTION, DOMAIN_ERROR, "close_option")
E(DOMAIN_ERROR_FILE_ERRORS, DOMAIN_ERROR, "file_errors")
E(DOMAIN_ERROR_FILE_TYPE, DOMAIN_ERROR, "file_type")
E(DOMAIN_ERROR_IO_MODE, DOMAIN_ERROR, "io_mode")
@ -55,6 +56,7 @@ E(DOMAIN_ERROR_NON_EMPTY_LIST, DOMAIN_ERROR, "non_empty_list")
E(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, DOMAIN_ERROR, "not_less_than_zero")
E(DOMAIN_ERROR_NOT_NL, DOMAIN_ERROR, "not_nl")
E(DOMAIN_ERROR_NOT_ZERO, DOMAIN_ERROR, "not_zero")
E(DOMAIN_ERROR_OPEN_OPTION, DOMAIN_ERROR, "open_option")
E(DOMAIN_ERROR_OPERATOR_PRIORITY, DOMAIN_ERROR, "operator_priority")
E(DOMAIN_ERROR_OPERATOR_SPECIFIER, DOMAIN_ERROR, "operator_specifier")
E(DOMAIN_ERROR_ORDER, DOMAIN_ERROR, "order")
@ -62,6 +64,7 @@ E(DOMAIN_ERROR_OUT_OF_RANGE, DOMAIN_ERROR, "out_of_range")
E(DOMAIN_ERROR_PROLOG_FLAG, DOMAIN_ERROR, "prolog_flag")
E(DOMAIN_ERROR_RADIX, DOMAIN_ERROR, "radix")
E(DOMAIN_ERROR_READ_OPTION, DOMAIN_ERROR, "read_option")
E(DOMAIN_ERROR_SET_STREAM_OPTION, DOMAIN_ERROR, "set_stream_option")
E(DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, DOMAIN_ERROR, "shift_count_overflow")
E(DOMAIN_ERROR_SOURCE_SINK, DOMAIN_ERROR, "source_sink")
E(DOMAIN_ERROR_SOLUTIONS, DOMAIN_ERROR, "solutions")
@ -69,6 +72,7 @@ E(DOMAIN_ERROR_STREAM, DOMAIN_ERROR, "stream")
E(DOMAIN_ERROR_STREAM_ENCODING, DOMAIN_ERROR, "stream_encoding")
E(DOMAIN_ERROR_STREAM_OR_ALIAS, DOMAIN_ERROR, "stream_or_alias")
E(DOMAIN_ERROR_STREAM_POSITION, DOMAIN_ERROR, "stream_position")
E(DOMAIN_ERROR_STREAM_PROPERTY_OPTION, DOMAIN_ERROR, "stream_property_option")
E(DOMAIN_ERROR_TIMEOUT_SPEC, DOMAIN_ERROR, "timeout_spec")
E(DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, DOMAIN_ERROR, "syntax_error_handler")
E(DOMAIN_ERROR_WRITE_OPTION, DOMAIN_ERROR, "write_option")

View File

@ -64,6 +64,8 @@
//#include "pl-error.h"
static atom_t ATOM_nil;
extern int PL_unify_termv(term_t l, va_list args);
extern X_API Atom YAP_AtomFromSWIAtom(atom_t at);
@ -105,8 +107,6 @@ extern X_API Int YAP_PLArityOfSWIFunctor(functor_t at);
/* This is silly, but let's keep it like that for now */
X_API Int
YAP_PLArityOfSWIFunctor(functor_t f) {
if (((CELL)(f) & 2) && ((CELL)f) < N_SWI_FUNCTORS*4+2)
return ArityOfFunctor(SWI_Functors[(CELL)f/4]);
if (IsAtomTerm(f))
return 0;
return ArityOfFunctor((Functor)f);
@ -208,18 +208,10 @@ Text is in ISO Latin-1 encoding and the call fails if text cannot be represented
X_API int
PL_get_nchars(term_t l, size_t *lengthp, char **s, unsigned flags)
{ CACHE_REGS
seq_tv_t inp, out;
size_t leng;
void *buf = NULL;
seq_tv_t inp, out;
inp.val.t = Yap_GetFromSlot( l );
inp.type = cvtFlags( flags );
if (flags & (BUF_DISCARDABLE|BUF_RING)) {
buf = LOCAL_FileNameBuf;
leng = YAP_FILENAME_MAX-1;
} else {
buf = NULL;
}
out.type = YAP_STRING_CHARS;
if (flags & (REP_UTF8|REP_MB)) {
out.enc = ENC_ISO_UTF8;
@ -245,17 +237,10 @@ PL_get_chars(term_t t, char **s, unsigned flags)
int PL_get_wchars(term_t l, size_t *lengthp, wchar_t **s, unsigned flags)
{
CACHE_REGS
seq_tv_t inp, out;
size_t leng;
void *buf = NULL;
inp.val.t = Yap_GetFromSlot( l );
inp.type = cvtFlags( flags );
if (flags & (BUF_DISCARDABLE|BUF_RING)) {
buf = LOCAL_FileNameBuf;
leng = YAP_FILENAME_MAX-1;
} else {
buf = NULL;
}
out.type = YAP_STRING_WCHARS;
if (flags & BUF_MALLOC)
out.type |= YAP_STRING_MALLOC;
@ -2353,6 +2338,7 @@ PL_initialise(int myargc, char **myargv)
GLOBAL_PL_Argv = myargv;
GLOBAL_InitialisedFromPL = TRUE;
int rc = YAP_Init(&init_args) != YAP_BOOT_ERROR;
ATOM_nil = YAP_SWIAtomFromAtom( AtomNil );
return rc;
}

View File

@ -43,21 +43,6 @@
void Yap_swi_install(void);
void Yap_install_blobs(void);
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))
static inline void
add_to_hash(Int i, ADDR key)
{
UInt h = addr_hash(key);
while (SWI_ReverseHash[h].key) {
h = (h+1)%N_SWI_HASH;
}
SWI_ReverseHash[h].key = key;
SWI_ReverseHash[h].pos = i;
}
static inline Term
SWIModuleToModule(module_t m)
{
@ -75,10 +60,6 @@ SWIModuleToModule(module_t m)
static inline atom_t
AtomToSWIAtom(Atom at)
{
TranslationEntry *p;
if ((p = Yap_GetTranslationProp(at,0)) != NULL)
return (atom_t)(p->Translation*2+1);
return (atom_t)at;
}
@ -87,27 +68,18 @@ AtomToSWIAtom(Atom at)
static inline Atom
SWIAtomToAtom(atom_t at)
{
if ((CELL)at & 1)
return SWI_Atoms[at/2];
return (Atom)at;
}
static inline functor_t
FunctorToSWIFunctor(Functor f)
{
TranslationEntry *p;
Atom at = NameOfFunctor(f);
arity_t ar = ArityOfFunctor(f);
if ((p = Yap_GetTranslationProp(at,ar)) != NULL)
return (functor_t)(p->Translation*2+1);
return (functor_t)f;
}
static inline Functor
SWIFunctorToFunctor(functor_t f)
{
if ((CELL)f & 1)
return SWI_Functors[f/2];
return (Functor)f;
}

View File

@ -42,22 +42,22 @@ number_of_expansions(0).
%%%%%%%%%%%%%%%%%%%%
compile_aux([Clause|Clauses], Module) :-
% compile the predicat declaration if needed
(
Clause = (Head :- _)
;
% compile the predicate declaration if needed
(
Clause = (Head :- _)
;
Clause = Head
),
!,
functor(Head, F, N),
( current_predicate(Module:F/N)
->
true
;
% format'*** Creating auxiliary predicate ~q~n', [F/N]),
% checklist(portray_clause, [Clause|Clauses]),
compile_term([Clause|Clauses], Module)
).
!,
functor(Head, F, N),
( current_predicate(Module:F/N)
->
true
;
% format'*** Creating auxiliary predicate ~q~n', [F/N]),
% checklist(portray_clause, [Clause|Clauses]),
compile_term([Clause|Clauses], Module)
).
compile_term([], _).
compile_term([Clause|Clauses], Module) :-

View File

@ -316,20 +316,6 @@ ADDR ForeignCodeMax =NULL void
/* recorded terms */
struct record_list *Yap_Records =NULL RestoreYapRecords()
/* SWI atoms and functors */
Atom *SWI_Atoms InitSWIAtoms() RestoreSWIAtoms()
Functor *SWI_Functors void void
swi_rev_hash SWI_ReverseHash[N_SWI_HASH] void void
/* integer access to atoms */
Int AtomTranslations void void
Int MaxAtomTranslations void void
/* integer access to functors */
Int FunctorTranslations void void
Int MaxFunctorTranslations void void
Atom EmptyWakeups[MAX_EMPTY_WAKEUPS] InitEmptyWakeups() RestoreEmptyWakeups()
int MaxEmptyWakeups =0

View File

@ -21,20 +21,20 @@ file_filter_with_initialization(A,B,C,D,E) :-
main :-
warning(Warning),
file_filter_with_initialization('misc/HEAPFIELDS','H/heap/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/heap/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/heap/h0struct.h',gen_0struct,Warning,['d0hstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/heap/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/heap/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/GLOBALS','H/heap/h0globals.h',gen_0struct,Warning,['hglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/heap/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/heap/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/heap/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']),
%% file_filter_with_initialization('misc/GLOBALS','H/heap/i0globals.h',gen_0init,Warning,['iglobals.h','GLOBALS']),
file_filter_with_initialization('misc/LOCALS','H/heap/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/heap/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/heap/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/heap/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']).
file_filter_with_initialization('misc/HEAPFIELDS','H/generated/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/generated/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/generated/h0struct.h',gen_0struct,Warning,['d0hstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/generated/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/HEAPFIELDS','H/generated/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']),
file_filter_with_initialization('misc/GLOBALS','H/generated/h0globals.h',gen_0struct,Warning,['hglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/generated/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/generated/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']),
file_filter_with_initialization('misc/GLOBALS','H/generated/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']),
%% file_filter_with_initialization('misc/GLOBALS','H/generated/i0globals.h',gen_0init,Warning,['iglobals.h','GLOBALS']),
file_filter_with_initialization('misc/LOCALS','H/generated/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/generated/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/generated/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']),
file_filter_with_initialization('misc/LOCALS','H/generated/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']).
warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildlocalglobal\"~n please do not update, update misc/~a instead */~n~n').

View File

@ -14,7 +14,7 @@ main :-
warning(Warning),
nb_setval(atom_counter,0),
nb_setval(functor_counter,0),
file_filter_with_init('misc/SWIATOMS','include/dswiatoms.h',gen_defs, Warning, ['dswiatoms.h']),
file_filter_with_init('misc/SWIATOMS','include/generated/dswiatoms.h',gen_defs, Warning, ['dswiatoms.h']),
open('include/dswiatoms.h',append,W),
nb_getval(atom_counter,SWIAtoms),
nb_getval(functor_counter,SWIFunctors),

View File

@ -34,7 +34,7 @@ include_directories (
add_library (real SHARED ${REAL_SOURCES})
target_link_libraries (real ${R_LIBRARIES} libYap )
target_link_libraries (real ${R_LIBRARIES} ${CMAKE_DL_LIBS} )
set_target_properties (real PROPERTIES PREFIX "")