vrq
cdatatype.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 1997-2010, Mark Hummel
3  * This file is part of Vrq.
4  *
5  * Vrq is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * Vrq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301 USA
19  *****************************************************************************
20  */
21 /******************************************************************************
22  *
23  *
24  * cdatatype.h
25  * - abstract class for data types
26  *
27  *
28  ******************************************************************************
29  */
30 
31 #ifndef CDATATYPE_H
32 #define CDATATYPE_H
33 
34 #include <list>
35 #include "cobject.h"
36 
37 class CNode;
38 
47  eREG,
51  eBIT,
52  eINT,
64 };
65 #if defined CDATATYPE_CC
66 
69 const char* varDataTypeName[] = {
70  "",
71  "real",
72  "shortreal",
73  "realtime",
74  "reg",
75  "time",
76  "logic",
77  "integer",
78  "bit",
79  "int",
80  "byte",
81  "shortint",
82  "longint",
83  "event",
84  "struct",
85  "union",
86  "union tagged",
87  "enum",
88  "class",
89  "proxy",
90  "interface type",
91 };
92 #else // CDATATYPE_CC
93 extern const char* varDataTypeName[];
94 #endif // CDATATYPE_CC
95 
99 enum NodeType_t {
100  eU,
101  eR,
102  eS,
103  eE,
104  eB
105 };
106 
110 class CDataType : public CObject
111 {
112 public:
113 private:
114  int const_;
115  VarDataType_t varDataType;
116  int numberOfPackedDimensions;
117  vector<CNode*> packedRange;
118 public:
126  CDataType( VarDataType_t t, list<CNode*> packedList );
131  virtual CDataType* Clone( CObstack* heap ) = 0;
136  virtual void SetVarDataType( VarDataType_t v ) { varDataType = v; }
141  virtual VarDataType_t GetVarDataType() const { return varDataType; }
146  virtual const char* GetVarDataTypeName() const { return varDataTypeName[varDataType]; }
152  virtual void SetConst( int v ) { const_ = v; }
157  virtual int GetConst() const { return const_; }
162  virtual int GetTwoState() const = 0;
167  virtual int GetSigned() const = 0;
172  virtual NodeType_t GetNodeType( void ) const = 0;
180  virtual int IsBaseWidthConstant( void ) const = 0;
188  virtual int IsBaseWidthVolatile( void ) const = 0;
195  virtual int IsBaseWidthEvaluateable( void ) const = 0;
200  virtual INT32 GetBaseWidth( void ) const = 0;
205  virtual CNode* GetBaseWidthExp() const = 0;
211  virtual int IsScalar() const;
217  virtual int IsVector() const = 0;
223  virtual int IsPacked() const = 0;
230  virtual int IsPackedWidthConstant( void ) const;
237  virtual int IsPackedWidthVolatile( void ) const;
243  virtual int IsPackedWidthEvaluateable( void ) const;
249  virtual CNode* GetPackedMsb() const;
255  virtual CNode* GetPackedLsb() const;
261  virtual CNode* GetPackedRange() const;
266  virtual INT32 GetPackedWidth( void ) const;
271  virtual CNode* GetPackedWidthExp() const;
276  virtual int PackedWidthDirection( void ) const;
281  virtual INT32 GetNumberOfPackedDimensions( void ) const
282  { return numberOfPackedDimensions;}
288  virtual CNode* GetPackedMsi( INT32 dim ) const;
294  virtual CNode* GetPackedLsi( INT32 dim ) const;
300  virtual CNode* GetPackedRange( INT32 dim ) const
301  { return packedRange[dim]; }
302 
303 
308  virtual void Dump( FILE* f ) const = 0;
316  virtual void PreVisit1( int (*callback)(CNode*,void*), void* data );
323  virtual void PostVisit1( void (*callback)(CNode*,void*), void* data );
332  virtual void PostSubVisit1( CNode* (*callback)(CNode*, void*), void* data );
333 protected:
340  void Copy( CObstack* heap, const CDataType& o );
341 private:
342  /*
343  * disable copy constructors
344  */
345  CDataType( const CDataType& o );
346 
347 };
348 
349 #endif // CDATATYPE_H
350 
virtual void SetVarDataType(VarDataType_t v)
Set declaration's variable data type.
Definition: cdatatype.h:136
int declaration
Definition: cdatatype.h:52
virtual void SetConst(int v)
Set declaration's const property.
Definition: cdatatype.h:152
undefined
Definition: cdatatype.h:100
virtual int IsScalar() const
Determine if complete data structure is a scalar.
signed bit vector, includes integer
Definition: cdatatype.h:102
shortreal declaration
Definition: cdatatype.h:45
virtual int IsPackedWidthEvaluateable(void) const
Determine if packed or vector width of declaration can be evaluated.
virtual int PackedWidthDirection(void) const
Evaluate current decl width direction.
tagged union declaration
Definition: cdatatype.h:59
longint declaration
Definition: cdatatype.h:55
virtual INT32 GetBaseWidth(void) const =0
Evaluate base width (sans packed dimensions) of declaration.
realtime declaration
Definition: cdatatype.h:46
virtual CNode * GetPackedMsb() const
Get expression for declaration's msb.
virtual VarDataType_t GetVarDataType() const
Get declaration's variable data type.
Definition: cdatatype.h:141
proxy declaration
Definition: cdatatype.h:62
long INT32
Short cut for signed 32 bit integer.
Definition: glue.h:38
virtual NodeType_t GetNodeType(void) const =0
Get data type.
register declaration
Definition: cdatatype.h:47
virtual int GetConst() const
Get declaration's const property.
Definition: cdatatype.h:157
virtual CNode * GetBaseWidthExp() const =0
Get expression for datatype's base width (sans packed dimensions)
virtual CDataType * Clone(CObstack *heap)=0
Create a new copy with a deep copy.
virtual CNode * GetPackedLsi(INT32 dim) const
Get expression tree for lower limit of packed array dimension.
virtual void Dump(FILE *f) const =0
Dump data type info to file descriptor.
Base class for describing data types.
Definition: cdatatype.h:110
byte declaration
Definition: cdatatype.h:53
real declaration
Definition: cdatatype.h:44
unsigned bit vector
Definition: cdatatype.h:104
virtual int IsPacked() const =0
Determine if complete data structure is packed.
virtual CNode * GetPackedRange() const
Get expression for datatype's overall packed or vector range (msb/lsb)
virtual CNode * GetPackedLsb() const
Get expression for declaration's lsb.
Bulk object allocation object.
Definition: cobstack.h:46
Primary data structure representing parse tree nodes.
Definition: cnode.h:197
CDataType(VarDataType_t t)
Create data type instance.
integer declaration
Definition: cdatatype.h:50
virtual int GetTwoState() const =0
Get declaration's 2 state property.
virtual INT32 GetPackedWidth(void) const
Evaluate packed or vector width of declaration.
integer declaration
Definition: cdatatype.h:51
virtual int IsBaseWidthConstant(void) const =0
Determine if base width (sans packed dimensions) of declaration is constant, ie dependent upon only c...
virtual int IsBaseWidthEvaluateable(void) const =0
Determine if base width (sans packed dimensions) of declaration can be evaluated. ...
virtual int IsPackedWidthConstant(void) const
Determine if packed or vector width of declaration is constant, ie dependent upon only constants and ...
virtual int IsVector() const =0
Determine if complete data structure is a vector.
virtual int IsPackedWidthVolatile(void) const
Determine if packed or vector width of declaration is volatile, ie depend upon parameters or variable...
virtual void PreVisit1(int(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node before children have been visited.
class declaration
Definition: cdatatype.h:61
shortint declaration
Definition: cdatatype.h:54
virtual INT32 GetNumberOfPackedDimensions(void) const
Get number of packed dimensions of declaration.
Definition: cdatatype.h:281
event - have width 0
Definition: cdatatype.h:103
Base class for vrq objects.
Definition: cobject.h:41
const char * varDataTypeName[]
Array to convert DataType_t to character string.
Definition: cdatatype.h:69
virtual CNode * GetPackedRange(INT32 dim) const
Get expression for range of packed array for dimension.
Definition: cdatatype.h:300
interface declaration
Definition: cdatatype.h:63
real - have width 0
Definition: cdatatype.h:101
virtual CNode * GetPackedMsi(INT32 dim) const
Get expression tree for upper limit of given packed array dimension.
virtual int IsBaseWidthVolatile(void) const =0
Determine if base width (sans packed dimensions) of declaration is volatile, ie depend upon parameter...
struct declaration
Definition: cdatatype.h:57
no type declaration
Definition: cdatatype.h:43
event declaration
Definition: cdatatype.h:56
VarDataType_t
Variable data types.
Definition: cdatatype.h:42
NodeType_t
Expression node type.
Definition: cdatatype.h:99
time declaration
Definition: cdatatype.h:48
virtual void PostSubVisit1(CNode *(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node after children have been visited.
virtual CNode * GetPackedWidthExp() const
Get expression for datatype's overall packed or vector width.
virtual void PostVisit1(void(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node after children have been visited.
enum declaration
Definition: cdatatype.h:60
virtual const char * GetVarDataTypeName() const
Get declaration's variable data type as a string.
Definition: cdatatype.h:146
logic declaration
Definition: cdatatype.h:49
union declaration
Definition: cdatatype.h:58
virtual int GetSigned() const =0
Get declartion's signed property.
void Copy(CObstack *heap, const CDataType &o)
Perform deep copy of given object to this one This should never be call directly, only by subclasses...