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