Subversion Repositories Vertical

Rev

Rev 9 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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 mjames Exp $
  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
  46.  *
  47.  * Revision 1.19  2000/10/04  10:37:15  10:37:15  mjames (Mike James)
  48.  * Part of Release PSAVAT01
  49.  *
  50.  * Revision 1.18  2000/10/02  11:04:12  11:04:12  mjames (Mike James)
  51.  * new_vhdl
  52.  *
  53.  * Revision 1.17  2000/09/27  14:42:30  14:42:30  mjames (Mike James)
  54.  * Part of Release Sep_27_ST_2000
  55.  *
  56.  * Revision 1.16  2000/09/21  10:16:00  10:16:00  mjames (Mike James)
  57.  * Part of Release Sep21Alpha
  58.  *
  59.  * Revision 1.15  2000/08/25  09:57:23  09:57:23  mjames (Mike James)
  60.  * Part of Release Aug25_alpha
  61.  *
  62.  * Revision 1.14  2000/08/16  08:57:40  08:57:40  mjames (Mike James)
  63.  * Part of Release CD01_Aug2000
  64.  *
  65.  * Revision 1.13  2000/08/14  14:45:19  14:45:19  mjames (Mike James)
  66.  * Part of Release Aug_14_2000
  67.  *
  68.  * Revision 1.12  2000/08/11  08:30:40  08:30:40  mjames (Mike James)
  69.  * Part of Release Aug_11_2000
  70.  *
  71.  * Revision 1.11  2000/08/09  10:31:57  10:31:57  mjames (Mike James)
  72.  * Part of Release Aug__9_2000
  73.  *
  74.  * Revision 1.10  2000/05/31  11:43:11  11:43:11  mjames (Mike James)
  75.  * Part of Release May_31_2000
  76.  *
  77.  * Revision 1.9  2000/05/08  17:01:46  17:01:46  mjames (Mike James)
  78.  * Part of Release May__8_2000
  79.  *
  80.  * Revision 1.8  2000/05/08  16:59:40  16:59:40  mjames (Mike James)
  81.  * Part of Release May__8_2000
  82.  *
  83.  * Revision 1.7  2000/05/08  16:57:16  16:57:16  mjames (Mike James)
  84.  * Part of Release May__8_2000
  85.  *
  86.  * Revision 1.6  2000/03/08  16:18:57  16:18:57  mjames (Mike James)
  87.  * New version including PC
  88.  *
  89.  * Revision 1.3  2000/01/20  15:58:58  15:58:58  mjames (Mike James)
  90.  * Part of Release R22
  91.  *
  92.  * Revision 1.2  99/12/22  11:15:39  11:15:39  mjames (Mike James)
  93.  * Part of Release Dec_22_1999
  94.  *
  95.  * Revision 1.1  99/06/25  14:36:23  14:36:23  mjames (Mike James)
  96.  * Initial revision
  97.  *
  98.  *  */
  99. #if !defined _EXPRESSION
  100. #define _EXPRESSION
  101.  
  102.  
  103. /* constants for object types found at bottom of expressions */
  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'
  111.  
  112.  
  113.  
  114. /* decoding  recurse_generics
  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
  118.  
  119.  constant a : integer := 3;
  120.  constant b : integer := a + 3;
  121.  constant c : integer := b + a;
  122.  
  123.  for values of expand generics :
  124.  value 0:
  125.  constant a : integer := 3;
  126.  constant b : integer := a + 3;
  127.  constant c : integer := b + a;
  128.  
  129.  value 1:
  130.  constant a : integer := 3;
  131.  constant b : integer := a + 3;
  132.  constant c : integer := (a+3) + a;
  133.  
  134.  value 2:
  135.  constant a : integer := 3;
  136.  constant b : integer := (3) + 3;
  137.  constant c : integer := ((3)+3) + (3);
  138.  
  139.  
  140.   */
  141.  
  142. typedef enum { NO_RECURSE=0,RECURSE_CONST,RECURSE_NUMBER } generic_print_style;
  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 */
  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;
  162.  
  163. /* place reference to a 'C' variable at the end of the tree branch */
  164. extern expression_t * compile_variable_reference(int *v,char * s );
  165.  
  166. /* compiles a variable. When printing expression stop descent of the evaluation tree here */
  167. extern expression_t * compile_variable(struct generic_info * gen , char * valname);
  168.  
  169. extern expression_t * compile_string(char * s);
  170.  
  171. extern expression_t * compile_char(char c);
  172.  
  173. /* an unelaborated variable reference (link at evaluation time */
  174. extern expression_t * compile_reference(char * s);
  175.  
  176. /* compiles an integer constant */
  177. extern expression_t * compile_constant(int k );  
  178.  
  179. extern expression_t * compile_constant_string(int k,char * s ) ;
  180.  
  181. /* compiles an boolean constant */
  182. extern expression_t * compile_bool_constant(int k );  
  183.  
  184. extern expression_t * compile_bool_constant_string(int k,char * s ) ;
  185.  
  186.  
  187. extern expression_t * compile_expression(int opcode,
  188.        expression_t * left,
  189.        expression_t * right );  
  190.  
  191. extern void print_expression(FILE * f,expression_t * e,generic_print_style recurse_generics ) ;
  192.  
  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 );
  196.  
  197.  
  198. /* this is actually returning the type of the generic */
  199. extern int eval_gen_expression(
  200.        struct generic_info * gen);
  201.  
  202. extern int eval_vhdl_expression(expression_t * expr,
  203.                          int * high,
  204.                          int * low );
  205.  
  206. /*******************************************/
  207. struct socket;/* pulled in from database.h */
  208. struct vhdl;
  209. /*******************************************/
  210. extern expression_t * copy_expression(expression_t * src,struct socket  * skt);
  211.  
  212.  
  213. extern struct vhdl * copy_vhdl(struct vhdl * vhdl,struct socket * skt);
  214.  
  215. extern void free_expression(expression_t * expr);
  216.  
  217. extern int eval_expression(expression_t * e,struct generic_info ** generic_list);
  218.  
  219. #endif
  220.