home *** CD-ROM | disk | FTP | other *** search
- /* mkop.c -- make operator function for bs.
- *
- * USAGE: op name type oper tag
- *
- * where: name: name of function generated.
- * type: data type of operation.
- * oper: operator for operation.
- * tag: structure tag name.
- *
- * This will only work with T_INT and T_DBL operators, T_CHR operations
- * do not boil down to a simple operation.
- */
- #include <stdio.h>
-
- main(argc,argv)
- char **argv;
- int argc;
- {
- char *name,*type,*oper,*tag;
-
- if(argc != 5) {
- fprintf(stderr,"arg count\n");
- exit(1);
- }
- name = argv[1]; type = argv[2]; oper = argv[3]; tag = argv[4];
-
- printf("_%s(l,p)\n",name);
- printf("int (*l[])(),p;\n");
- printf("{\n");
- printf(" union value rg1,rg2,result;\n");
- printf("\n");
- printf(" switch(status&XMODE) {\n");
- printf(" case M_READ: dtype = T_%s;\n",type);
- printf(" case M_EXECUTE:\n");
- printf(" rg2 = pop();\n");
- printf(" rg1 = pop();\n");
- printf(" result.%s = rg1.%s %s rg2.%s;\n",tag,tag,oper,tag);
- printf(" push(result);\n");
- printf(" case M_FIXUP:\n");
- printf(" case M_COMPILE: return(p);\n");
- printf(" default: STerror(\"%s\");\n",name);
- printf(" }\n");
- printf("}\n");
- }
-