/************************************************************************ * * * The SB-Prolog System * * Copyright SUNY at Stony Brook, 1986 * * * ************************************************************************/ /*----------------------------------------------------------------- SB-Prolog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the SB-Prolog General Public License for full details. Everyone is granted permission to copy, modify and redistribute SB-Prolog, but only under the conditions described in the SB-Prolog General Public License. A copy of this license is supposed to have been given to you along with SB-Prolog so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. ------------------------------------------------------------------ */ /* init_branch.c */ #include "builtin.h" extern int b_0(); extern int b_1(); extern int b_NAME0(); extern int b_BLDATOM(); extern int b_RESET (); extern int b_REWRITE (); extern int b_GET0 (); extern int b_GET (); extern int b_SKIP (); extern int b_READ (); extern int b_CLOSE (); extern int b_PUT (); extern int b_TAB (); extern int b_NL (); extern int b_FILEERRORS (); extern int b_NOFILEERRORS (); extern int b_ALLOC_BUFF (); extern int b_BUFF_CODE (); extern int b_TRIMBUFF (); extern int b_WRITE4 (); extern int b_ARITH (); extern int b_FLOATC (); extern int b_REAL (); extern int b_FLOOR0 (); extern int b_VAR (); extern int b_NONVAR (); extern int b_ATOM (); extern int b_INTEGER (); extern int b_ATOMIC (); extern int b_ARITY (); extern int b_STATS (); extern int b_CPUTIME (); extern int b_LENGTH (); extern int b_COMPARE (); extern int b_SAVE (); extern int b_RESTORE (); extern int b_ARG0 (); extern int b_FUNCTOR0 (); extern int b_SYSTEM0 (); extern int b_SYSCALL (); extern int b_BROCALL (); extern int b_ERRNO (); extern int b_BLDSTR (); extern int b_TERMREP (); extern int b_STRUCTURE (); extern int b_WRITEQNAME (); extern int b_WRITENAME (); extern int b_CALL (); extern int b_LOAD (); extern int b_SEE(); extern int b_SEEING(); extern int b_SEEN(); extern int b_TELL(); extern int b_TELLING(); extern int b_TOLD(); extern int b_STATISTICS(); extern int b_SYMTYPE(); extern int b_HASHVAL(); extern int b_TRACE(); extern int b_PILTRACE(); extern int b_UNTRACE(); extern int b_FLAGS(); extern int b_SUBSTRING(); extern int b_SUBNUMBER(); extern int b_SUBDELIM(); extern int b_CONLENGTH(); /* CURSES: add this instruction extern int b_CURSES(); */ #define set_b_inst(b_inst, routine) \ branch_table[b_inst] = routine int (*branch_table[256])(); b_unused() { printf("Builtin #%d is not implemented.\n", oprnd1); exit(111); } init_branch_table() { int i; for (i=0; i<256; i++) set_b_inst( i, b_unused); set_b_inst ( VAR, b_VAR); set_b_inst ( BUFF_CODE, b_BUFF_CODE); set_b_inst ( TRIMBUFF, b_TRIMBUFF); set_b_inst ( ALLOC_BUFF, b_ALLOC_BUFF); set_b_inst ( SYSTEM0, b_SYSTEM0); set_b_inst ( SYSCALL, b_SYSCALL); set_b_inst ( BROCALL, b_BROCALL); set_b_inst ( ERRNO, b_ERRNO); set_b_inst ( NONVAR, b_NONVAR); set_b_inst ( TERMREP, b_TERMREP); set_b_inst ( WRITE4, b_WRITE4); set_b_inst ( ARITH, b_ARITH); set_b_inst ( FLOATC, b_FLOATC); set_b_inst ( REAL, b_REAL); set_b_inst ( FLOOR0, b_FLOOR0); set_b_inst ( INTEGER, b_INTEGER); set_b_inst ( ATOM, b_ATOM); set_b_inst ( ATOMIC, b_ATOMIC ); set_b_inst ( ARITY, b_ARITY); set_b_inst ( LENGTH, b_LENGTH); set_b_inst ( STRUCTURE, b_STRUCTURE); set_b_inst ( ARG0, b_ARG0); set_b_inst ( FUNCTOR0, b_FUNCTOR0); set_b_inst ( BLDSTR, b_BLDSTR); set_b_inst ( WRITEQNAME, b_WRITEQNAME); set_b_inst ( FILEERRORS, b_FILEERRORS); set_b_inst ( NOFILEERRORS, b_NOFILEERRORS); set_b_inst ( PUT, b_PUT); set_b_inst ( GET0, b_GET0); set_b_inst ( GET, b_GET); set_b_inst ( SKIP, b_SKIP); set_b_inst ( TAB, b_TAB); set_b_inst ( NL, b_NL); set_b_inst ( WRITENAME, b_WRITENAME); set_b_inst ( RESET, b_RESET); set_b_inst ( REWRITE, b_REWRITE); set_b_inst ( CLOSE, b_CLOSE); set_b_inst ( 0, b_0); set_b_inst ( 1, b_1); set_b_inst ( NAME0, b_NAME0); set_b_inst ( BLDATOM, b_BLDATOM); set_b_inst ( CALL, b_CALL); set_b_inst ( LOAD, b_LOAD); set_b_inst ( SEE, b_SEE); set_b_inst ( SEEING, b_SEEING); set_b_inst ( SEEN, b_SEEN); set_b_inst ( TELL, b_TELL); set_b_inst ( TELLING, b_TELLING); set_b_inst ( TOLD, b_TOLD); set_b_inst ( CPUTIME, b_CPUTIME); set_b_inst ( STATS, b_STATS); set_b_inst ( COMPARE, b_COMPARE); set_b_inst ( SAVE, b_SAVE); set_b_inst ( RESTORE, b_RESTORE); set_b_inst ( STATISTICS, b_STATISTICS); set_b_inst ( SYMTYPE, b_SYMTYPE); set_b_inst ( HASHVAL, b_HASHVAL); set_b_inst ( TRACE, b_TRACE); set_b_inst ( PILTRACE, b_PILTRACE); set_b_inst ( UNTRACE, b_UNTRACE); set_b_inst ( FLAGS, b_FLAGS); set_b_inst ( SUBSTRING, b_SUBSTRING); set_b_inst ( SUBNUMBER, b_SUBNUMBER); set_b_inst ( SUBDELIM, b_SUBDELIM); set_b_inst ( CONLENGTH, b_CONLENGTH); /* CURSES: add this instruction set_b_inst ( CURSES, b_CURSES); */ }