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;
61  vector<CBlock*> children;
64 private:
65  CNode* codeList;
66  int rebalance;
67 public:
73  CBlock( CSymbol* name, Coord_t* aLoc );
80  CBlock( CSymbol* name, Coord_t* aLoc, Decl_t dtype );
84  virtual ~CBlock() {}
90  virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); }
99  virtual void Add( CInstance* instance );
108  virtual void Add( CParam* param );
117  virtual void Add( CNet* net );
126  virtual void Add( CVar* var );
135  virtual void Add( CBlock* child );
144  virtual void Add( CFref* fref );
153  virtual void Add( CGenvar* genvar );
158  virtual void Add( CNode* code );
163  void SetParent( CBlock* parent );
168  CBlock* GetParent( void );
183  virtual void Dump( FILE* f );
188  vector<CNet*>* GetNetList();
193  vector<CVar*>* GetVarList();
198  vector<CParam*>* GetParamList();
203  vector<CGenvar*>* GetGenvarList();
208  virtual CNode* GetCodeList();
213  virtual void SetCodeList( CNode* list );
218  vector<CBlock*>* GetChildList();
223  virtual vector<CPortDir*>* GetPortDirList()
224  { static vector<CPortDir*> nullList; return &nullList;}
229  virtual void SetSymtab( CSymtab<CDecl>& symtab );
234  virtual CSymtab<CDecl>& GetSymtab() { return symtab; }
239  void PreVisit1( int (*func)(CNode*,void*), void* data );
240  void PostVisit1( void (*func)(CNode*, void*), void* data );
241  void PostSubVisit1( CNode* (*func)(CNode*, void*), void* data );
242 protected:
243  static void Reconnect( CNode *n );
244  void RedeclarePorts();
245  void LinkFrefs( CSymtab<CDecl>& portSymtab,
246  CSymtab<CDecl>& moduleSymtab,
247  vector<CFref*>& frefList,
248  int inferVectors );
249  virtual void CodeListChanged() {}
250 private:
251  void LinkPortFref( CSymtab<CDecl>* symtab1,
252  CSymtab<CDecl>* symtab2,
253  CFref* fref );
254  void InferFref( CSymtab<CDecl>* symtab1,
255  CFref* fref,
256  int inferVector );
257  void LinkFref( CSymtab<CDecl>* symtab,
258  CFref* fref, int inferVector );
259  CBlock( const CBlock& );
263 };
264 
268 typedef CBlock CScope;
269 
270 
271 #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:84
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's parent block.
CSymbol * trailingLabel
Definition: cblock.h:63
CBlock CScope
Alias for CBlock.
Definition: cblock.h:268
vector< CFref * > frefList
Definition: cblock.h:58
vector< CNet * > * GetNetList()
Get list of object's nets.
int inferVectors
Definition: main.cc:292
CSymbol * GetTrailingLabel(void)
Get this block's end label.
Definition: cblock.h:178
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:90
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:188
vector< CVar * > * GetVarList()
Get list of object's registers.
virtual vector< CPortDir * > * GetPortDirList()
Get list of block's port declarations.
Definition: cblock.h:223
CSymtab< CDecl > portSymtab
Definition: main.cc:285
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's end label.
Definition: cblock.h:173
virtual void SetCodeList(CNode *list)
Set block's parse tree.
vector< CBlock * > children
Definition: cblock.h:61
vector< CGenvar * > * GetGenvarList()
Get list of object's genvars.
virtual void SetSymtab(CSymtab< CDecl > &symtab)
Set block's symbol table.
Base class for describing declaration objects.
Definition: cdecl.h:164
virtual CSymtab< CDecl > & GetSymtab()
Get block's symbol table.
Definition: cblock.h:234
Declaration object for variables.
Definition: cvar.h:50
Declaration object for parameters.
Definition: cparam.h:46
CBlock * parent
Definition: cblock.h:60
virtual void PostVisit1(void(*func)(CNode *, void *), void *data)
vector< CVar * > varList
Definition: cblock.h:56
vector< CParam * > * GetParamList()
Get list of object's parameters.
Declaration object for input/output/inout statements.
Definition: cportdir.h:45
CSymtab< CDecl > symtab
Definition: cblock.h:62
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< CBlock * > * GetChildList()
Get list of block's child blocks.
CBlock * GetParent(void)
Get this block's parent block.