Jump to content

Introspector/GccCpp/mytypes.h

From Wikibooks, open books for an open world

here is my new tree.h wrapper


#ifndef HOST_WIDE_INT
//#typedef HOST_WIDE_INT int ;
#define HOST_WIDE_INT long
#endif

#include "machmode.h"

class rtx_def;
class tree_decl;
class tree_int_cst;
class tree_real_cst;
class tree_string;
class tree_complex;
class tree_vector;
class tree_identifier;
class tree_list;
class tree_vec;
class tree_exp;
class tree_block;
class tree_type;

class tree_common;
typedef tree_common tree_node;
typedef tree_node *tree;


#define  TREECONSTRUCTOR2(C) \
  C (); \
  C (void *); \
  C (C *); \
  C (C &); \
  C (const C &);  \
  operator bool () const;\
  C & operator =  (void *); \
  C & operator =  (const C &); \
  bool operator != (const C & ) const ; \
  bool operator != (C & ) const;\
  bool operator != (C & ) ;\
  bool operator != (C * ) ; \
  bool operator != (const int ) const ; /*!= 0*/		\
  bool operator != (const int ); /*!= 0*/		\
  bool operator == (const C & ) const ;		\
  bool operator == (C & ) ;\
  bool operator == (C * ) ;

#define  TREECONSTRUCTOR(C) \
  TREECONSTRUCTOR2(C)\
  C (tree_common *);

template <class T> class TRef
{
 public:
  TREECONSTRUCTOR(TRef)
  bool operator != (T *);
  bool operator != (const int & ) const;
  bool operator != ( const T & ) ;
  bool operator == ( T  ) ;
  T & operator =  (T *);
  T & operator =  (T &);

  operator T ();
};

template <class T> class TPtr
{
 public:
  TREECONSTRUCTOR(TPtr)
  bool operator != (T *);
  T & operator =  (T *);
  T & operator =  (T &);

  T * operator -> ();

  operator T ();
};

template <class T> class TreePtr
{
 public:
  TREECONSTRUCTOR(TreePtr)
  bool operator != (T *);
  T & operator =  (T *);
  T & operator =  (T &);

  operator tree_node* ();
  operator tree_decl * ();
  operator  tree_int_cst * ();
  operator  tree_real_cst* ();
  operator  tree_string* ();
  operator  tree_complex* ();
  operator  tree_vector* ();
  operator  tree_identifier* ();
  operator  tree_list* ();
  operator  tree_vec* ();
  operator  tree_exp* ();
  operator  tree_block* ();
  operator  tree_type* ();


  T * operator -> ();

  operator T ();

  bool operator != (const int &);

};


class TRefmachine_mode : public TRef<machine_mode>
{
 public:
  TREECONSTRUCTOR(TRefmachine_mode)
    
    operator int();
  TRefmachine_mode & operator =  (TRefmachine_mode &);
  TRefmachine_mode & operator =  (machine_mode );
  TRefmachine_mode & operator ==  (machine_mode );

  //  TRefmachine_mode & operator ==  (int );

};


class mystring : public TRef<const char *>
{
 public:
 mystring & operator = (const char *);
 // mystring & operator = (const char *);
};

class TRefHOST_WIDE_INT  : public  TRef<HOST_WIDE_INT>
{
 public:
  TRefHOST_WIDE_INT (  );
  TRefHOST_WIDE_INT ( HOST_WIDE_INT );
  const TRefHOST_WIDE_INT & operator  = (const long int & );
  const TRefHOST_WIDE_INT & operator  = (const int &);
  operator  long int ();
  operator  bool ();
  operator long unsigned int();
 const TRefHOST_WIDE_INT & operator  & (const long int  ) const;
 const TRefHOST_WIDE_INT & operator  &= (const long int  ) const;
 const TRefHOST_WIDE_INT & operator  << (const long int  ) const;
  const TRefHOST_WIDE_INT & operator  |= (const  TRefHOST_WIDE_INT &  ) const;
  const TRefHOST_WIDE_INT & operator  |= (const  unsigned long int &  ) const;
 const TRefHOST_WIDE_INT & operator  & (const  int  ) const;
 const TRefHOST_WIDE_INT & operator  &= (const  int  ) const;
 const TRefHOST_WIDE_INT & operator  << (const  int  ) const;
  bool operator < (TRefHOST_WIDE_INT &);
  bool operator < (long unsigned int &);
  bool operator < (int &);
  bool operator < (int) const;

  bool operator  == (const int & ) const;
  bool operator  == (const long unsigned int & ) const;
  bool operator  == (const TRefHOST_WIDE_INT &  ) const;
  bool operator  == (const HOST_WIDE_INT &  ) const;


  bool operator  != (const long int  ) const;
  bool operator  != (const int  ) const;
  bool operator  != (const unsigned  ) const;
  TRefHOST_WIDE_INT & operator  ~ ( ) ;
  
};

const TRefHOST_WIDE_INT TRefHOST_WIDE_INTNULL;

// LOW 
class TRefunsignedHOST_WIDE_INT  : public  TRef<unsigned HOST_WIDE_INT>
{
public:
  TRefunsignedHOST_WIDE_INT (  );
  TRefunsignedHOST_WIDE_INT ( int );
  TRefunsignedHOST_WIDE_INT & operator  = (int );

  const TRefunsignedHOST_WIDE_INT & operator  & (const unsigned long int  &) const;
  const TRefunsignedHOST_WIDE_INT & operator  & (const   TRefunsignedHOST_WIDE_INT &  ) const;

  const TRefunsignedHOST_WIDE_INT & operator  += (const  int &  );

  const TRefunsignedHOST_WIDE_INT & operator  &= (const  TRefunsignedHOST_WIDE_INT &  ) const;
  const TRefunsignedHOST_WIDE_INT & operator  |= (const  TRefunsignedHOST_WIDE_INT &  ) const;
  const TRefunsignedHOST_WIDE_INT & operator  |= (const  unsigned long int &  ) const;

  const TRefunsignedHOST_WIDE_INT & operator  << (const long int  ) const;

  const TRefunsignedHOST_WIDE_INT & operator  & (long int  ) const ;
  

  TRefunsignedHOST_WIDE_INT & operator  + (const  TRefunsignedHOST_WIDE_INT &  ) const;
    TRefunsignedHOST_WIDE_INT & operator  ~ ( ) ;
  const TRefunsignedHOST_WIDE_INT & operator  ^ (const  TRefunsignedHOST_WIDE_INT &  ) const;
  const TRefunsignedHOST_WIDE_INT & operator  ^= (const  TRefunsignedHOST_WIDE_INT &  ) const;
  bool operator  != (const  TRefunsignedHOST_WIDE_INT &  ) const;
  bool operator  != (const  unsigned long int &  ) const;
  bool operator  != (const int &  ) const;

  const TRefunsignedHOST_WIDE_INT & operator  << (const  int  ) const;

  operator long int();
  operator  int();
  bool operator < (long unsigned int &);
  bool operator < (TRefunsignedHOST_WIDE_INT &);
  bool operator < (int &);

  bool operator  == (const int  ) const;
  bool operator  == (const unsigned int  ) const;
  bool operator  == (const long unsigned int  ) const;
  bool operator  == (const TRefunsignedHOST_WIDE_INT &  ) const;
  bool operator  == (const TRefHOST_WIDE_INT &  ) const;

};

const TRefunsignedHOST_WIDE_INT  TRefunsignedHOST_WIDE_INTNULL;

class tree_common ;
typedef tree_common tree_node;

class BitRef2 : public TRef<unsigned>
{

 public:
  TREECONSTRUCTOR(BitRef2)

  unsigned operator |=  (unsigned);

  bool operator == (const BitRef2&);

  bool operator > (const long&);
  bool operator > (const BitRef2&);
  bool operator > (const TRefHOST_WIDE_INT &);
  bool operator > (const TRefunsignedHOST_WIDE_INT &);

  bool operator > (TRefHOST_WIDE_INT &);
  bool operator > (TRefunsignedHOST_WIDE_INT &);
  bool operator < (const BitRef2&);
  const BitRef2 & operator =  (unsigned);
  const BitRef2 & operator =  (int );

  const TRefHOST_WIDE_INT & operator  += (const  int &  );

  BitRef2 & operator  ~ ( ) ;
  BitRef2 & operator  << ( int ) ;
  

  tree_node * operator = (tree_node * );

};

const TRefunsignedHOST_WIDE_INT & operator  & (const TRefunsignedHOST_WIDE_INT &,const BitRef2 &  );  
const TRefunsignedHOST_WIDE_INT & operator  &= (const TRefunsignedHOST_WIDE_INT &,const BitRef2 &  ) ;


typedef BitRef2 TRefunsignedint;
typedef BitRef2 TRefunsigned ;
typedef BitRef2 TRefint;

const BitRef2 false_bit_ref;

class tree_type;

class TreeRef2
{
 public:
  TreePtr<tree_type> type;

  int GetCode();
  BitRef2 side_effects_flag;
  BitRef2 constant_flag;
  BitRef2 addressable_flag;
  BitRef2 volatile_flag;
  BitRef2 readonly_flag;
  BitRef2 unsigned_flag;
  BitRef2 asm_written_flag;
  //  BitRef unused_0 ;

  BitRef2 used_flag;
  BitRef2 nothrow_flag;
  BitRef2 static_flag;
  BitRef2 public_flag;
  BitRef2 private_flag;
  BitRef2 protected_flag;
  BitRef2 deprecated_flag ;
  //  BitRef unused_1 ;

  BitRef2 lang_flag_0;
  BitRef2 lang_flag_1;
  BitRef2 lang_flag_2;
  BitRef2 lang_flag_3;
  BitRef2 lang_flag_4;
  BitRef2 lang_flag_5;
  BitRef2 lang_flag_6;

};

class TreeRef
{

 public:
  // create one
  //  TreeRef(tree_node*);

  int GetCode();
  tree_node * operator =  (tree_node *);

  bool  operator ==  (const TreeRef2 &) const;

  bool  operator ==  (const TreeRef *) const;
  bool  operator !=  (TreeRef &) const ;
  bool  operator !=  (TreeRef *) const;
  bool  operator !=  (const int & ) const;
  bool  operator !=  (const int & ) ;
  bool  operator !=  (const int  ) const;
  bool  operator !=  (const int  ) ;

  // bool  operator !=  (const void *);
  //  bool  operator !=  (void *);
  bool  operator !=  ( unsigned );

  bool  operator !  ();
  operator bool ();

  operator tree_node * ();
  /*

  operator tree_decl * ();
  operator  tree_int_cst * ();
  operator  tree_real_cst* ();
  operator  tree_string* ();
  operator  tree_complex* ();
  operator  tree_vector* ();
  operator  tree_identifier* ();
  operator  tree_list* ();
  operator  tree_vec* ();
  operator  tree_exp* ();
  operator  tree_block* ();
  operator  tree_type* ();
  */
};




class TreeExpRef : public TreeRef
{
 public:
  TreeExpRef(tree_node *);
  tree_exp * operator -> ();

};

class TreeIntCstRef : public TreeRef
{
 public:
  TreeIntCstRef(const TreeRef &);
  TreeIntCstRef(tree_node *);
  tree_int_cst * operator -> ();
  bool  operator < (const TreeIntCstRef &) const;
  bool  operator <= (const TreeIntCstRef &) const;
  bool  operator > (const TreeIntCstRef &) const;
  bool  operator > (const TRefunsignedHOST_WIDE_INT &) const;
  bool  operator > (const TRefHOST_WIDE_INT &) const;
  bool  operator > (const int &) const;

  bool  operator < (const unsigned long int &) const;
  bool  operator < (const unsigned int &) const;
  bool  operator < (const  int &) const;
  bool  operator < (const TRefunsignedHOST_WIDE_INT &) const;
  bool  operator < (const TRefHOST_WIDE_INT &) const;
  bool  operator >= (const TreeIntCstRef &)const;
  bool  operator == (const TreeIntCstRef &)const;
  bool  operator != (const TreeIntCstRef &)const;
  const TreeIntCstRef&  operator += (const TreeIntCstRef &);
  const TreeIntCstRef&  operator + (const TreeIntCstRef &);
  const TreeIntCstRef&  operator + (const int &);
  const TreeIntCstRef&  operator += (const int &);
  const TreeIntCstRef&  operator - (const TreeIntCstRef &);
  const TreeIntCstRef&  operator - (tree );
  const TreeIntCstRef&  operator - (const int );

  const TreeIntCstRef & operator  << (long int  );
  const TreeIntCstRef & operator  << (const long int  ) const;
  const TreeIntCstRef & operator  << (const int  ) const;

  const TreeIntCstRef & operator  & (long int  ) const ;

  //  operator long unsigned int ();
};

unsigned int ToUnsignedInt(const TreeIntCstRef &);

template <class T> long unsigned int ToLongUnsignedInt(T);



class TreeType;

class TreeTypeRef : public TreeRef
{
 public:
  TreeTypeRef(tree_node *);
  TreeType * operator -> ();
  bool operator == (tree ) const;

  bool operator == (const TreeTypeRef &) const;
  bool operator != (const TreeTypeRef &) const;
  bool operator != (tree ) const;

  bool operator == (const TreeTypeRef *) const;
  bool operator != (const TreeTypeRef *) const;
};

class TreeStringRef : public TreeRef
{
 public:
  TreeStringRef(tree_node *);
  tree_string * operator -> ();
};

class TreeName
{
 public:
  operator tree_node * ();
};


class TreeValuesRef
{
 public:
  operator tree_node * ();

};

// interface used by fold-const
class TreeType
{
 public:
  TRefmachine_mode mode;
  TreeIntCstRef maxval;
  TreeIntCstRef minval;
  TreeIntCstRef size;
  TreeIntCstRef precision;
  TreeIntCstRef align;
  TreeTypeRef main_variant;
  TreeName name;
  TreeValuesRef values;
};



class TreeDeclRef : public TreeRef
{
 public:
  TreeDeclRef(tree_node *);
  tree_decl * operator -> ();
};

class TreeRealCstRef : public TreeRef
{
 public:
  TreeRealCstRef(tree_node *);
  tree_real_cst * operator -> ();
};

class TreeComplexRef : public TreeRef
{
 public:
  TreeComplexRef(tree_node *);
  tree_complex * operator -> ();

};

class TreeVectorRef : public TreeRef
{
 public:
  TreeVectorRef(tree_node *);
  tree_vector * operator -> ();
};

class TreeVecRef : public TreeRef
{
 public:
  TreeVecRef(tree_node *);
  tree_vec * operator -> ();

  TRef<int> length;
  TreeRef a[1];

};

class TreeListRef : public TreeRef
{
 public:
  TreeListRef(tree_node *);
  tree_list * operator -> ();
};

class TreeExprRef : public TreeRef
{
 public:
  TreeExprRef(tree_node *);
  tree_exp * operator -> ();
};



class BitRef
{

 public:
  TREECONSTRUCTOR(BitRef)
  unsigned operator |=  (unsigned);
  BitRef& operator =  (int);
  operator unsigned ();

};

typedef BitRef2  TRefunsigned_long;


class basic_block_def;
class bitmap_head_def;
class cselib_val_struct;

const TRefHOST_WIDE_INT&         operator > (const TRefHOST_WIDE_INT&,const TRefunsignedHOST_WIDE_INT &);
const TRefHOST_WIDE_INT&         operator > (const TRefHOST_WIDE_INT&,const BitRef &);
const TRefunsignedHOST_WIDE_INT& operator > (const TRefunsignedHOST_WIDE_INT&,const BitRef2 &);

const TRefHOST_WIDE_INT&         operator > (const BitRef &,const TRefHOST_WIDE_INT&);
const TRefunsignedHOST_WIDE_INT& operator > (const BitRef2 &,const TRefunsignedHOST_WIDE_INT&);

const TRefHOST_WIDE_INT&         operator > (const BitRef2 &,const TRefHOST_WIDE_INT&);
const TRefunsignedHOST_WIDE_INT& operator > (const BitRef &,const TRefunsignedHOST_WIDE_INT&);



const TRefHOST_WIDE_INT&         operator ^ (const long int &          ,const TRefHOST_WIDE_INT&);
const TRefunsignedHOST_WIDE_INT& operator ^ (const unsigned long int & ,const TRefunsignedHOST_WIDE_INT&);

const TRefunsignedHOST_WIDE_INT& operator ^ (const TRefHOST_WIDE_INT & ,const TRefunsignedHOST_WIDE_INT&);


int & operator+=(int & ,const TRefunsignedHOST_WIDE_INT &);
int & operator+=(int &,const TRefHOST_WIDE_INT &);
const TreeIntCstRef &  operator << (unsigned long int ,const TreeIntCstRef &);
const TreeIntCstRef &  operator << (long int ,const TreeIntCstRef &);

const TreeIntCstRef &  operator &= (int,const TreeIntCstRef &);