pretty print
This commit is contained in:
parent
d90a0f72b0
commit
9444c36ff4
@ -8,9 +8,7 @@
|
|||||||
|
|
||||||
/* need to fix overflow handling */
|
/* need to fix overflow handling */
|
||||||
|
|
||||||
static void
|
static void mk_blob(int sz USES_REGS) {
|
||||||
mk_blob(int sz USES_REGS)
|
|
||||||
{
|
|
||||||
MP_INT *dst;
|
MP_INT *dst;
|
||||||
|
|
||||||
HR[0] = (CELL)FunctorBigInt;
|
HR[0] = (CELL)FunctorBigInt;
|
||||||
@ -23,9 +21,7 @@ mk_blob(int sz USES_REGS)
|
|||||||
HR += sz + 1;
|
HR += sz + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CELL *
|
static CELL *extend_blob(CELL *start, int sz USES_REGS) {
|
||||||
extend_blob(CELL *start, int sz USES_REGS)
|
|
||||||
{
|
|
||||||
UInt osize;
|
UInt osize;
|
||||||
MP_INT *dst;
|
MP_INT *dst;
|
||||||
|
|
||||||
@ -41,11 +37,8 @@ extend_blob(CELL *start, int sz USES_REGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*init of ClasuseList*/
|
/*init of ClasuseList*/
|
||||||
X_API clause_list_t
|
clause_list_t Yap_ClauseListInit(clause_list_t in) {
|
||||||
Yap_ClauseListInit(clause_list_t in)
|
CACHE_REGS in->n = 0;
|
||||||
{
|
|
||||||
CACHE_REGS
|
|
||||||
in->n = 0;
|
|
||||||
in->start = HR;
|
in->start = HR;
|
||||||
mk_blob(0 PASS_REGS);
|
mk_blob(0 PASS_REGS);
|
||||||
in->end = HR;
|
in->end = HR;
|
||||||
@ -54,9 +47,7 @@ Yap_ClauseListInit(clause_list_t in)
|
|||||||
|
|
||||||
/*add clause to ClauseList
|
/*add clause to ClauseList
|
||||||
returns FALSE on error*/
|
returns FALSE on error*/
|
||||||
X_API int
|
int Yap_ClauseListExtend(clause_list_t cl, void *clause, void *pred) {
|
||||||
Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
PredEntry *ap = (PredEntry *)pred;
|
PredEntry *ap = (PredEntry *)pred;
|
||||||
|
|
||||||
@ -65,13 +56,17 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (cl->n == 0) {
|
if (cl->n == 0) {
|
||||||
void **ptr;
|
void **ptr;
|
||||||
if (!(ptr = (void **)extend_blob(cl->start,1 PASS_REGS))) return FALSE;
|
if (!(ptr = (void **)extend_blob(cl->start, 1 PASS_REGS)))
|
||||||
|
return FALSE;
|
||||||
ptr[0] = clause;
|
ptr[0] = clause;
|
||||||
} else if (cl->n == 1) {
|
} else if (cl->n == 1) {
|
||||||
yamop **ptr;
|
yamop **ptr;
|
||||||
yamop *code_p, *fclause;
|
yamop *code_p, *fclause;
|
||||||
|
|
||||||
if (!(ptr = (yamop **)extend_blob(cl->start,2*(CELL)NEXTOP((yamop *)NULL,Otapl)/sizeof(CELL)-1 PASS_REGS))) return FALSE;
|
if (!(ptr = (yamop **)extend_blob(
|
||||||
|
cl->start, 2 * (CELL)NEXTOP((yamop *)NULL, Otapl) / sizeof(CELL) -
|
||||||
|
1 PASS_REGS)))
|
||||||
|
return FALSE;
|
||||||
fclause = ptr[-1];
|
fclause = ptr[-1];
|
||||||
code_p = (yamop *)(ptr - 1);
|
code_p = (yamop *)(ptr - 1);
|
||||||
code_p->opc = Yap_opcode(_try_clause);
|
code_p->opc = Yap_opcode(_try_clause);
|
||||||
@ -98,7 +93,10 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
} else {
|
} else {
|
||||||
yamop *code_p;
|
yamop *code_p;
|
||||||
|
|
||||||
if (!(code_p = (yamop *)extend_blob(cl->start,((CELL)NEXTOP((yamop *)NULL,Otapl))/sizeof(CELL) PASS_REGS))) return FALSE;
|
if (!(code_p = (yamop *)extend_blob(cl->start,
|
||||||
|
((CELL)NEXTOP((yamop *)NULL, Otapl)) /
|
||||||
|
sizeof(CELL) PASS_REGS)))
|
||||||
|
return FALSE;
|
||||||
code_p->opc = Yap_opcode(_trust);
|
code_p->opc = Yap_opcode(_trust);
|
||||||
code_p->y_u.Otapl.d = clause;
|
code_p->y_u.Otapl.d = clause;
|
||||||
code_p->y_u.Otapl.s = ap->ArityOfPE;
|
code_p->y_u.Otapl.s = ap->ArityOfPE;
|
||||||
@ -118,16 +116,11 @@ Yap_ClauseListExtend(clause_list_t cl, void * clause, void *pred)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*closes the clause list*/
|
/*closes the clause list*/
|
||||||
X_API void
|
void Yap_ClauseListClose(clause_list_t cl) { /* no need to do nothing */
|
||||||
Yap_ClauseListClose(clause_list_t cl)
|
|
||||||
{
|
|
||||||
/* no need to do nothing */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*destroys the clause list freeing memory*/
|
/*destroys the clause list freeing memory*/
|
||||||
X_API int
|
int Yap_ClauseListDestroy(clause_list_t cl) {
|
||||||
Yap_ClauseListDestroy(clause_list_t cl)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (cl->end != HR)
|
if (cl->end != HR)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -136,23 +129,20 @@ Yap_ClauseListDestroy(clause_list_t cl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*destroys clause list and returns only first clause*/
|
/*destroys clause list and returns only first clause*/
|
||||||
X_API void *
|
void *Yap_ClauseListToClause(clause_list_t cl) {
|
||||||
Yap_ClauseListToClause(clause_list_t cl)
|
|
||||||
{
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
void **ptr;
|
void **ptr;
|
||||||
if (cl->end != HR)
|
if (cl->end != HR)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (cl->n != 1)
|
if (cl->n != 1)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!(ptr = (void **)extend_blob(cl->start,0 PASS_REGS))) return NULL;
|
if (!(ptr = (void **)extend_blob(cl->start, 0 PASS_REGS)))
|
||||||
|
return NULL;
|
||||||
return ptr[-1];
|
return ptr[-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return pointer to start of try-retry-trust sequence*/
|
/*return pointer to start of try-retry-trust sequence*/
|
||||||
X_API void *
|
void *Yap_ClauseListCode(clause_list_t cl) {
|
||||||
Yap_ClauseListCode(clause_list_t cl)
|
|
||||||
{
|
|
||||||
CELL *ptr;
|
CELL *ptr;
|
||||||
ptr = (CELL *)cl->start;
|
ptr = (CELL *)cl->start;
|
||||||
ptr += (1 + sizeof(MP_INT) / sizeof(CELL));
|
ptr += (1 + sizeof(MP_INT) / sizeof(CELL));
|
||||||
@ -160,10 +150,4 @@ Yap_ClauseListCode(clause_list_t cl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* where to fail */
|
/* where to fail */
|
||||||
X_API void *
|
void *Yap_FAILCODE(void) { return (void *)FAILCODE; }
|
||||||
Yap_FAILCODE(void)
|
|
||||||
{
|
|
||||||
return (void *)FAILCODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user