1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 25 #ifndef ADC_CPP_PE_VAFU_HXX 26 #define ADC_CPP_PE_VAFU_HXX 27 28 // BASE CLASSES 29 #include "cpp_pe.hxx" 30 // USED SERVICES 31 #include <semantic/callf.hxx> 32 #include <semantic/sub_peu.hxx> 33 #include <ary/cpp/c_types4cpp.hxx> 34 #include <ary/cpp/c_vfflag.hxx> 35 36 37 38 namespace cpp 39 { 40 41 class PE_Type; 42 class PE_Variable; 43 class PE_Function; 44 class PE_Ignore; 45 46 47 48 49 class PE_VarFunc : public Cpp_PE 50 { 51 public: 52 enum E_State 53 { 54 start, 55 expectCtor, 56 afterClassDecl, // Also used for after enum declaration. 57 expectName, 58 afterName, 59 afterName_inErraneousTemplate, 60 finished, 61 finishedIncludingFunctionImplementation, 62 size_of_states 63 }; 64 enum E_ResultType 65 { 66 result_unknown = 0, 67 result_ignore, /// Used for class and enum declarations and predeclarations and for extern variables and functions. 68 result_variable, 69 result_function 70 }; 71 72 typedef ary::cpp::E_Protection E_Protection; 73 74 75 PE_VarFunc( 76 Cpp_PE * i_pParent ); 77 ~PE_VarFunc(); 78 79 virtual void Call_Handler( 80 const cpp::Token & i_rTok ); 81 82 const std::vector<ary::cpp::Ce_id> & 83 Result_Ids() const; 84 ary::cpp::Type_id Result_FrontType() const; 85 const StringVector & 86 Result_Names() const; 87 E_ResultType Result_CeType() const; 88 89 private: 90 typedef SubPe< PE_VarFunc, PE_Type > SP_Type; 91 typedef SubPeUse< PE_VarFunc, PE_Type > SPU_Type; 92 typedef SubPe< PE_VarFunc, PE_Variable > SP_Variable; 93 typedef SubPeUse< PE_VarFunc, PE_Variable > SPU_Variable; 94 typedef SubPe< PE_VarFunc, PE_Function > SP_Function; 95 typedef SubPeUse< PE_VarFunc, PE_Function > SPU_Function; 96 typedef SubPe< PE_VarFunc, PE_Ignore > SP_Ignore; 97 typedef SubPeUse< PE_VarFunc, PE_Ignore > SPU_Ignore; 98 99 void Setup_StatusFunctions(); 100 virtual void InitData(); 101 virtual void TransferData(); 102 void Hdl_UnknownToken( const char *); 103 104 void SpInit_FunctionStd(); 105 void SpInit_FunctionCtor(); 106 void SpInit_FunctionDtor(); 107 void SpInit_FunctionCastOperator(); 108 void SpInit_FunctionNormalOperator(); 109 void SpReturn_Type(); 110 void SpReturn_Variable(); 111 void SpReturn_FunctionStd(); 112 void SpReturn_Ignore(); 113 114 void On_start_Identifier(const char * i_sText); 115 void On_start_operator(const char * i_sText); 116 void On_start_TypeKey(const char * i_sText); 117 void On_start_virtual(const char * i_sText); 118 void On_start_Tilde(const char * i_sText); 119 void On_start_const(const char * i_sText); 120 void On_start_volatile(const char * i_sText); 121 void On_start_extern(const char * i_sText); 122 void On_start_static(const char * i_sText); 123 void On_start_mutable(const char * i_sText); 124 void On_start_register(const char * i_sText); 125 void On_start_inline(const char * i_sText); 126 void On_start_explicit(const char * i_sText); 127 void On_start_Bracket_Right(const char * i_sText); 128 void On_start_typename(const char * i_sText); 129 130 void On_expectCtor_Bracket_Left(const char * i_sText); 131 132 void On_afterClassDecl_Semicolon(const char * i_sText); 133 134 void On_expectName_Identifier(const char * i_sText); 135 void On_expectName_operator(const char * i_sText); 136 void On_expectName_Bracket_Left(const char * i_sText); 137 138 void On_afterName_ArrayBracket_Left(const char * i_sText); 139 void On_afterName_Bracket_Left(const char * i_sText); 140 void On_afterName_DoubleColon(const char * i_sText); 141 void On_afterName_Semicolon(const char * i_sText); 142 void On_afterName_Comma(const char * i_sText); 143 void On_afterName_Assign(const char * i_sText); 144 void On_afterName_Less(const char * i_sText); 145 146 void On_afterName_inErraneousTemplate_Less(const char * i_sText); 147 void On_afterName_inErraneousTemplate_Greater(const char * i_sText); 148 void On_afterName_inErraneousTemplate_Default(const char * i_sText); 149 150 void On_finished_Semicolon(const char * i_sText); 151 void On_finished_Comma(const char * i_sText); 152 void On_finished_Default(const char * i_sText); 153 154 void On_finishedIncludingFunctionImplementation_Default(const char * i_sText); 155 156 ary::cpp::FunctionFlags 157 CreateFunctionFlags(); 158 159 // DATA 160 Dyn< PeStatusArray<PE_VarFunc> > 161 pStati; 162 163 Dyn<SP_Type> pSpType; 164 Dyn<SPU_Type> pSpuType; 165 Dyn<SP_Variable> pSpVariable; 166 Dyn<SPU_Variable> pSpuVariable; 167 Dyn<SP_Function> pSpFunction; 168 Dyn<SPU_Function> pSpuFunctionStd; 169 Dyn<SPU_Function> pSpuFunctionCtor; 170 Dyn<SPU_Function> pSpuFunctionDtor; 171 Dyn<SPU_Function> pSpuFunctionCastOperator; 172 Dyn<SPU_Function> pSpuFunctionNormalOperator; 173 Dyn<SP_Ignore> pSpIgnore; 174 Dyn<SPU_Ignore> pSpuIgnore; 175 176 intt nCounter_TemplateBrackets; 177 bool bInDestructor; 178 179 std::vector<ary::cpp::Ce_id> 180 aResultIds; 181 ary::cpp::Type_id nResultFrontType; 182 E_ResultType eResultType; 183 184 // Pre-Results 185 String sName; 186 187 bool bVirtual; 188 bool bStatic; 189 bool bExtern; 190 bool bExternC; 191 bool bMutable; 192 bool bInline; 193 bool bRegister; 194 bool bExplicit; 195 }; 196 197 198 199 // IMPLEMENTATION 200 201 inline const std::vector<ary::cpp::Ce_id> & 202 PE_VarFunc::Result_Ids() const 203 { return aResultIds; } 204 inline ary::cpp::Type_id 205 PE_VarFunc::Result_FrontType() const 206 { return nResultFrontType; } 207 inline PE_VarFunc::E_ResultType 208 PE_VarFunc::Result_CeType() const 209 { return eResultType; } 210 211 212 213 } // namespace cpp 214 215 216 217 218 #endif 219 220 221 /* // Overview of Stati 222 223 Undecided 224 --------- 225 226 start // vor und w�hrend storage class specifiern 227 any ->stay 228 operaator ->goto Function 229 230 ->Typ 231 232 expectName 233 Identifier ->stay 234 operator ->goto Function 235 236 afterName ->goto Variable or Function 237 238 239 240 241 Variable 242 -------- 243 244 start // vor und w�hrend storage class specifiern 245 246 ->Typ 247 248 expectName // Typ ist da -> im Falle von '(': notyetimplemented 249 afterName 250 251 expectSize // after [ 252 expectFinish 253 // vor ; oder , 254 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 255 256 257 258 259 260 Function 261 -------- 262 263 start // vor und w�hrend storage class specifiern 264 265 ->Typ 266 267 expectName // Typ ist da 268 expectBracket // Nach Name 269 expectParameter // nach ( oder , 270 -> Parameter 271 after Parameters // before const, volatile throw or = 0. 272 after throw // expect ( 273 expectException // after ( 274 after exceptions // = 0 oder ; oder , 275 276 277 expectNextVarName // anders als bei expectName kann hier auch * oder & kommen 278 279 280 281 282 283 284 285 */ 286