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,
63 };
64 #if defined CDATATYPE_CC
65 
68 const char* varDataTypeName[] = {
69  "",
70  "real",
71  "shortreal",
72  "realtime",
73  "reg",
74  "time",
75  "logic",
76  "integer",
77  "bit",
78  "int",
79  "byte",
80  "shortint",
81  "longint",
82  "event",
83  "struct",
84  "union",
85  "union tagged",
86  "enum",
87  "class",
88  "proxy",
89 };
90 #else // CDATATYPE_CC
91 extern const char* varDataTypeName[];
92 #endif // CDATATYPE_CC
93 
97 enum NodeType_t {
98  eU,
99  eR,
100  eS,
101  eE,
102  eB
103 };
104 
108 class CDataType : public CObject
109 {
110 public:
111 private:
112  int const_;
113  VarDataType_t varDataType;
114  int numberOfPackedDimensions;
115  vector<CNode*> packedRange;
116 public:
124  CDataType( VarDataType_t t, list<CNode*> packedList );
129  virtual CDataType* Clone( CObstack* heap ) = 0;
134  virtual void SetVarDataType( VarDataType_t v ) { varDataType = v; }
139  virtual VarDataType_t GetVarDataType() const { return varDataType; }
145  virtual void SetConst( int v ) { const_ = v; }
150  virtual int GetConst() const { return const_; }
155  virtual int GetTwoState() const = 0;
160  virtual int GetSigned() const = 0;
165  virtual NodeType_t GetNodeType( void ) const = 0;
173  virtual int IsBaseWidthConstant( void ) const = 0;
181  virtual int IsBaseWidthVolatile( void ) const = 0;
188  virtual int IsBaseWidthEvaluateable( void ) const = 0;
193  virtual INT32 GetBaseWidth( void ) const = 0;
198  virtual CNode* GetBaseWidthExp() const = 0;
204  virtual int IsScalar() const;
210  virtual int IsVector() const = 0;
216  virtual int IsPacked() const = 0;
223  virtual int IsPackedWidthConstant( void ) const;
230  virtual int IsPackedWidthVolatile( void ) const;
236  virtual int IsPackedWidthEvaluateable( void ) const;
242  virtual CNode* GetPackedMsb() const;
248  virtual CNode* GetPackedLsb() const;
254  virtual CNode* GetPackedRange() const;
259  virtual INT32 GetPackedWidth( void ) const;
264  virtual CNode* GetPackedWidthExp() const;
269  virtual int PackedWidthDirection( void ) const;
274  virtual INT32 GetNumberOfPackedDimensions( void ) const
275  { return numberOfPackedDimensions;}
281  virtual CNode* GetPackedMsi( INT32 dim ) const;
287  virtual CNode* GetPackedLsi( INT32 dim ) const;
293  virtual CNode* GetPackedRange( INT32 dim ) const
294  { return packedRange[dim]; }
295 
296 
301  virtual void Dump( FILE* f ) const = 0;
309  virtual void PreVisit1( int (*callback)(CNode*,void*), void* data );
316  virtual void PostVisit1( void (*callback)(CNode*,void*), void* data );
325  virtual void PostSubVisit1( CNode* (*callback)(CNode*, void*), void* data );
326 protected:
333  void Copy( CObstack* heap, const CDataType& o );
334 private:
335  /*
336  * disable copy constructors
337  */
338  CDataType( const CDataType& o );
339 
340 };
341 
342 #endif // CDATATYPE_H
343 
virtual void SetVarDataType(VarDataType_t v)
Set declaration's variable data type.
Definition: cdatatype.h:134
int declaration
Definition: cdatatype.h:52
virtual void SetConst(int v)
Set declaration's const property.
Definition: cdatatype.h:145
undefined
Definition: cdatatype.h:98
virtual int IsScalar() const
Determine if complete data structure is a scalar.
signed bit vector, includes integer
Definition: cdatatype.h:100
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:139
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:150
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:108
byte declaration
Definition: cdatatype.h:53
real declaration
Definition: cdatatype.h:44
unsigned bit vector
Definition: cdatatype.h:102
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:188
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:274
event - have width 0
Definition: cdatatype.h:101
Base class for vrq objects.
Definition: cobject.h:41
const char * varDataTypeName[]
Array to convert DataType_t to character string.
Definition: cdatatype.h:68
virtual CNode * GetPackedRange(INT32 dim) const
Get expression for range of packed array for dimension.
Definition: cdatatype.h:293
real - have width 0
Definition: cdatatype.h:99
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:97
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
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...