home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Utilities / Calc / func.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-24  |  2.1 KB  |  56 lines  |  [TEXT/????]

  1. /*
  2.  * Copyright (c) 1992 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  */
  6.  
  7.  
  8. /*
  9.  * Structure of a function.
  10.  * The f_opcodes array is actually of variable size.
  11.  */
  12. typedef struct func FUNC;
  13. struct func {
  14.     FUNC *f_next;            /* next function in list */
  15.     unsigned long f_opcodecount;    /* size of opcode array */
  16.     unsigned int f_localcount;    /* number of local variables */
  17.     unsigned int f_paramcount;    /* max number of parameters */
  18.     char *f_name;            /* function name */
  19.     VALUE f_savedvalue;        /* saved value of last expression */
  20.     long f_opcodes[1];        /* array of opcodes (variable length) */
  21. };
  22.  
  23.  
  24. /*
  25.  * Amount of space needed to allocate a function of n opcodes.
  26.  */
  27. #define funcsize(n) (sizeof(FUNC) + (n) * sizeof(long))
  28.  
  29.  
  30. /*
  31.  * Size of a character pointer rounded up to a number of opcodes.
  32.  */
  33. #define PTR_SIZE ((sizeof(char *) + sizeof(long) - 1) / sizeof(long))
  34.  
  35.  
  36. extern FUNC *curfunc;        /* current function being compiled */
  37. extern FUNC *findfunc();    /* return function given index */
  38. extern char *namefunc();    /* return function name given index */
  39. extern BOOL evaluate();        /* evaluate a line */
  40. extern long adduserfunc();
  41. extern void beginfunc();    /* initialize a function for definition */
  42. extern int builtinopcode();    /* return the opcode for a built-in function */
  43. extern void addop();        /* add an opcode to the current function */
  44. extern void endfunc();        /* commit the just defined function for use */
  45. extern void addopindex();    /* add an opcode & index to the current func */
  46. extern void addoplabel();    /* add jump-type opcode + label to the func */
  47. extern void addopptr();        /* add an opcode + char ptr to the func */
  48. extern void showbuiltins();    /* show list of primitive builtin funcs */
  49. extern int getbuiltinfunc();    /* return the index of a built-in func */
  50. extern void builtincheck();    /* determine if the # of arguments are legal */
  51. extern void addopfunction();    /* add opcode + index + arg count to the func */
  52. extern void showfunctions();    /* show the list of user defined functs */
  53. extern void clearopt();        /* clear optimization done for next opcode */
  54.  
  55. /* END CODE */
  56.