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