val.h 971 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef VAL_H
  2. #define VAL_H
  3. #include "type.h"
  4. #include "scope.h"
  5. struct Val : public Scope{
  6. Type *type;
  7. CGExp *cg_exp;
  8. Val( int n,Type *ty=Type::int32 );
  9. Val( int64 n,Type *ty=Type::int64 );
  10. Val( float n,Type *ty=Type::float32 );
  11. Val( double n,Type *ty=Type::float64 );
  12. Val( bstring t );
  13. Val( const char *t );
  14. Val( Type *t,CGExp *e );
  15. virtual ~Val();
  16. CGExp* constant();
  17. int64 intValue();
  18. double floatValue();
  19. bstring stringValue();
  20. Val* cond();
  21. Val* cast( Type *ty );
  22. Val* initCast( Type *ty );
  23. Val* funArgCast( Type *ty,CGSeq *cleanup );
  24. Val* forEachCast( Type *ty );
  25. Val* explicitCast( Type *ty );
  26. Val* find( string id );
  27. Type* balance( Val *t );
  28. Type* balance( Type *t );
  29. Val* retain();
  30. CGStm* release();
  31. bool refCounted();
  32. int countTmps( string id );
  33. Val* renameTmps( string id,CGExp *e );
  34. static Val* null( Type *ty );
  35. };
  36. struct SuperVal : public Val{
  37. SuperVal( Val *v );
  38. Val* find( string id );
  39. };
  40. #endif