Polaris: RangeAccessor.h Source File

RangeAccessor.h

Go to the documentation of this file.
00001 #ifndef _RANGE_ACCESSOR_H
00002 #define _RANGE_ACCESSOR_H
00003 ///
00004 /// file RangeAccessor.h
00005 ///
00006 /// \class RangeAccessor 
00007 /// \brief Interface to a RangeDict object
00008 /// \defgroup Polaris
00009 /// \ingroup Polaris
00010 ///  Range
00011 /// \see RangeAccessor.h
00012 /// \see RangeAccessor.h
00013 /// \see RangeAccessor.cc
00014 ///
00015 /// \endcode
00016 /// \section Overview Overview
00017 /// A RangeAccessor object is an interface to a RangeDict
00018 /// object.  RangeAccessors are typically used to compare
00019 /// expressions or to determine whether a single expression is always
00020 /// positive or always negative.  See the compare() and sign() methods
00021 /// for more details.
00022 ///
00023 /// \endcode
00024 /// \section Description Description
00025 /// A RangeAccessor is created by giving it an RangeDict
00026 /// object and one or two statements.  Subsequent comparisons performed
00027 /// by the RangeAccessor would be done using those ranges
00028 /// that hold on the entry of the given statement (or both of the two
00029 /// given statements) in the program unit.
00030 ///
00031 /// Ranges can also be modified by a RangeAccessor object.
00032 /// However, these modifications are local to this object; that is
00033 /// the modifications are only seen by this object and are discarded
00034 /// when the object is deleted.  The associated RangeDict object
00035 /// is not modified.
00036 ///
00037 /// Many of the comparison operators can be found in the superclass of
00038 /// this object, RangeComparator.h.
00039 ///
00040 ///
00041 #include "../Collection/Map.h"
00042 #include "../Symbol/Symbol.h"
00043 #include "../Expression/Expression.h"
00044 ///
00045 #include "RangeDict.h"
00046 #include "RangeComparator.h"
00047 ///
00048 ///
00049 class Statement;
00050 
00051 class RangeAccessor : public RangeComparator {
00052 public:
00053     RangeAccessor(RangeDict &ranges, const Statement &stmt);
00054     ///< Create a RangeAccessor object that only uses those
00055     ///< ranges that hold on the entry of the given statement.
00056 
00057     RangeAccessor(RangeDict &ranges, const Statement &stmt1,
00058           const Statement &stmt2, bool union_ranges = true);
00059     ///< Create a RangeAccessor object that only uses those
00060     ///< ranges that hold on the entries of the given pair of statements.
00061     ///< If union_ranges=true, the sets of ranges of the two
00062     ///< statements are unioned together, otherwise they are intersected
00063     ///< togethor.  (Unioning means use the weaker of the two ranges,
00064     ///< while intersecting means to use the stronger of the two.)
00065 
00066     RangeAccessor(const RangeAccessor &other);
00067     ///< Copy constructor
00068 
00069     virtual ~RangeAccessor();
00070 
00071     virtual void set_range(const Symbol &var, Expression *range);
00072     ///< Set the given variable to the given range.
00073   
00074     virtual void del_range(const Symbol &var);
00075     ///< Delete the range associated with the given variable.
00076 
00077     virtual const Expression *get_range_ref(const Symbol &var);
00078     ///< Return the range associated with the given variable.  If the
00079     ///< variable doesn't have an associated range, return 0;
00080 
00081     RangeAccessor &operator = (const RangeAccessor &other);
00082     ///< Completely copy the contents of the other range accessor
00083     ///< into myself.
00084 
00085     virtual void print(ostream & out) const;
00086     ///< Print out the range accessor.
00087     
00088     void pretty_print(ostream & out) const;
00089     ///< Print out the range dictionary in a more user-readable
00090     ///< manner.
00091 
00092     Relation compare(const Expression &e1, const Expression &e2);
00093     Relation compare(const Expression &e1, int value);
00094 
00095     virtual Listable *listable_clone(void) const;
00096     virtual int structures_OK() const;
00097     ///< Methods required by Listable
00098 
00099 private:
00100     RangeDict *_range_dict;
00101     const Statement *_stmt1;
00102     const Statement *_stmt2;
00103     bool _union_ranges;
00104     Map<Symbol,Expression> _local_ranges;
00105 };
00106 
00107 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:04 2005