node.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef NODE_H
  2. #define NODE_H
  3. #include "ex.h"
  4. #include "toker.h"
  5. #include "environ.h"
  6. #include "codegen.h"
  7. struct VarNode;
  8. struct ConstNode;
  9. struct Node{
  10. virtual ~Node(){}
  11. //used user funcs...
  12. static set<string> usedfuncs;
  13. //helper funcs
  14. static void ex();
  15. static void ex( const string &e );
  16. static void ex( const string &e,int pos );
  17. static void ex( const string &e,int pos,const string &f );
  18. static string genLabel();
  19. static VarNode *genLocal( Environ *e,Type *ty );
  20. static TNode *compare( int op,TNode *l,TNode *r,Type *ty );
  21. static ConstNode *constValue( Type *ty );
  22. static int enumVars( Environ *e );
  23. static Type *tagType( const string &s,Environ *e );
  24. static TNode *createVars( Environ *e );
  25. static TNode *deleteVars( Environ *e );
  26. static TNode *seq( TNode *l,TNode *r );
  27. static TNode *move( TNode *src,TNode *dest );
  28. static TNode *global( const string &s );
  29. static TNode *local( int offset );
  30. static TNode *arg( int offset );
  31. static TNode *mem( TNode *ref );
  32. static TNode *add( TNode *l,TNode *r );
  33. static TNode *mul( TNode *l,TNode *r );
  34. static TNode *iconst( int n );
  35. static TNode *ret();
  36. static TNode *jsr( const string &s );
  37. static TNode *jump( const string &s );
  38. static TNode *jumpt( TNode *cond,const string &s );
  39. static TNode *jumpf( TNode *cond,const string &s );
  40. static TNode *jumpge( TNode *l,TNode *r,const string &s );
  41. static TNode *call( const string &func,TNode *a0=0,TNode *a1=0,TNode *a2=0 );
  42. static TNode *fcall( const string &func,TNode *a0=0,TNode *a1=0,TNode *a2=0 );
  43. };
  44. #endif