Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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