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