Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

const.h

Go to the documentation of this file.
00001 
00002 #ifndef CONST_H
00003 #define CONST_H
00004 
00005 
00006 /*===============================<o>=====================================
00007 
00008 Copyright 1996, 1997, 2004 Ian Kaplan, Bear Products International,
00009 www.bearcave.com.
00010 
00011 All Rights Reserved
00012 
00013 You may use this software in software components for which you do
00014 not collect money (e.g., non-commercial software).  All commercial
00015 use is reserved.
00016 
00017 ===============================<o>=====================================*/
00018 
00019 
00020 #include <assert.h>
00021 
00022 #include "type.h"
00023 
00024 
00025 #ifndef NULL
00026 #define NULL 0
00027 #endif
00028 
00030 enum { bad_constant,
00031        cn_sign,          // a signed scalar constant
00032        cn_unsign,        // an unsigned scalar constant
00033        cn_real,          // a real constant
00034        cn_aggregate      // an "aggragate" constant for either
00035                          // an array or a record. 
00036      };
00037 
00038 
00105 class vhdl_const {
00106 public:
00107     vhdl_const(void) { }
00108 
00110   void *operator new( unsigned int num_bytes )
00111   {
00112     assert( FALSE );
00113     return NULL;
00114   }
00115 
00119   void *operator new( unsigned int num_bytes, pool *mem_pool )
00120   {
00121     return mem_pool->GetMem( num_bytes );
00122   }
00123 
00125   virtual const uint get_cn_kind( void ) { return bad_constant; }
00126 
00127     // virtual functions specific to a class
00131     virtual void set_val( int i )
00132     {
00133         assert( FALSE );
00134     }
00135     virtual const int get_val(void)
00136     {
00137         assert( FALSE );
00138         return 0;
00139     }
00142     virtual void set_uval( uint u )
00143     {
00144         assert( FALSE );
00145     }
00146     virtual const uint get_uval(void)
00147     {
00148         assert( FALSE );
00149         return 0;
00150     }
00153     virtual void set_real( float f )
00154     {
00155         assert( FALSE );
00156     }
00157     virtual const float get_real(void)
00158     {
00159         assert( FALSE );
00160         return (float)0.0;
00161     }
00162     //
00163     //
00164     //
00165     virtual void set_agg_ty( pType ty ) 
00166     {
00167         assert( FALSE );
00168     }    
00169     virtual const pType get_agg_ty(void)
00170     {
00171         return NULL;
00172     }
00173     //
00174     // const_agg 
00175     //
00176     virtual void set_tree( NODE *tree ) 
00177     {
00178         assert( FALSE );
00179     }
00180     virtual const NODE *get_tree(void)
00181     {
00182         return NULL;
00183     }
00184 };  // vhdl_const
00185 
00186 
00187 
00188 
00191 class const_range_signed : public vhdl_const {
00192 private:
00193     int val;
00194 public:
00195     const_range_signed(void) { val = 0; }
00196     const_range_signed(int i) { val = i; }
00197     void set_val( int i )
00198     {
00199         val = i;
00200     }
00201     const int get_val(void)
00202     {
00203         return val;
00204     }
00205 
00206     const uint get_cn_kind( void ) { return cn_sign; }
00207 }; // const_range_signed
00208 
00209 
00210 
00211 /*
00212  * const_range_unsigned
00213  *
00214  */
00215 class const_range_unsigned : public vhdl_const {
00216 private:
00217     uint val;
00218 public:
00219     const_range_unsigned() { val = 0; }
00220     const_range_unsigned( uint u ) { val = u; }
00221     void set_uval( uint u )
00222     {
00223         val = u;
00224     }
00225     const uint get_uval(void)
00226     {
00227         return val;
00228     }
00229     const uint get_cn_kind( void ) { return cn_unsign; }
00230 }; // const_range_unsigned
00231 
00232 
00235 class const_real : public vhdl_const {
00236 private:
00237     float real_val;
00238 
00239 public:
00240     const_real(void) { real_val = 0.0; }
00241     void set_real( float f )
00242     {
00243         real_val = f;
00244     }
00245     const float get_real(void)
00246     {
00247         return real_val;
00248     }
00249     const uint get_cn_kind( void ) { return cn_real; }
00250 }; // const_real
00251 
00252 
00253 
00264 class const_agg : public vhdl_const {
00265 private:
00266     pType ty_aggragate;
00267     NODE *agg_tree;
00268 public:
00269     const_agg(void) 
00270     { 
00271         ty_aggragate = NULL;
00272         agg_tree = NULL;
00273     }
00274     
00275     void set_agg_ty( pType ty ) 
00276     {
00277         ty_aggragate = ty;
00278     }    
00279     const pType get_agg_ty(void)
00280     {
00281         return ty_aggragate;
00282     }
00283 
00284     void set_tree( NODE *tree ) 
00285     {
00286         assert( tree != NULL );
00287         agg_tree = tree;
00288     }
00289     const NODE *get_tree(void)
00290     {
00291         return agg_tree;
00292     }
00293     const uint get_cn_kind( void ) { return cn_aggregate; }
00294 }; // const_agg
00295 
00296 
00297 #endif

Generated on Wed Mar 31 21:15:55 2004 for Data Structures for a VHDL Compiler by doxygen 1.3.3