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

@@ -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) :-