Subversion Repositories Vertical

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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