decl.h 663 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef DECL_H
  2. #define DECL_H
  3. enum{
  4. DECL_FUNC=1,DECL_ARRAY=2,DECL_STRUCT=4, //NOT vars
  5. DECL_GLOBAL=8,DECL_LOCAL=16,DECL_PARAM=32,DECL_FIELD=64 //ARE vars
  6. };
  7. struct Type;
  8. struct ConstType;
  9. struct Decl{
  10. string name;
  11. Type *type; //type
  12. int kind,offset;
  13. ConstType *defType; //default value
  14. Decl( const string &s,Type *t,int k,ConstType *d=0 ):name(s),type(t),kind(k),defType(d){}
  15. ~Decl();
  16. virtual void getName( char *buff );
  17. };
  18. struct DeclSeq{
  19. vector<Decl*> decls;
  20. DeclSeq();
  21. ~DeclSeq();
  22. Decl *findDecl( const string &s );
  23. Decl *insertDecl( const string &s,Type *t,int kind,ConstType *d=0 );
  24. int size(){ return decls.size(); }
  25. };
  26. #endif