vrq
cblock.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 1997-2007, 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  * cblock.hpp
25  * - class definition of blocks
26  *
27  ******************************************************************************
28  */
29 
30 #ifndef CBLOCK_HPP
31 #define CBLOCK_HPP
32 
33 #include <vector>
34 #include "glue.h"
35 #include "cdecl.h"
36 #include "csymtab.h"
37 
38 
39 class CParam;
40 class CVar;
41 class CNode;
42 class CNet;
43 class CFref;
44 class CInstance;
45 class CGenvar;
46 class CPortDir;
47 
48 
52 class CBlock: public CDecl
53 {
54 protected:
55  vector<CParam*> paramList;
56  vector<CVar*> varList;
57  vector<CGenvar*> genvarList;
58  vector<CFref*> frefList;
59  vector<CNet*> netList;
60  vector<CInstance*> instanceList;
62  vector<CBlock*> children;
65 private:
66  CNode* codeList;
67  int rebalance;
68 public:
74  CBlock( CSymbol* name, Coord_t* aLoc );
81  CBlock( CSymbol* name, Coord_t* aLoc, Decl_t dtype );
85  virtual ~CBlock() {}
91  virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); }
100  virtual void Add( CInstance* instance );
109  virtual void Add( CParam* param );
118  virtual void Add( CNet* net );
127  virtual void Add( CVar* var );
136  virtual void Add( CBlock* child );
145  virtual void Add( CFref* fref );
154  virtual void Add( CGenvar* genvar );
159  virtual void Add( CNode* code );
164  void SetParent( CBlock* parent );
169  CBlock* GetParent( void );
174  void SetTrailingLabel( CSymbol* s ) { trailingLabel = s; }
184  virtual void Dump( FILE* f );
189  vector<CNet*>* GetNetList();
194  vector<CVar*>* GetVarList();
199  vector<CParam*>* GetParamList();
204  vector<CGenvar*>* GetGenvarList();
209  virtual vector<CInstance*>* GetInstanceList();
214  virtual CNode* GetCodeList();
219  virtual void SetCodeList( CNode* list );
224  vector<CBlock*>* GetChildList();
229  virtual vector<CPortDir*>* GetPortDirList()
230  { static vector<CPortDir*> nullList; return &nullList;}
235  virtual void SetSymtab( CSymtab<CDecl>& symtab );
240  virtual CSymtab<CDecl>& GetSymtab() { return symtab; }
245  void PreVisit1( int (*func)(CNode*,void*), void* data );
246  void PostVisit1( void (*func)(CNode*, void*), void* data );
247  void PostSubVisit1( CNode* (*func)(CNode*, void*), void* data );
248 protected:
249  static void Reconnect( CNode *n );
250  void RedeclarePorts();
251  void LinkFrefs( CSymtab<CDecl>& portSymtab,
252  CSymtab<CDecl>& moduleSymtab,
253  vector<CFref*>& frefList,
254  int inferVectors );
255  virtual void CodeListChanged() {}
256 private:
257  void LinkPortFref( CSymtab<CDecl>* symtab1,
258  CSymtab<CDecl>* symtab2,
259  CFref* fref );
260  void InferFref( CSymtab<CDecl>* symtab1,
261  CFref* fref,
262  int inferVector );
263  void LinkFref( CSymtab<CDecl>* symtab,
264  CFref* fref, int inferVector );
265  CBlock( const CBlock& );
269 };
270 
274 typedef CBlock CScope;
275 
276 
277 #endif // CBLOCK_HPP
Declaration object for nets.
Definition: cnet.h:46
virtual void Add(CInstance *instance)
vector< CParam * > paramList
Definition: cblock.h:55
Declaration object for genvars.
Definition: cgenvar.h:46
virtual ~CBlock()
Object destructor.
Definition: cblock.h:85
Decl_t
Declaration types.
Definition: cdecl.h:74
virtual void Dump(FILE *f)
Dump information about block to a file.
virtual void PreVisit1(int(*func)(CNode *, void *), void *data)
virtual CNode * GetCodeList()
Get blocks parse tree.
void SetParent(CBlock *parent)
Set this block&#39;s parent block.
CSymbol * trailingLabel
Definition: cblock.h:64
CBlock CScope
Alias for CBlock.
Definition: cblock.h:273
vector< CFref * > frefList
Definition: cblock.h:58
vector< CNet * > * GetNetList()
Get list of object&#39;s nets.
int inferVectors
Definition: main.cc:296
CSymbol * GetTrailingLabel(void)
Get this block&#39;s end label.
Definition: cblock.h:179
vector< CNet * > netList
Definition: cblock.h:59
Structure to hold file coordinates.
Definition: cdecl.h:47
Holder for character strings.
Definition: csymbol.h:44
virtual CDecl * Clone(CObstack *heap)
Create a clone of this declaration.
Definition: cblock.h:91
Forward reference declaration.
Definition: cfref.h:51
Bulk object allocation object.
Definition: cobstack.h:46
Primary data structure representing parse tree nodes.
Definition: cnode.h:197
vector< CVar * > * GetVarList()
Get list of object&#39;s registers.
virtual vector< CPortDir * > * GetPortDirList()
Get list of block&#39;s port declarations.
Definition: cblock.h:229
CSymtab< CDecl > portSymtab
Definition: main.cc:289
Declaration object for module and gate instances.
Definition: cinstance.h:45
virtual void PostSubVisit1(CNode *(*func)(CNode *, void *), void *data)
void SetTrailingLabel(CSymbol *s)
Set this block&#39;s end label.
Definition: cblock.h:174
virtual void SetCodeList(CNode *list)
Set block&#39;s parse tree.
vector< CBlock * > children
Definition: cblock.h:62
vector< CGenvar * > * GetGenvarList()
Get list of object&#39;s genvars.
virtual void SetSymtab(CSymtab< CDecl > &symtab)
Set block&#39;s symbol table.
Base class for describing declaration objects.
Definition: cdecl.h:164
virtual CSymtab< CDecl > & GetSymtab()
Get block&#39;s symbol table.
Definition: cblock.h:240
Declaration object for variables.
Definition: cvar.h:50
Declaration object for parameters.
Definition: cparam.h:46
CBlock * parent
Definition: cblock.h:61
virtual void PostVisit1(void(*func)(CNode *, void *), void *data)
vector< CVar * > varList
Definition: cblock.h:56
vector< CParam * > * GetParamList()
Get list of object&#39;s parameters.
Declaration object for input/output/inout statements.
Definition: cportdir.h:45
virtual vector< CInstance * > * GetInstanceList()
Get list if module instances.
CSymtab< CDecl > symtab
Definition: cblock.h:63
vector< CGenvar * > genvarList
Definition: cblock.h:57
Declaration class for block constructs.
Definition: cblock.h:52
CBlock(CSymbol *name, Coord_t *aLoc)
Constructor for BLOCK declarations.
vector< CInstance * > instanceList
list of module instances.
Definition: cblock.h:60
vector< CBlock * > * GetChildList()
Get list of block&#39;s child blocks.
CBlock * GetParent(void)
Get this block&#39;s parent block.