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