Polaris: ArrayRefExpr.h Source File

ArrayRefExpr.h

Go to the documentation of this file.
00001 ///
00002 #ifndef _ARRAY_REF_EXPR_H
00003 #define _ARRAY_REF_EXPR_H
00004 ///
00005 /// \class ArrayRefExpr 
00006 /// \brief An expression representing an array reference.
00007 /// \defgroup Polaris
00008 /// \ingroup Polaris
00009 ///  Expression
00010 /// \see Expression/ArrayRefExpr.h
00011 /// \see Expression/ArrayRefExpr.h
00012 /// \see Expression/Expression.cc
00013 ///
00014 /// \endcode
00015 /// \section Description Description
00016 /// An ArrayRefExpr is an array reference.  It consists of an
00017 /// array name and a subscripting expression.
00018 ///
00019 /// USE:
00020 /// array is an IDExpr
00021 /// subscript is a CommaExpr
00022 ///
00023 #ifdef POLARIS_GNU_PRAGMAS
00024 #pragma interface
00025 #endif
00026 ///
00027 #ifndef _BINARY_EXPR_H
00028 #include "BinaryExpr.h"
00029 #endif
00030 ///
00031 class   DDgraph;
00032 
00033 class ArrayRefExpr : public BinaryExpr {
00034     friend class          ExprTable;
00035     friend class        DDgraph;
00036 
00037  public:
00038     inline ArrayRefExpr(const Type & etype, Expression * array_exp,
00039             Expression * subscript_exp);
00040     inline ArrayRefExpr(const ArrayRefExpr & e);
00041     virtual ~ArrayRefExpr();
00042 
00043     virtual ArrayRefExpr & operator = (const ArrayRefExpr &);
00044 
00045     const Expression & array() const {
00046       return _left_guarded();
00047     }
00048 
00049     Expression & array() {
00050       return _left_guarded();
00051     }
00052 
00053     virtual void array(Expression *);
00054     ///< Access the variable name of the array reference.  This
00055     ///< expression should always be an IDExpr.
00056 
00057     inline const Expression & subscript() const {
00058       return _right_guarded();
00059     }
00060 
00061     inline Expression & subscript() {
00062       return _right_guarded();
00063     }
00064     virtual void    subscript(Expression *);
00065     ///< Access the subscript expression of the array reference.
00066     ///< This expression should always be a CommaExpr.
00067 
00068     virtual Expression *clone() const;
00069     virtual int     structures_OK() const;
00070     virtual void    convert(BinRep & exprSet, Symtab & symtab);
00071     virtual void    print_debug(ostream & o, Boolean debug) const;
00072     virtual const Symbol *base_variable_ref() const;
00073     virtual Symbol *base_variable_ref();
00074     ///< See Expression.h.
00075  
00076     virtual int     exchange_expr( VDL & vdl );
00077     ///< Create a node in the "expression" member and return the index.
00078 
00079  protected:
00080     Arc_type       *_arcs;
00081 
00082     inline ArrayRefExpr(const Type & etype);
00083 };
00084 
00085 
00086 ///< inline implementations
00087 
00088 
00089 inline
00090 ArrayRefExpr::ArrayRefExpr(const Type & etype)
00091 : BinaryExpr(ARRAY_REF_OP, etype) 
00092 {
00093     _arcs = 0;
00094 }
00095 
00096 inline
00097 ArrayRefExpr::ArrayRefExpr(const Type & etype, Expression * array_exp,
00098          Expression * subscript_exp)
00099 : BinaryExpr(ARRAY_REF_OP, etype, array_exp, subscript_exp) 
00100 {
00101     p_assert(array_exp->op() == ID_OP
00102          || array_exp->is_wildcard(),
00103          "ArrayRefExpr( ):'array' expression not an IDExpr");
00104     p_assert(subscript_exp->op() == COMMA_OP
00105          || subscript_exp->is_wildcard(),
00106          "ArrayRefExpr( ):'subscript' expression not a CommaExpr");
00107     _arcs = 0;
00108 }
00109 
00110 inline
00111 ArrayRefExpr::ArrayRefExpr(const ArrayRefExpr & e)
00112 : BinaryExpr(e) 
00113 {
00114     _arcs = 0;
00115 }
00116 
00117 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:05:37 2005