Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
x_set_macro.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  * Revision history:
00041  *  05-05-93 - Original Version
00042  *
00043  * Description:
00044  *
00045  *      Template for macro interface to sets of objects.  This is
00046  *      processed by common/util/gen_x_set into a particular
00047  *      instantiation for a particular base type.  See below for a
00048  *      complete interface documentation.
00049  *
00050  * ====================================================================
00051  * ====================================================================
00052  */
00053 
00054 BEGIN
00055 
00056 #ifndef #uset#_INCLUDED
00057 #define #uset#_INCLUDED
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061 
00062 
00063 #include "bitset.h"     /* our clients do not need to know about it */
00064 
00065 typedef BS #uset#;
00066 
00067 BEGIN SUBUNIVERSES
00068 class #uset#_SUBUNIVERSE;
00069 END SUBUNIVERSES
00070 
00071 #define #uset#_CHOOSE_FAILURE ((#base_type#)BS_CHOOSE_FAILURE)
00072 
00073 /* This macro will maps BS_ELTs to their corresponding base_type elements,
00074  * allowing for the possibility that #num_elt# may not be defined on
00075  * BS_CHOOSE_FAILURE and maintaining the mapping from BS_CHOOSE_FAILURE to
00076  * #uset#_CHOOSE_FAILURE.   In other words:
00077  *
00078  *      #uset#_bs_elt_bas_type(x) ==>
00079  *              #uset#_CHOOSE_FAILURE if x == BS_CHOOSE_FAILURE
00080  *              #num_elt#(x)          otherwise
00081  *
00082  * The complexity arises from the possibility that x may be an expression,
00083  * instead of a simple variable.  In that case we can't evaluate it twice,
00084  * since it may have side effects or be expensive to evaluate.  So we'll
00085  * assign it to a file scoped static and select the result depending on
00086  * whether it's a choose failure.  Not so great, huh?
00087  *
00088  * TODO: Allow an optional straightforward implementation for mappings that
00089  * map BS_CHOOSE_FAILURE to #uset#_CHOOSE_FAILURE.
00090  */
00091 inline #base_type#
00092 #uset#_bs_elt_base_type( BS_ELT x )
00093 {
00094   if ( x == BS_CHOOSE_FAILURE )
00095     return #uset#_CHOOSE_FAILURE;
00096   else
00097     return #num_elt#(x);
00098 }
00099 
00100 
00101 /* A subuniverse version as well. */
00102 BEGIN SUBUNIVERSES
00103 inline #base_type#
00104 #uset#_bs_elt_base_type_sub( BS_ELT x, #uset#_SUBUNIVERSE* sub )
00105 {
00106   if ( x == BS_CHOOSE_FAILURE )
00107     return #uset#_CHOOSE_FAILURE;
00108   else
00109     return #num_elt_sub#(x,sub);
00110 }
00111 END SUBUNIVERSES
00112 
00113 #define #uset#_Create BS_Create
00114 #define #uset#_Size_Alloc_Size BS_Size_Alloc_Size
00115 #define #uset#_Alloc_Size BS_Alloc_Size
00116 #define #uset#_ClearD BS_ClearD
00117 #define #uset#_Create_Empty BS_Create_Empty
00118 #define #uset#_Range BS_Range
00119 #define #uset#_RangeD BS_RangeD
00120 
00121 #define #uset#_Singleton(e,p)                                           \
00122     BS_Singleton(#elt_num#(e),(p))
00123 
00124 BEGIN SUBUNIVERSES
00125 #define #uset#_SingletonS(e,p,s)                                        \
00126     BS_Singleton(#elt_num_sub#((e),(s)),(p))
00127 END SUBUNIVERSES
00128 
00129 #define #uset#_SingletonD(s,e,p)                                        \
00130     BS_SingletonD((s),#elt_num#(e),(p))
00131 
00132 BEGIN SUBUNIVERSES
00133 #define #uset#_SingletonDS(s,e,p,sub)                                   \
00134     BS_SingletonD((s),#elt_num_sub#((e),(sub)),(p))
00135 END SUBUNIVERSES
00136 
00137 #define #uset#_Universe BS_Universe
00138 #define #uset#_UniverseD BS_UniverseD
00139 #define #uset#_Copy BS_Copy
00140 #define #uset#_CopyD BS_CopyD
00141 
00142 #define #uset#_Choose(x)                                                \
00143   #uset#_bs_elt_base_type(BS_Choose(x))
00144 
00145 #define #uset#_ChooseS(x,s)                                             \
00146   #uset#_bs_elt_base_type_sub(BS_Choose(x),s)
00147 
00148 #define #uset#_Intersection_Choose(x1,x2)                               \
00149   #uset#_bs_elt_base_type(BS_Intersection_Choose((x1),(x2)))
00150 
00151 #define #uset#_Intersection_ChooseS(x1,x2,s)                            \
00152   #uset#_bs_elt_base_type_sub(BS_Intersection_Choose((x1),(x2)),(s))
00153 
00154 #define #uset#_Choose_Next(x,e)                                         \
00155   #uset#_bs_elt_base_type(BS_Choose_Next((x),#elt_num#(e)))
00156 
00157 BEGIN SUBUNIVERSES
00158 /* Needs to evaluate "sub" twice, so it has to be a function:
00159  */
00160 extern #base_type# #uset#_Choose_NextS(
00161   #uset#*,
00162   #base_type#,
00163   #uset#_SUBUNIVERSE*
00164 );
00165 END SUBUNIVERSES
00166 
00167 #define #uset#_Intersection_Choose_Next(x1,x2,e)                        \
00168   #uset#_bs_elt_base_type(BS_Intersection_Choose_Next((x1),(x2),#elt_num#(e)))
00169 
00170 BEGIN SUBUNIVERSES
00171 /* Needs to evaluate "sub" twice, so it has to be a function:
00172  */
00173 extern #base_type# #uset#_Intersection_Choose_NextS(
00174   #uset#*,
00175   #uset#*,
00176   #base_type#,
00177   #uset#_SUBUNIVERSE*
00178 );
00179 END SUBUNIVERSES
00180 
00181 #define #uset#_Choose_Range(x,l,h)                                      \
00182   #uset#_bs_elt_base_type(BS_Choose_Range((x),(l),(h)))
00183 
00184 #define #uset#_Choose_RangeS(x,l,h,s)                                   \
00185   #uset#_bs_elt_base_type_sub(BS_Choose_Range((x),(l),(h)),(s))
00186 
00187 #define #uset#_Difference BS_Difference
00188 #define #uset#_DifferenceD BS_DifferenceD
00189 
00190 #define #uset#_Difference1(s,e,p)                                       \
00191     BS_Difference1(s,#elt_num#(e),(p))
00192 
00193 BEGIN SUBUNIVERSES
00194 #define #uset#_Difference1S(s,e,p,sub)                                  \
00195     BS_Difference1(s,#elt_num_sub#((e),(sub)),(p))
00196 END SUBUNIVERSES
00197 
00198 #define #uset#_Difference1D(s,e)                                        \
00199     BS_Difference1D(s,#elt_num#(e))
00200 
00201 BEGIN SUBUNIVERSES
00202 #define #uset#_Difference1DS(s,e,sub)                                   \
00203     BS_Difference1D(s,#elt_num_sub#((e),(sub)))
00204 END SUBUNIVERSES
00205 
00206 #define #uset#_Intersection BS_Intersection
00207 #define #uset#_IntersectionD BS_IntersectionD
00208 #define #uset#_Size BS_Size
00209 #define #uset#_Union BS_Union
00210 #define #uset#_UnionD BS_UnionD
00211 
00212 #define #uset#_Union1(s,x,p)                                            \
00213     BS_Union1((s),#elt_num#(x),(p))
00214 
00215 #define #uset#_UnionD_Intersection(s1,s2,s3,p)                          \
00216     BS_UnionD_Intersection((s1),(s2),(s3),(p))
00217 
00218 BEGIN SUBUNIVERSES
00219 #define #uset#_Union1S(s,x,p,sub)                                       \
00220     BS_Union1((s),#elt_num_sub#((x),(sub)),(p))
00221 END SUBUNIVERSES
00222 
00223 #define #uset#_Union1D(s,x,p)                                           \
00224     BS_Union1D((s),#elt_num#(x),(p))
00225 
00226 BEGIN SUBUNIVERSES
00227 #define #uset#_Union1DS(s,x,p,sub)                                      \
00228     BS_Union1D((s),#elt_num_sub#((x),(sub)),(p))
00229 END SUBUNIVERSES
00230 
00231 #define #uset#_ContainsP BS_ContainsP
00232 #define #uset#_EmptyP BS_EmptyP
00233 #define #uset#_EqualP BS_EqualP
00234 #define #uset#_IntersectsP BS_IntersectsP
00235 
00236 #define #uset#_MemberP(set,x) BS_MemberP((set),#elt_num#(x))
00237 
00238 BEGIN SUBUNIVERSES
00239 #define #uset#_MemberPS(set,x,s) BS_MemberP((set),#elt_num_sub#((x),(s)))
00240 END SUBUNIVERSES
00241 
00242 #define #uset#_Intersection_MemberP(set1,set2,x)                        \
00243     BS_Intersection_MemberP((set1),(set2),#elt_num#(x))
00244 
00245 BEGIN SUBUNIVERSES
00246 #define #uset#_Intersection_MemberPS(set1,set2,x,s)                     \
00247     BS_Intersection_MemberP((set1),(set2),#elt_num_sub#((x),(s)))
00248 END SUBUNIVERSES
00249 
00250 #define #uset#_Print BS_Print
00251 
00252 #define FOR_ALL_#uset#_members(set,x)   \
00253     for (x = #uset#_Choose(set);        \
00254          x != #uset#_CHOOSE_FAILURE;    \
00255          x = #uset#_Choose_Next(set,x))
00256 
00257 #ifdef __cplusplus
00258 }
00259 #endif
00260 #endif /* #uset#_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines