home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Vectronix 2
/
VECTRONIX2.iso
/
FILES_01
/
X_PROLOG.LZH
/
X_PROLOG
/
SOURCES
/
BUILTIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-13
|
2KB
|
68 lines
/*
* X PROLOG Vers. 2.0
*
*
* Written by : Andreas Toenne
* CS Dept. , IRB
* University of Dortmund, W-Germany
* <at@unido.uucp>
* <....!seismo!unido!at>
* <at@unido.bitnet>
*
* Copyright : This software is copyrighted by Andreas Toenne.
* Permission is granted hereby to copy the entire
* package including this copyright notice without fee.
*
*/
#include "prolog.h"
#include "error.h"
#include "builtin.h"
#include "extern.h"
extern term *argument();
extern functor *get_functor();
extern clause *make_clause();
term *args[MAXARGS]; /* for the arguments */
/* call a given built in, check for proper argument count and */
/* extract the given arguments */
short call_builtin(which, t, e)
short which; /* # of that bi */
term *t; /* responsible term */
env *e; /* his enviroment */
{
short i, nargs;
nargs = bis[which].nargs;
if (nargs != ARITY(t)) /* not enough arguments */
return(FALSE); /* goal fails */
for (i=1; i<=nargs; i++) /* get the arguments */
args[i-1] = argument(t,e,i);
return((*bis[which].func)(args));/* call the bi */
}
/* Create proper definitions for all given built in's */
void build_bis()
{
functor *f;
short i;
for (i=0; bis[i].name; i++)
{
f = get_functor(bis[i].name, bis[i].nargs);
f->cp = (char *)make_clause(BUILTIN, (long)i, 0L, 0);
}
f = get_functor("$clause", 3); /* make infinite clause chain */
((clause *)(f->cp))->next = (clause *)(f->cp);
f = get_functor("repeat", 0);
((clause *)(f->cp))->next = (clause *)(f->cp);
f = get_functor("$functor", 3);
((clause *)(f->cp))->next = (clause *)(f->cp);
}