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