Rev 9 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 11 | mjames | 1 | /* contains the type declarations for expression handling information |
| 2 | mjames | 2 | * |
| 11 | mjames | 3 | * $Header: c:\\cygwin\\cvsroot/Vert03/vertlib/expression.h,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
| 2 | mjames | 4 | * |
| 5 | * $Log: expression.h,v $ |
||
| 6 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
||
| 7 | * Imported into local repositrory |
||
| 8 | * |
||
| 9 | * Revision 1.8 2002/10/02 19:37:30 MJAMES |
||
| 10 | * Moved dummy functions to a separate support file. |
||
| 11 | * |
||
| 12 | * Used correct number of arguments to define_pin |
||
| 13 | * |
||
| 14 | * Revision 1.7 2002/09/30 13:22:38 MJAMES |
||
| 15 | * Altered the use and creation of partition |
||
| 16 | * generics (at evaluation time of expressions within the partition ) |
||
| 17 | * This still needs checking, as evaluation of the expression may well be |
||
| 18 | * delayed until after when the partition generics need to be defined. |
||
| 19 | * |
||
| 20 | * Revision 1.6 2002/09/09 10:15:54 mjames |
||
| 21 | * Modified expression parser to match CC as previous one was |
||
| 22 | * broken |
||
| 23 | * |
||
| 24 | * Revision 1.5 2002/08/14 12:04:42 mjames |
||
| 25 | * Added declaration for eval_expression |
||
| 26 | * |
||
| 27 | * Revision 1.5 2002/04/04 14:53:05 mjames |
||
| 28 | * Added mentor board station reader to the portfolio |
||
| 29 | * |
||
| 30 | * Revision 1.4 2001/10/31 22:20:04 mjames |
||
| 31 | * Tidying up problematical comments caused by CVS |
||
| 32 | * 'intelligent' comment guessing |
||
| 33 | * |
||
| 34 | * Revision 1.3 2001/06/06 12:10:23 mjames |
||
| 35 | * Move from HPUX |
||
| 36 | * |
||
| 37 | * Revision 1.2 2000/11/29 21:51:18 mjames |
||
| 38 | * Fine tuning of software |
||
| 39 | * |
||
| 40 | * Revision 1.1.1.1 2000/10/19 21:58:37 mjames |
||
| 41 | * Mike put it here |
||
| 42 | * |
||
| 43 | * |
||
| 44 | * Revision 1.19 2000/10/04 10:37:15 10:37:15 mjames (Mike James) |
||
| 45 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
||
| 11 | mjames | 46 | * |
| 2 | mjames | 47 | * Revision 1.19 2000/10/04 10:37:15 10:37:15 mjames (Mike James) |
| 48 | * Part of Release PSAVAT01 |
||
| 11 | mjames | 49 | * |
| 2 | mjames | 50 | * Revision 1.18 2000/10/02 11:04:12 11:04:12 mjames (Mike James) |
| 51 | * new_vhdl |
||
| 11 | mjames | 52 | * |
| 2 | mjames | 53 | * Revision 1.17 2000/09/27 14:42:30 14:42:30 mjames (Mike James) |
| 54 | * Part of Release Sep_27_ST_2000 |
||
| 11 | mjames | 55 | * |
| 2 | mjames | 56 | * Revision 1.16 2000/09/21 10:16:00 10:16:00 mjames (Mike James) |
| 57 | * Part of Release Sep21Alpha |
||
| 11 | mjames | 58 | * |
| 2 | mjames | 59 | * Revision 1.15 2000/08/25 09:57:23 09:57:23 mjames (Mike James) |
| 60 | * Part of Release Aug25_alpha |
||
| 11 | mjames | 61 | * |
| 2 | mjames | 62 | * Revision 1.14 2000/08/16 08:57:40 08:57:40 mjames (Mike James) |
| 63 | * Part of Release CD01_Aug2000 |
||
| 11 | mjames | 64 | * |
| 2 | mjames | 65 | * Revision 1.13 2000/08/14 14:45:19 14:45:19 mjames (Mike James) |
| 66 | * Part of Release Aug_14_2000 |
||
| 11 | mjames | 67 | * |
| 2 | mjames | 68 | * Revision 1.12 2000/08/11 08:30:40 08:30:40 mjames (Mike James) |
| 69 | * Part of Release Aug_11_2000 |
||
| 11 | mjames | 70 | * |
| 2 | mjames | 71 | * Revision 1.11 2000/08/09 10:31:57 10:31:57 mjames (Mike James) |
| 72 | * Part of Release Aug__9_2000 |
||
| 11 | mjames | 73 | * |
| 2 | mjames | 74 | * Revision 1.10 2000/05/31 11:43:11 11:43:11 mjames (Mike James) |
| 75 | * Part of Release May_31_2000 |
||
| 11 | mjames | 76 | * |
| 2 | mjames | 77 | * Revision 1.9 2000/05/08 17:01:46 17:01:46 mjames (Mike James) |
| 78 | * Part of Release May__8_2000 |
||
| 11 | mjames | 79 | * |
| 2 | mjames | 80 | * Revision 1.8 2000/05/08 16:59:40 16:59:40 mjames (Mike James) |
| 81 | * Part of Release May__8_2000 |
||
| 11 | mjames | 82 | * |
| 2 | mjames | 83 | * Revision 1.7 2000/05/08 16:57:16 16:57:16 mjames (Mike James) |
| 84 | * Part of Release May__8_2000 |
||
| 11 | mjames | 85 | * |
| 2 | mjames | 86 | * Revision 1.6 2000/03/08 16:18:57 16:18:57 mjames (Mike James) |
| 87 | * New version including PC |
||
| 11 | mjames | 88 | * |
| 2 | mjames | 89 | * Revision 1.3 2000/01/20 15:58:58 15:58:58 mjames (Mike James) |
| 90 | * Part of Release R22 |
||
| 11 | mjames | 91 | * |
| 2 | mjames | 92 | * Revision 1.2 99/12/22 11:15:39 11:15:39 mjames (Mike James) |
| 93 | * Part of Release Dec_22_1999 |
||
| 11 | mjames | 94 | * |
| 2 | mjames | 95 | * Revision 1.1 99/06/25 14:36:23 14:36:23 mjames (Mike James) |
| 96 | * Initial revision |
||
| 11 | mjames | 97 | * |
| 2 | mjames | 98 | * */ |
| 99 | #if !defined _EXPRESSION |
||
| 100 | #define _EXPRESSION |
||
| 101 | |||
| 11 | mjames | 102 | |
| 2 | mjames | 103 | /* constants for object types found at bottom of expressions */ |
| 11 | mjames | 104 | #define EXP_CONSTANT 'C' |
| 105 | #define EXP_VAR_REF 'I' |
||
| 106 | #define EXP_BOOLEAN 'B' |
||
| 107 | #define EXP_VARIABLE 'V' |
||
| 108 | #define EXP_STRING 'S' |
||
| 109 | #define EXP_UNDEF_VAR 'U' |
||
| 110 | #define EXP_CHAR 'H' |
||
| 2 | mjames | 111 | |
| 11 | mjames | 112 | |
| 113 | |||
| 114 | /* decoding recurse_generics |
||
| 2 | mjames | 115 | * 0: NO_RECURSE stop expanding generics when a constant encountered |
| 116 | * 1: RECURSE_CONST expand generics until one found which does not contain an expression |
||
| 117 | * 2: RECURSE_NUMBER: expand generics until all constants are exposed |
||
| 11 | mjames | 118 | |
| 2 | mjames | 119 | constant a : integer := 3; |
| 120 | constant b : integer := a + 3; |
||
| 121 | constant c : integer := b + a; |
||
| 11 | mjames | 122 | |
| 2 | mjames | 123 | for values of expand generics : |
| 11 | mjames | 124 | value 0: |
| 2 | mjames | 125 | constant a : integer := 3; |
| 126 | constant b : integer := a + 3; |
||
| 127 | constant c : integer := b + a; |
||
| 11 | mjames | 128 | |
| 129 | value 1: |
||
| 2 | mjames | 130 | constant a : integer := 3; |
| 131 | constant b : integer := a + 3; |
||
| 132 | constant c : integer := (a+3) + a; |
||
| 11 | mjames | 133 | |
| 134 | value 2: |
||
| 2 | mjames | 135 | constant a : integer := 3; |
| 136 | constant b : integer := (3) + 3; |
||
| 137 | constant c : integer := ((3)+3) + (3); |
||
| 11 | mjames | 138 | |
| 139 | |||
| 2 | mjames | 140 | */ |
| 141 | |||
| 11 | mjames | 142 | typedef enum { NO_RECURSE=0,RECURSE_CONST,RECURSE_NUMBER } generic_print_style; |
| 2 | mjames | 143 | |
| 144 | struct generic_info; |
||
| 145 | /* see database.h for the description of expression_t */ |
||
| 146 | /* expression data structures .. see expression.h for handler fns */ |
||
| 11 | mjames | 147 | typedef struct exp { |
| 148 | int opcode; |
||
| 149 | union { |
||
| 150 | char * s; /* pointer to string value */ |
||
| 151 | struct generic_info * g; /* pointer to generic value */ |
||
| 152 | int i; /* integer part of expression */ |
||
| 153 | struct exp * e; |
||
| 154 | int * ip; /* pointer to an integer somewhere */ |
||
| 155 | } left; /* values */ |
||
| 156 | union { |
||
| 157 | char * s; /* pointer to name */ |
||
| 158 | struct exp * e; |
||
| 159 | } right; /* name or expression */ |
||
| 160 | |||
| 161 | } expression_t; |
||
| 2 | mjames | 162 | |
| 163 | /* place reference to a 'C' variable at the end of the tree branch */ |
||
| 11 | mjames | 164 | extern expression_t * compile_variable_reference(int *v,char * s ); |
| 2 | mjames | 165 | |
| 166 | /* compiles a variable. When printing expression stop descent of the evaluation tree here */ |
||
| 11 | mjames | 167 | extern expression_t * compile_variable(struct generic_info * gen , char * valname); |
| 2 | mjames | 168 | |
| 11 | mjames | 169 | extern expression_t * compile_string(char * s); |
| 2 | mjames | 170 | |
| 11 | mjames | 171 | extern expression_t * compile_char(char c); |
| 2 | mjames | 172 | |
| 173 | /* an unelaborated variable reference (link at evaluation time */ |
||
| 11 | mjames | 174 | extern expression_t * compile_reference(char * s); |
| 2 | mjames | 175 | |
| 176 | /* compiles an integer constant */ |
||
| 11 | mjames | 177 | extern expression_t * compile_constant(int k ); |
| 2 | mjames | 178 | |
| 11 | mjames | 179 | extern expression_t * compile_constant_string(int k,char * s ) ; |
| 2 | mjames | 180 | |
| 181 | /* compiles an boolean constant */ |
||
| 11 | mjames | 182 | extern expression_t * compile_bool_constant(int k ); |
| 2 | mjames | 183 | |
| 11 | mjames | 184 | extern expression_t * compile_bool_constant_string(int k,char * s ) ; |
| 2 | mjames | 185 | |
| 186 | |||
| 11 | mjames | 187 | extern expression_t * compile_expression(int opcode, |
| 188 | expression_t * left, |
||
| 189 | expression_t * right ); |
||
| 2 | mjames | 190 | |
| 11 | mjames | 191 | extern void print_expression(FILE * f,expression_t * e,generic_print_style recurse_generics ) ; |
| 2 | mjames | 192 | |
| 11 | mjames | 193 | extern void print_range_expression(FILE * f,expression_t * e,generic_print_style recurse_generics); |
| 2 | mjames | 194 | |
| 11 | mjames | 195 | extern void print_msg_expression(FILE * f,char * s,expression_t * e ); |
| 196 | |||
| 197 | |||
| 2 | mjames | 198 | /* this is actually returning the type of the generic */ |
| 11 | mjames | 199 | extern int eval_gen_expression( |
| 200 | struct generic_info * gen); |
||
| 2 | mjames | 201 | |
| 11 | mjames | 202 | extern int eval_vhdl_expression(expression_t * expr, |
| 203 | int * high, |
||
| 204 | int * low ); |
||
| 2 | mjames | 205 | |
| 206 | /*******************************************/ |
||
| 11 | mjames | 207 | struct socket;/* pulled in from database.h */ |
| 2 | mjames | 208 | struct vhdl; |
| 209 | /*******************************************/ |
||
| 11 | mjames | 210 | extern expression_t * copy_expression(expression_t * src,struct socket * skt); |
| 2 | mjames | 211 | |
| 212 | |||
| 11 | mjames | 213 | extern struct vhdl * copy_vhdl(struct vhdl * vhdl,struct socket * skt); |
| 2 | mjames | 214 | |
| 11 | mjames | 215 | extern void free_expression(expression_t * expr); |
| 2 | mjames | 216 | |
| 11 | mjames | 217 | extern int eval_expression(expression_t * e,struct generic_info ** generic_list); |
| 218 | |||
| 2 | mjames | 219 | #endif |