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 /* -*-Mode: c++;-*- (Tell emacs to use c++ mode) */ 00037 #ifndef anl_srcpos_INCLUDED 00038 #define anl_srcpos_INCLUDED 00039 00040 // ============================================================== 00041 // ============================================================== 00042 // 00043 // Module: anl_srcpos.h 00044 // $Revision: 1.1 $ 00045 // $Date: 2005/07/27 02:13:44 $ 00046 // $Author: kevinlo $ 00047 // $Source: /depot/CVSROOT/javi/src/sw/cmplr/be/prompf_anl/anl_srcpos.h,v $ 00048 // 00049 // Description: 00050 // 00051 // An object oriented interface to srcpos utilities. Note that 00052 // all relational comparison operators return FALSE for different 00053 // Filenum(), since we assume no order between files. 00054 // 00055 // ============================================================== 00056 // ============================================================== 00057 00058 #include "srcpos.h" 00059 00060 class ANL_SRCPOS 00061 { 00062 private: 00063 00064 USRCPOS _usrcpos; 00065 00066 public: 00067 00068 // ============== Constructors & Destructors ============== 00069 00070 ANL_SRCPOS() {USRCPOS_srcpos(_usrcpos) = 0;} 00071 ANL_SRCPOS(SRCPOS srcpos) {USRCPOS_srcpos(_usrcpos) = srcpos;} 00072 ANL_SRCPOS(WN *stmt) 00073 { 00074 if (stmt == NULL) 00075 USRCPOS_srcpos(_usrcpos) = 0; 00076 else 00077 USRCPOS_srcpos(_usrcpos) = WN_linenum(stmt); 00078 } 00079 00080 00081 // =============== Accessors =============== 00082 00083 INT32 Filenum() const {return USRCPOS_filenum(_usrcpos);} 00084 INT32 Linenum() const {return USRCPOS_linenum(_usrcpos);} 00085 INT32 Column() const {return USRCPOS_column(_usrcpos);} 00086 00087 00088 // =============== Writing to string buffer =============== 00089 00090 void Write(ANL_CBUF *cbuf); 00091 void Write_Filenum(ANL_CBUF *cbuf) const {cbuf->Write_Int(Filenum());} 00092 void Write_Linenum(ANL_CBUF *cbuf) const {cbuf->Write_Int(Linenum());} 00093 void Write_Column(ANL_CBUF *cbuf) const {cbuf->Write_Int(Column());} 00094 00095 00096 // =============== Assignment Operators =============== 00097 00098 ANL_SRCPOS &operator=(const ANL_SRCPOS &s) 00099 { 00100 _usrcpos.srcpos = s._usrcpos.srcpos; 00101 return *this; 00102 } 00103 ANL_SRCPOS &operator+=(INT32 lineincr) 00104 { 00105 USRCPOS_linenum(_usrcpos) += lineincr; 00106 return *this; 00107 } 00108 ANL_SRCPOS &operator-=(INT32 linedecr) 00109 { 00110 USRCPOS_linenum(_usrcpos) -= linedecr; 00111 return *this; 00112 } 00113 00114 // =============== Comparison Operators =============== 00115 00116 00117 BOOL operator==(const ANL_SRCPOS &s) 00118 { 00119 return s._usrcpos.srcpos == _usrcpos.srcpos; 00120 } 00121 BOOL operator!=(const ANL_SRCPOS &s) 00122 { 00123 return s._usrcpos.srcpos == _usrcpos.srcpos; 00124 } 00125 BOOL operator<(const ANL_SRCPOS &s); 00126 BOOL operator<=(const ANL_SRCPOS &s); 00127 BOOL operator>(const ANL_SRCPOS &s); 00128 BOOL operator>=(const ANL_SRCPOS &s); 00129 00130 }; // class ANL_SRCPOS 00131 00132 #endif // anl_srcpos_INCLUDED
1.5.6