home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / oleo_src.lha / src / eval.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-27  |  5.1 KB  |  226 lines

  1. /*    Copyright (C) 1990 Free Software Foundation, Inc.
  2.  
  3. This file is part of Oleo, the GNU Spreadsheet.
  4.  
  5. Oleo is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 1, or (at your option)
  8. any later version.
  9.  
  10. Oleo is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with Oleo; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* Despite the name, this file contains the #defines for all the byte-compiled
  20.    byte values.
  21.  */
  22.  
  23. /* 0 - 5  Control stuff */
  24. #define ENDCOMP        0    /* End of compiled code */
  25.  
  26. /* These are followed by a jump-code, or a two-byte jump-code */
  27.  
  28. #define IF        2    /* Followed by jump-code */
  29. #define IF_L        3
  30. #define F_IF        4    /* Like if, but decompiles differently */
  31. #define F_IF_L        5
  32. #define AND        6    /* Followed by jump-code */
  33. #define AND_L        7    /* Followed by jump-code */
  34. #define OR        8    /* Followed by jump-code */
  35. #define OR_L        9
  36.  
  37. #define CONST_STR    10
  38. #define CONST_STR_L    11
  39.  
  40. /* 12 - 15 Cell references */
  41. #define R_CELL        12
  42. #define ROWREL        1
  43. #define COLREL        2
  44.  
  45. /* 16 - 31 Range references */
  46. #define RANGE        16
  47. #define LRREL        1
  48. #define HRREL        2
  49. #define LCREL        4
  50. #define HCREL        8
  51.  
  52. /* 32 - 130  Various Constants */
  53. #define F_TRUE        32
  54. #define F_FALSE        33
  55. #define CONST_INF    34
  56. #define CONST_NINF    35
  57. #define CONST_NAN    36
  58. #define CONST_ERR    37    /* Followed by error code and text(?) */
  59. #define CONST_FLT    38    /* Followed by double */
  60. #define CONST_INT    39    /* Followed by long */
  61.  
  62. /* 131    Variable reference */
  63. #define VAR        40    /* Followed by struct var * */
  64.  
  65. /* Unary Functions */
  66. #define NEGATE        41
  67. #define NOT        42
  68.  
  69. /* Binary Functions */
  70. #define DIFF        43
  71. #define DIV        44
  72. #define MOD        45
  73. #define PROD        46
  74. #define SUM        47
  75. #define CONCAT        48
  76. #define EQUAL        49
  77. #define GREATEQ        50
  78. #define GREATER        51
  79. #define LESS        52
  80. #define LESSEQ        53
  81. #define NOTEQUAL    54
  82. #define POW        55
  83.  
  84. #define F_PI        56
  85. #define F_ROW        57
  86. #define F_COL        58
  87. #define F_NOW        59
  88.  
  89. /* 40 - 65 one-operand functions */
  90. #define F_ABS        60
  91. #define F_ACOS        61
  92. #define F_ASIN        62
  93. #define F_ATAN        63
  94. #define F_CEIL        64
  95. #define F_INT        65
  96. #define F_FLOOR        66
  97. #define F_COS        67
  98. #define F_DTR        68
  99. #define F_EXP        69
  100. #define F_LOG        70
  101. #define F_LOG10        71
  102. #define F_RTD        72
  103. #define F_SIN        73
  104. #define F_SQRT        74
  105. #define F_TAN        75
  106. #define F_CTIME        76
  107. #define F_NEG        77
  108. #define F_NOT        78
  109. #define F_ISERR        79
  110. #define F_ISNUM        80
  111. #define F_RND        81
  112. #define F_ROWS        82
  113. #define F_COLS        83
  114.  
  115. /* 75 - 98 Two-operand functions */
  116. #define F_ATAN2        84
  117. #define F_HYPOT        85
  118. #define F_FIXED        86
  119. #define F_IFERR        87
  120.  
  121. #define F_INDEX        88
  122.  
  123. /* 100 - 106 Three input functions */
  124. #define F_INDEX2    89
  125.  
  126. /* 110 - 114 N-input functions */
  127. #define F_ONEOF        90
  128.  
  129. #define F_FILE        91
  130.  
  131. /* 115 - 122 area functions */
  132. #define AREA_SUM    92
  133. #define AREA_PROD    93
  134. #define AREA_AVG    94
  135. #define AREA_STD    95
  136. #define AREA_MAX    96
  137. #define AREA_MIN    97
  138. #define AREA_CNT    98
  139. #define AREA_VAR    99
  140.  
  141. #define USR1        100    /* User defined function */
  142.                 /* Followed by function # */
  143.  
  144. #define SKIP        254
  145. #define SKIP_L        255
  146.  
  147. struct function {
  148.         /* See C_mumble below.  This is used when byte-compiling,
  149.             and decompiling */
  150.         /* The infix information is *not* used for parsing, although
  151.            it should be. . . */
  152.     short fn_comptype;
  153.  
  154.         /* See X_mumble below.  This encodes the number of arguments
  155.            this function takes.  It is used by the expression
  156.            evaluator and the parser. */
  157.     char fn_argn;
  158.  
  159.         /* This is used by the expression evaluator to convert the
  160.             args to the fun into the appropriate type
  161.             (And by the parser to see if the function will accept
  162.            regions as arguments) */
  163.     char fn_argt[4];
  164.  
  165.         /* This function is called by the expression evaluator
  166.             when the (spreadsheet) function is executed */
  167.     void (*fn_fun)();
  168.  
  169.         /* This is the function's name.  It gets used for compiling
  170.            decompiling, and parsing. . . */
  171.     char *fn_str;
  172. };
  173.  
  174. extern struct function the_funs[];
  175. extern int n_usr_funs;
  176. extern struct function **usr_funs;
  177. extern int *usr_n_funs;
  178. extern struct function skip_funs[];
  179.  
  180. /* Magic numbers for byte-compiling and decompiling expressions */
  181. /* These need only be distinct (and have x|C_T be distinct too!) */
  182. #define GET_COMP(x) ((x)&0x1f)
  183. #define C_IF     0x1
  184. #define C_ANDOR  0x2
  185. #define C_ERR     0x3
  186. #define C_FLT     0x4
  187. #define C_INT     0x5
  188. #define C_STR     0x6
  189. #define C_VAR     0x7
  190. #define C_CELL     0x8
  191. #define C_RANGE     0x9
  192. #define C_FN0X     0xA
  193. #define C_FN0     0xB
  194. #define C_FN1     0xC
  195. #define C_FN2     0xD
  196. #define C_FN3     0xE
  197. #define C_FN4     0xF
  198. #define C_FNN    0x10
  199. #define C_INF    0x11
  200. #define C_UNA    0x12
  201. #define C_CONST    0x13
  202. #define C_SKIP  0x14
  203.  
  204. #define C_T     0x20
  205.  
  206. #define INF(x)    (x<<8)
  207. #define ASO    0xC0
  208. #define R    0x40
  209. #define L    0x80
  210. #define N    0xC0
  211.  
  212. #define ISINFIX(x)    ((x)&ASO)
  213. #define GET_IN(x)    ((x)>>8)
  214. #define GET_ASO(x)    (((x)&ASO)==R ? -1 : (((x)&ASO)==L ? 1 : 0))
  215.  
  216. #define X_ARGS    0x07
  217. #define X_A0    0
  218. #define X_A1    1
  219. #define X_A2    2
  220. #define X_A3    3
  221. #define X_A4    4
  222. #define X_AN    5
  223.  
  224. #define X_J    0x08
  225. #define X_JL    0x10
  226.