static char *SccsId = "@(#)bifunc.cls 4.2 (TU-Delft) 06/11/91";
/**********************************************************

Name/Version      : sls_mkdb/4.2

Language          : C
Operating system  : UNIX SYSTEM V
Host machine      : HP9000

Author(s)         : A.C. de Graaf
Creation date     : 10-Jul-1986
Modified by       : S. de Graaf
Modification date : 10-Jul-1986


        Delft University of Technology
        Department of Electrical Engineering
        Network Theory Section
        Mekelweg 4 - P.O.Box 5031
        2600 GA DELFT
        The Netherlands

        Phone : 015 - 786234

        COPYRIGHT (C) 1986 , All rights reserved
**********************************************************/
#include "sys_incl.h"
#class
#include "class.h"
#include "mkdbdefs.h"

class built_in_func {
public:
	char *name;
	Network *ntw;
};

typedef class built_in_func Bifunc;

Bifunc  *bifunc;

int bif_nbr;

void init_bifs() {
	Stack *pxs;
	Queue *bif_termq;
	Network *ntw;
	Netelem *fterm;
	Xelem *pxelem;

	bif_termq = new Queue (QueueType);
	pxs = new Stack (1);
	pxelem = new Xelem (0, 0);
	pxs -> push ((char *) pxelem);
	fterm = new Netelem ("i", NULL, TermType);
	fterm -> xs = pxs;
	bif_termq -> put ((Link *) fterm);
	fterm = new Netelem ("o", NULL, TermType);
	bif_termq -> put ((Link *) fterm);

	bifunc = new Bifunc [6];
        bif_nbr = 6;

	bifunc[0].name= "and";
	bifunc[1].name= "exor";
	bifunc[2].name= "nand";
	bifunc[3].name= "nor";
	bifunc[4].name= "or";
	bifunc[5].name= "invert";

	bifunc[0].ntw = new Network ("and");
	bifunc[1].ntw = new Network ("exor");
	bifunc[2].ntw = new Network ("nand");
	bifunc[3].ntw = new Network ("nor");
	bifunc[4].ntw = new Network ("or");
	bifunc[5].ntw = new Network ("invert");

	bifunc[0].ntw -> termq = bif_termq;
	bifunc[1].ntw -> termq = bif_termq;
	bifunc[2].ntw -> termq = bif_termq;
	bifunc[3].ntw -> termq = bif_termq;
	bifunc[4].ntw -> termq = bif_termq;
	bifunc[5].ntw -> termq = bif_termq;
}

Network *is_bifunc(name)
char * name;
{
     int i;
     int strcmp();
     Bifunc * pbif = bifunc;

     for (i = 0; i < bif_nbr; i++)
     {
	 if(strcmp(name, pbif -> name) == NULL)
	     return(pbif -> ntw);
	 pbif++;
     }

     return(NULL);
}
