vrq
/usr/src/RPM/BUILD/vrq-1.0.96/src/cblock.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 1997-2007, Mark Hummel
00003  * This file is part of Vrq.
00004  *
00005  * Vrq is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * Vrq is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00018  * Boston, MA  02110-1301  USA
00019  *****************************************************************************
00020  */
00021 /******************************************************************************
00022  *
00023  *
00024  *         cblock.hpp
00025  *              - class definition of blocks 
00026  *
00027  ******************************************************************************
00028  */
00029 
00030 #ifndef CBLOCK_HPP
00031 #define CBLOCK_HPP
00032 
00033 #include <vector>
00034 #include "glue.h"
00035 #include "cdecl.h"
00036 #include "csymtab.h"
00037 
00038 
00039 class CParam;
00040 class CVar;
00041 class CNode;
00042 class CNet;
00043 class CFref;
00044 class CInstance;
00045 class CGenvar;
00046 class CPortDir;
00047 
00048 
00052 class CBlock: public CDecl
00053 {
00054 protected:
00055         vector<CParam*>   paramList;
00056         vector<CVar*>     varList;
00057         vector<CGenvar*>  genvarList;
00058         vector<CFref*>    frefList;
00059         vector<CNet*>     netList;
00060         CBlock*           parent;
00061         vector<CBlock*>   children;
00062         CSymtab<CDecl>    symtab; 
00063 private:
00064         CNode*            codeList;
00065         int               rebalance;
00066 public:
00072         CBlock( CSymbol* name, Coord_t* aLoc );
00079         CBlock( CSymbol* name, Coord_t* aLoc, Decl_t dtype );
00083         virtual ~CBlock() {}
00089         virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); }
00098         virtual void Add( CInstance* instance );
00107         virtual void Add( CParam* param );
00116         virtual void Add( CNet* net );
00125         virtual void Add( CVar* var );
00134         virtual void Add( CBlock* child );
00143         virtual void Add( CFref* fref );
00152         virtual void Add( CGenvar* genvar );
00157         virtual void Add( CNode* code  );
00162         void    SetParent( CBlock* parent );
00167         CBlock* GetParent( void );
00172         virtual void Dump( FILE* f );
00177         vector<CNet*>*  GetNetList();
00182         vector<CVar*>*  GetVarList();
00187         vector<CParam*>* GetParamList();
00192         vector<CGenvar*>* GetGenvarList();
00197         virtual CNode*  GetCodeList();
00202         virtual void    SetCodeList( CNode* list );
00207         vector<CBlock*>* GetChildList();
00212         virtual vector<CPortDir*>*  GetPortDirList() 
00213                 { static vector<CPortDir*> nullList; return &nullList;}
00218         virtual void    SetSymtab( CSymtab<CDecl>& symtab );
00223         virtual CSymtab<CDecl>& GetSymtab() { return symtab; }
00228         void    PreVisit1( int (*func)(CNode*,void*), void* data );
00229         void    PostVisit1( void (*func)(CNode*, void*), void* data );
00230         void    PostSubVisit1( CNode* (*func)(CNode*, void*), void* data );
00231 protected:
00232         static void Reconnect( CNode *n );
00233         void RedeclarePorts();
00234         void LinkFrefs( CSymtab<CDecl>& portSymtab,
00235                         CSymtab<CDecl>& moduleSymtab,
00236                         vector<CFref*>& frefList, 
00237                         int inferVectors );
00238         virtual void CodeListChanged() {}
00239 private:
00240         void LinkPortFref( CSymtab<CDecl>* symtab1,
00241                        CSymtab<CDecl>* symtab2,
00242                        CFref* fref  );
00243         void InferFref( CSymtab<CDecl>* symtab1,
00244                        CFref* fref,
00245                        int inferVector );
00246         void LinkFref( CSymtab<CDecl>* symtab,
00247                        CFref* fref, int inferVector );
00248         CBlock( const CBlock& );
00252 };
00253 
00257 typedef CBlock CScope;
00258 
00259 
00260 #endif // CBLOCK_HPP