This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/library/dialect/swi/os/pl-codelist.h

48 lines
880 B
C
Raw Normal View History

2011-02-10 00:01:19 +00:00
#ifndef PL_CODELIST_H
#define PL_CODELIST_H
static inline Word
INIT_SEQ_STRING(size_t n)
{
2013-11-16 00:27:02 +00:00
CACHE_REGS
return RepPair(OpenList(n PASS_REGS));
2011-02-10 00:01:19 +00:00
}
static inline Word
2011-03-11 19:49:32 +00:00
EXTEND_SEQ_CODES(Word ptr, int c) {
CACHE_REGS
2011-03-11 19:49:32 +00:00
ptr[0] = MkIntegerTerm(c);
ptr[1] = AbsPair(ptr+2);
return ptr+2;
2011-02-10 00:01:19 +00:00
}
static inline Word
2011-03-11 19:49:32 +00:00
EXTEND_SEQ_CHARS(Word ptr, int c) {
ptr[0] = codeToAtom(c);
ptr[1] = AbsPair(ptr+2);
return ptr+2;
2011-02-10 00:01:19 +00:00
}
2015-04-13 13:28:17 +01:00
static inline int
2011-03-11 19:49:32 +00:00
CLOSE_SEQ_STRING(Word p, Word p0, term_t tail, term_t term, term_t l) {
CACHE_REGS
Yap_PutInSlot(l, AbsPair(p0) PASS_REGS);
p--;
if (tail) {
RESET_VARIABLE(p);
2015-04-13 13:28:17 +01:00
if (Yap_unify(Yap_GetFromSlot(l), Yap_GetFromSlot(term))) {
2011-03-11 19:49:32 +00:00
Yap_PutInSlot(tail, (CELL)(p) PASS_REGS);
return TRUE;
}
return FALSE;
2011-02-10 00:01:19 +00:00
} else {
2013-11-16 00:27:02 +00:00
p[0] = TermNil;
2015-04-13 13:28:17 +01:00
return Yap_unify(Yap_GetFromSlot(l), Yap_GetFromSlot(term ));
2011-02-10 00:01:19 +00:00
}
}
#endif