varnode.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef VARNODE_H
  2. #define VARNODE_H
  3. #include "varnode.h"
  4. struct VarNode : public Node{
  5. Type *sem_type;
  6. //get set var
  7. TNode *load( Codegen *g );
  8. virtual TNode *store( Codegen *g,TNode *n );
  9. virtual bool isObjParam();
  10. //addr of var
  11. virtual void semant( Environ *e )=0;
  12. virtual TNode *translate( Codegen *g )=0;
  13. };
  14. #include "decl.h"
  15. struct DeclVarNode : public VarNode{
  16. Decl *sem_decl;
  17. DeclVarNode( Decl *d=0 ):sem_decl(d){ if( d ) sem_type=d->type; }
  18. void semant( Environ *e );
  19. TNode *translate( Codegen *g );
  20. virtual TNode *store( Codegen *g,TNode *n );
  21. bool isObjParam();
  22. };
  23. struct IdentVarNode : public DeclVarNode{
  24. string ident,tag;
  25. IdentVarNode( const string &i,const string &t ):ident(i),tag(t){}
  26. void semant( Environ *e );
  27. };
  28. struct ArrayVarNode : public VarNode{
  29. string ident,tag;
  30. ExprSeqNode *exprs;
  31. Decl *sem_decl;
  32. ArrayVarNode( const string &i,const string &t,ExprSeqNode *e ):ident(i),tag(t),exprs(e){}
  33. ~ArrayVarNode(){ delete exprs; }
  34. void semant( Environ *e );
  35. TNode *translate( Codegen *g );
  36. };
  37. struct FieldVarNode : public VarNode{
  38. ExprNode *expr;
  39. string ident,tag;
  40. Decl *sem_field;
  41. FieldVarNode( ExprNode *e,const string &i,const string &t ):expr(e),ident(i),tag(t){}
  42. ~FieldVarNode(){ delete expr; }
  43. void semant( Environ *e );
  44. TNode *translate( Codegen *g );
  45. };
  46. struct VectorVarNode : public VarNode{
  47. ExprNode *expr;
  48. ExprSeqNode *exprs;
  49. VectorType *vec_type;
  50. VectorVarNode( ExprNode *e,ExprSeqNode *es ):expr(e),exprs(es){}
  51. ~VectorVarNode(){ delete expr;delete exprs; }
  52. void semant( Environ *e );
  53. TNode *translate( Codegen *g );
  54. };
  55. #endif