YAP updates.

This commit is contained in:
Vitor Santos Costa
2011-02-10 00:02:05 +00:00
parent 232a740d43
commit 841f6eb1e5
13 changed files with 357 additions and 825 deletions

View File

@@ -201,15 +201,17 @@ static int emit_rubber(format_state *state);
word
pl_format_predicate(term_t chr, term_t descr)
{ int c;
Procedure proc;
predicate_t proc;
Symbol s;
int arity;
if ( !PL_get_char_ex(chr, &c, FALSE) )
fail;
if ( !get_procedure(descr, &proc, 0, GP_CREATE) )
fail;
if ( proc->definition->functor->arity == 0 )
PL_predicate_info(proc, NULL, &arity, NULL);
if ( arity == 0 )
return PL_error(NULL, 0, "arity must be > 0", ERR_DOMAIN,
PL_new_atom("format_predicate"),
descr);
@@ -255,8 +257,7 @@ pl_current_format_predicate(term_t chr, term_t descr, control_t h)
}
while( (s=advanceTableEnum(e)) )
{ if ( PL_unify_integer(chr, (intptr_t)s->name) &&
unify_definition(contextModule(LD->environment),
descr, ((Procedure)s->value)->definition, 0, 0) )
PL_unify_predicate(descr, (predicate_t)s->value, 0) )
{ PL_close_foreign_frame(fid);
ForeignRedoPtr(e);
}
@@ -419,20 +420,23 @@ do_format(IOSTREAM *fd, PL_chars_t *fmt, int argc, term_t argv)
/* Check for user defined format */
if ( format_predicates &&
(s = lookupHTable(format_predicates, (void*)((intptr_t)c))) )
{ Procedure proc = (Procedure) s->value;
FunctorDef fdef = proc->definition->functor;
term_t av = PL_new_term_refs(fdef->arity);
{ predicate_t proc = (predicate_t) s->value;
int arity;
term_t av;
char buf[BUFSIZE];
char *str = buf;
size_t bufsize = BUFSIZE;
unsigned int i;
PL_predicate_info(proc, NULL, &arity, NULL);
av = PL_new_term_refs(arity);
if ( arg == DEFAULT )
PL_put_atom(av+0, ATOM_default);
else
PL_put_integer(av+0, arg);
for(i=1; i<fdef->arity; i++)
for(i=1; i < arity; i++)
{ NEED_ARG;
PL_put_term(av+i, argv);
SHIFT;