vrq
/usr/src/RPM/BUILD/vrq-1.0.96/src/cfunction.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  *         cfunction.hpp
00025  *              - class definition of function
00026  *                definition nodes
00027  *
00028  ******************************************************************************
00029  */
00030 
00031 #ifndef CFUNCTION_HPP
00032 #define CFUNCTION_HPP
00033 
00034 #include <stdio.h>
00035 #include <vector> 
00036 #include <list> 
00037 #include "glue.h"
00038 #include "cdecl.h"
00039 #include "csymtab.h"
00040 #include "cblock.h"
00041 #include "cnode.h"
00042 #include "cfref.h"
00043 
00044 class CContext;
00045 
00046 
00050 class CFunction: public CBlock
00051 {
00052 private:
00053         CSymtab<CDecl>    portSymtab;       
00054         int               portDirListValid; 
00055 
00056         vector<CPortDir*> portDirList;      
00057         CDecl*            output;           
00058 
00059         int               automatic;        
00060         CNode*            ports;            
00061         int               inlinePortDecls;  
00062         CSymbol*          trailingLabel;    
00063 public:
00070         CFunction( CSymbol* symbol, Coord_t* aLoc, int automatic );
00075         virtual void Dump( FILE* f );
00080         virtual vector<CPortDir*>* GetPortDirList();
00085         void    SetTrailingLabel( CSymbol* label ) { trailingLabel = label; }
00090         CSymbol* GetTrailingLabel() { return trailingLabel; }
00095         void    SetPorts( CNode* n ) { ports = n; }
00100         CNode*  GetPorts() { return ports; }
00105         int     InlinePortDecls() { return inlinePortDecls; }
00110         void    InlinePortDecls( int v ) { inlinePortDecls = v; }
00115         void    SetOutput( CDecl* output ) { this->output = output; }
00120         CDecl*  GetOutput() { return output; }
00126         int     GetAutomatic() { return automatic; }
00127 
00137         static int Width( CSymbol* symbol, CNode* args, CBlock* block ) ;
00147         static CNode* WidthExp( CSymbol* symbol, CNode* args, CBlock* block ) ;
00158         static int WidthConstant( CSymbol* symbol, CNode* args, 
00159                                                         CBlock* block );
00170         static int WidthVolatile( CSymbol* symbol, CNode* args, 
00171                                                         CBlock* block );
00181         static int WidthEvaluateable( CSymbol* symbol, CNode* args, 
00182                                       CBlock* block );
00192         static NodeType_t Type( CSymbol* symbol, CNode* args, CBlock* block );
00193 
00201         static int Evaluateable( CSymbol* symbol, CNode* args, CBlock* block );
00202 
00210         static void EvalVector( CVector& v, CSymbol* symbol, 
00211                                         CNode* args, CBlock* block );
00212 
00220         static double EvalReal( CSymbol* symbol, CNode* args, CBlock* block );
00221 
00226         void    PreVisit1( int (*func)(CNode*,void*), void* data );
00227         void    PostVisit1( void (*func)(CNode*, void*), void* data );
00228         void    PostSubVisit1( CNode* (*func)(CNode*, void*), void* data );
00229         void    FixupPorts();
00230         void    SetPortSymtab( CSymtab<CDecl>& symtab );
00231 protected:
00232         virtual void CodeListChanged() { portDirListValid = FALSE; }
00233 private:
00234         static CFunction* FindFunction( CSymbol* symbol,
00235                                 CNode* args, CBlock* block );
00236         void EvaluateArgs( CContext* context, CNode* args );
00240 };
00241 
00242 #endif // CFUNCTION_HPP