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_TYPE_HXX
26 #define ADC_CPP_PE_TYPE_HXX
27 
28 
29 
30 // USED SERVICES
31 	// BASE CLASSES
32 #include "cpp_pe.hxx"
33 	// COMPONENTS
34 #include <ary/cpp/usedtype.hxx>
35 #include <semantic/callf.hxx>
36 #include <semantic/sub_peu.hxx>
37 	// PARAMETERS
38 #include <ary/cpp/c_types4cpp.hxx>
39 
40 
41 
42 namespace cpp {
43 
44 class PE_Class;
45 class PE_Enum;
46 class PE_Expression;
47 
48 class PE_Type : public Cpp_PE
49 {
50   public:
51 	enum E_State
52 	{
53 		start,
54 		expect_namesegment,
55 		after_namesegment,
56 		afterclass_expect_semicolon,
57 		within_template,
58 		within_indirection,
59 		size_of_states
60 	};
61 	enum E_KindOfResult
62 	{
63 		is_none,
64 		is_type,
65 		is_constructor,
66 		is_explicit_class_declaration,
67         is_class_predeclaration,
68 		is_explicit_enum_declaration
69 	};
70 
71 						PE_Type(
72 							Cpp_PE *			i_pParent );
73 						~PE_Type();
74 
75     void                Init_AsCastOperatorType();
76 
77 	virtual void		Call_Handler(
78 							const cpp::Token &	i_rTok );
79 
80 	E_KindOfResult		Result_KindOf() const;
81 	const ary::cpp::Type &
82 						Result_Type() const;
83   private:
84 	typedef SubPe< PE_Type, PE_Type >		    SP_Type;
85 	typedef SubPe< PE_Type, PE_Class >		    SP_Class;
86 	typedef SubPe< PE_Type, PE_Enum >		    SP_Enum;
87 	typedef SubPeUse< PE_Type, PE_Type >	    SPU_Type;
88 	typedef SubPeUse< PE_Type, PE_Class >	    SPU_Class;
89 	typedef SubPeUse< PE_Type, PE_Enum >	    SPU_Enum;
90 
91 	void				Setup_StatusFunctions();
92 	virtual void		InitData();
93 	virtual void		TransferData();
94 	void  				Hdl_SyntaxError( const char *);
95 
96 	void				SpReturn_Type_TemplateParameter();
97 	void				SpReturn_Class();
98 	void				SpReturn_Enum();
99 
100 	void				On_EndOfType(const char *);
101 
102 	void				On_start_Identifier(const char *);
103 	void				On_start_class(const char *);
104 	void				On_start_enum(const char *);
105 	void				On_start_const(const char *);
106 	void				On_start_volatile(const char *);
107 	void				On_start_Bracket_Right(const char *);
108 	void				On_start_DoubleColon(const char *);
109 	void				On_start_BuiltInType(const char *);
110 	void				On_start_TypeSpecializer(const char *);
111 	void				On_start_typename(const char *);
112 
113 	void				On_expect_namesegment_Identifier(const char *);
114 
115 	void				On_after_namesegment_const(const char *);
116 	void				On_after_namesegment_volatile(const char *);
117     void                On_after_namesegment_Bracket_Left(const char *);
118 	void				On_after_namesegment_DoubleColon(const char *);
119 	void				On_after_namesegment_Less(const char *);
120 	void				On_after_namesegment_Asterix(const char *);
121 	void				On_after_namesegment_AmpersAnd(const char *);
122 
123 	void				On_afterclass_expect_semicolon_Semicolon(const char *);
124 
125 	void				On_within_template_Comma(const char *);
126 	void				On_within_template_Greater(const char *);
127 	void				On_within_template_Constant(const char *);
128 	void				On_within_template_TypeStart(const char *);
129 
130 	void				On_within_indirection_const(const char *);
131 	void				On_within_indirection_volatile(const char *);
132 	void				On_within_indirection_Asterix(const char *);
133 	void				On_within_indirection_AmpersAnd(const char *);
134 
135 	bool				IsType() const;
136 
137 	// DATA
138 	Dyn< PeStatusArray<PE_Type> >
139 						pStati;
140 
141 	Dyn<SP_Type>	    pSpType;
142 	Dyn<SPU_Type>	 	pSpuType_TemplateParameter;
143 	Dyn<SP_Class>	    pSpClass;
144 	Dyn<SPU_Class>	 	pSpuClass;
145 	Dyn<SP_Enum>	    pSpEnum;
146 	Dyn<SPU_Enum>	 	pSpuEnum;
147 
148 	Dyn<ary::cpp::UsedType>
149 						pType;
150     ary::cpp::ut::List_TplParameter *
151                         pCurTemplate_ParameterList;
152 	String              sOwningClassName;
153     String 				sParsedClass_Name;
154 
155 	const ary::cpp::Type *
156 						pResult_Type;
157 	E_KindOfResult		eResult_KindOf;
158     bool                bIsCastOperatorType;
159 };
160 
161 
162 
163 // IMPLEMENTATION
164 
165 
166 inline const ary::cpp::Type &
Result_Type() const167 PE_Type::Result_Type() const
168 	{ csv_assert(pResult_Type != 0);
169 	  return *pResult_Type; }
170 inline PE_Type::E_KindOfResult
Result_KindOf() const171 PE_Type::Result_KindOf() const
172 	{ return eResult_KindOf; }
173 
174 
175 }   // namespace cpp
176 
177 
178 #endif
179 
180 
181 
182