1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 #ifndef ADC_CPP_PE_FUNCT_HXX 30 #define ADC_CPP_PE_FUNCT_HXX 31 32 33 34 // USED SERVICES 35 // BASE CLASSES 36 #include "cpp_pe.hxx" 37 // COMPONENTS 38 #include <semantic/callf.hxx> 39 #include <semantic/sub_peu.hxx> 40 #include <ary/cpp/c_types4cpp.hxx> 41 #include <ary/cpp/c_vfflag.hxx> 42 // PARAMETERS 43 44 45 namespace ary 46 { 47 namespace cpp 48 { 49 class Function; 50 struct S_VariableInfo; 51 } 52 } 53 54 namespace cpp 55 { 56 57 class PE_Type; 58 class PE_Parameter; 59 60 class PE_Function : public Cpp_PE 61 { 62 public: 63 enum E_State 64 { 65 afterStdOperator, // if initializes as operator 66 afterStdOperatorLeftBracket, 67 // if initializes as operator with ( or [ 68 afterCastOperator, // if initializes as operator 69 afterName, // undecided 70 expectParameterSeparator, // 71 afterParameters, // before const, volatile throw or = 0. 72 afterThrow, // expect ( 73 expectExceptionSeparator, // 74 afterExceptions, // = 0 oder ; oder , 75 expectZero, // after '=' 76 inImplementation, // after { 77 size_of_states 78 }; 79 typedef ary::cpp::E_Protection E_Protection; 80 typedef ary::cpp::E_Virtuality E_Virtuality; 81 typedef ary::cpp::E_ConVol E_ConVol; 82 83 PE_Function( 84 Cpp_PE * i_pParent ); 85 ~PE_Function(); 86 87 void Init_Std( 88 const String & i_sName, 89 ary::cpp::Type_id i_nReturnType, 90 bool i_bVirtual, 91 ary::cpp::FunctionFlags 92 i_aFlags ); 93 void Init_Ctor( 94 const String & i_sName, 95 ary::cpp::FunctionFlags 96 i_aFlags ); 97 void Init_Dtor( 98 const String & i_sName, 99 bool i_bVirtual, 100 ary::cpp::FunctionFlags 101 i_aFlags ); 102 void Init_CastOperator( 103 bool i_bVirtual, 104 ary::cpp::FunctionFlags 105 i_aFlags ); 106 void Init_NormalOperator( 107 ary::cpp::Type_id i_nReturnType, 108 bool i_bVirtual, 109 ary::cpp::FunctionFlags 110 i_aFlags ); 111 112 ary::cpp::Ce_id Result_Id() const; 113 bool Result_WithImplementation() const; 114 115 virtual void Call_Handler( 116 const cpp::Token & i_rTok ); 117 private: 118 typedef SubPe< PE_Function, PE_Type > SP_Type; 119 typedef SubPeUse< PE_Function, PE_Type > SPU_Type; 120 typedef SubPe< PE_Function, PE_Parameter> SP_Parameter; 121 typedef SubPeUse<PE_Function, PE_Parameter> SPU_Parameter; 122 123 typedef std::vector<ary::cpp::S_Parameter> ParameterList; 124 typedef std::vector<ary::cpp::Type_id> ExceptionTypeList; 125 126 void Setup_StatusFunctions(); 127 virtual void InitData(); 128 virtual void TransferData(); 129 void Hdl_SyntaxError(const char * i_sText); 130 131 void SpInit_CastOperatorType(); 132 133 void SpReturn_Parameter(); 134 void SpReturn_Exception(); 135 void SpReturn_CastOperatorType(); 136 137 void On_afterOperator_Std_Operator(const char * i_sText); // Operator+() etc. 138 void On_afterOperator_Std_LeftBracket(const char * i_sText); // operator [] or () 139 void On_afterStdOperatorLeftBracket_RightBracket(const char * i_sText); 140 void On_afterOperator_Cast_Type(const char * i_sText); // Type 141 142 void On_afterName_Bracket_Left(const char * i_sText); 143 144 void On_expectParameterSeparator_BracketRight(const char * i_sText); 145 void On_expectParameterSeparator_Comma(const char * i_sText); 146 147 void On_afterParameters_const(const char * i_sText); 148 void On_afterParameters_volatile(const char * i_sText); 149 void On_afterParameters_throw(const char * i_sText); 150 void On_afterParameters_SwBracket_Left(const char * i_sText); 151 void On_afterParameters_Semicolon(const char * i_sText); 152 void On_afterParameters_Comma(const char * i_sText); 153 void On_afterParameters_Colon(const char * i_sText); 154 void On_afterParameters_Assign(const char * i_sText); 155 156 void On_afterThrow_Bracket_Left(const char * i_sText); 157 158 void On_expectExceptionSeparator_BracketRight(const char * i_sText); 159 void On_expectExceptionSeparator_Comma(const char * i_sText); 160 161 void On_afterExceptions_SwBracket_Left(const char * i_sText); 162 void On_afterExceptions_Semicolon(const char * i_sText); 163 void On_afterExceptions_Comma(const char * i_sText); 164 void On_afterExceptions_Colon(const char * i_sText); 165 void On_afterExceptions_Assign(const char * i_sText); 166 167 void On_expectZero_Constant(const char * i_sText); 168 169 void On_inImplementation_SwBracket_Left(const char * i_sText); 170 void On_inImplementation_SwBracket_Right(const char * i_sText); 171 void On_inImplementation_Default(const char * i_sText); 172 173 void PerformFinishingPunctuation(); 174 void EnterImplementation( 175 intt i_nBracketCountStart ); /// 1 normally, 0 in initialisation section of c'tors. 176 177 // DATA 178 Dyn< PeStatusArray<PE_Function> > 179 pStati; 180 181 Dyn< SP_Parameter > pSpParameter; 182 Dyn< SPU_Parameter> pSpuParameter; 183 Dyn< SP_Type > pSpType; 184 Dyn< SPU_Type > pSpuException; 185 Dyn< SPU_Type > pSpuCastOperatorType; // in "operator int()" or "operator ThatClass *()" 186 187 ary::cpp::Ce_id nResult; 188 bool bResult_WithImplementation; // Necessary for the parent ParseEnvironment 189 // to know, there is no semicolon or comma following. 190 // Pre results 191 StreamStr aName; 192 E_Virtuality eVirtuality; 193 E_ConVol eConVol; 194 ary::cpp::FunctionFlags 195 aFlags; 196 ary::cpp::Type_id nReturnType; 197 ParameterList aParameters; 198 ExceptionTypeList aExceptions; 199 bool bThrow; // Indicates, if there is a throw - important, if there are 0 exceptions listed. 200 intt nBracketCounterInImplementation; 201 }; 202 203 204 205 206 // IMPLEMENTATION 207 inline bool 208 PE_Function::Result_WithImplementation() const 209 { return bResult_WithImplementation; } 210 211 212 213 214 } // namespace cpp 215 #endif 216 217 218 219 220 221 /* // Overview of Stati 222 223 Undecided 224 --------- 225 226 start // vor und w�hrend storage class specifiern 227 228 ->Typ 229 230 expectName // Typ ist da 231 232 afterName 233 234 235 236 237 Variable 238 -------- 239 240 start // vor und w�hrend storage class specifiern 241 242 ->Typ 243 244 expectName // Typ ist da -> im Falle von '(': notyetimplemented 245 afterName 246 247 expectSize // after [ 248 expectFinish 249 // vor ; oder , 250 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 251 252 253 254 255 256 Function 257 -------- 258 259 start // vor und w�hrend storage class specifiern 260 261 ->Typ 262 263 expectName // Typ ist da 264 expectBracket // Nach Name 265 expectParameter // nach ( oder , 266 -> Parameter 267 after Parameters // before const, volatile throw or = 0. 268 after throw // expect ( 269 expectException // after ( 270 after exceptions // = 0 oder ; oder , 271 272 273 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 274 275 276 277 278 279 280 281 */ 282