Replaced unbound record elements with null pointers in record-ofs (bug 494614)
[deliverable/titan.core.git] / compiler2 / Typestuff.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Delic, Adam
11 * Forstner, Matyas
12 * Gecse, Roland
13 * Kovacs, Ferenc
14 * Raduly, Csaba
15 * Szabados, Kristof
16 * Szabo, Janos Zoltan – initial implementation
17 * Szalai, Gabor
18 * Tatarka, Gabor
19 * Zalanyi, Balazs Andor
20 *
21 ******************************************************************************/
22 #ifndef _Common_Typestuff_HH
23 #define _Common_Typestuff_HH
24
25 #include "Setting.hh"
26
27 namespace Asn {
28 class TagCollection;
29 } // namespace Asn
30
31 namespace Ttcn {
32 class WithAttribPath;
33 }
34
35 namespace Common {
36 class CompField;
37
38 /**
39 * \addtogroup AST_Type
40 *
41 * @{
42 */
43
44 /**
45 * ExceptionSpecification
46 */
47 class ExcSpec : public Node {
48 private:
49 Type *type;
50 Value *value;
51 /** Copy constructor not implemented */
52 ExcSpec(const ExcSpec& p);
53 /** Assignment disabled */
54 ExcSpec& operator=(const ExcSpec& p);
55 public:
56 ExcSpec(Type *p_type, Value *p_value);
57 virtual ~ExcSpec();
58 virtual ExcSpec *clone() const;
59 virtual void set_my_scope(Scope *p_scope);
60 virtual void set_fullname(const string& p_fullname);
61 Type *get_type() const { return type; }
62 Value *get_value() const { return value; }
63 };
64
65 class CTs_EE_CTs;
66 class CTs;
67 class ExtAndExc;
68 class ExtAdds;
69 class ExtAddGrp;
70 class ExtAdd;
71 class CT;
72 class CT_CompsOf;
73 class CT_reg;
74
75 /**
76 * ComponentTypeList
77 */
78 class CTs : public Node {
79 private:
80 vector<CT> cts;
81 /** Copy constructor not implemented */
82 CTs(const CTs& p);
83 /** Assignment disabled */
84 CTs& operator=(const CTs& p);
85 public:
86 CTs() : Node(), cts() { }
87 virtual ~CTs();
88 virtual CTs *clone() const;
89 virtual void set_fullname(const string& p_fullname);
90 virtual void set_my_scope(Scope *p_scope);
91 size_t get_nof_comps() const;
92 CompField* get_comp_byIndex(size_t n) const;
93 bool has_comp_withName(const Identifier& p_name) const;
94 CompField* get_comp_byName(const Identifier& p_name) const;
95 void tr_compsof(ReferenceChain *refch, bool is_set);
96 void add_ct(CT* p_ct);
97 virtual void dump(unsigned level) const;
98 };
99
100 /**
101 * ComponentTypeList ExtensionAndException ComponentTypeList
102 */
103 class CTs_EE_CTs : public Node {
104 CTs *cts1;
105 ExtAndExc *ee;
106 CTs *cts2;
107 /** Pointer to the owner type */
108 Type *my_type;
109 /** Indicates whether the uniqueness of components has been checked */
110 bool checked;
111 /** Shortcut for all components */
112 vector<CompField> comps_v;
113 /** Map for all components (indexed by component name) */
114 map<string, CompField> comps_m;
115 /** Copy constructor not implemented */
116 CTs_EE_CTs(const CTs_EE_CTs& p);
117 /** Assignment disabled */
118 CTs_EE_CTs& operator=(const CTs_EE_CTs& p);
119 public:
120 CTs_EE_CTs(CTs *p_cts1, ExtAndExc *p_ee, CTs *p_cts2);
121 virtual ~CTs_EE_CTs();
122 virtual CTs_EE_CTs *clone() const;
123 virtual void set_fullname(const string& p_fullname);
124 virtual void set_my_scope(Scope *p_scope);
125 void set_my_type(Type *p_my_type) { my_type = p_my_type; }
126 size_t get_nof_comps();
127 size_t get_nof_root_comps();
128 CompField* get_comp_byIndex(size_t n);
129 CompField* get_root_comp_byIndex(size_t n);
130 bool has_comp_withName(const Identifier& p_name);
131 CompField* get_comp_byName(const Identifier& p_name);
132 void tr_compsof(ReferenceChain *refch, bool in_ellipsis);
133 bool has_ellipsis() const { return ee != 0; }
134 bool needs_auto_tags();
135 void add_auto_tags();
136 /** Checks the uniqueness of components and builds the shortcut map and
137 * vectors */
138 void chk();
139 void chk_tags();
140 virtual void dump(unsigned level) const;
141 private:
142 void chk_comp_field(CompField *cf, const char *type_name,
143 const char *comp_name);
144 void chk_tags_choice();
145 void chk_tags_seq();
146 void chk_tags_seq_comp(Asn::TagCollection& coll, CompField *cf,
147 bool is_mandatory);
148 void chk_tags_set();
149 void get_multiple_tags(Asn::TagCollection& coll, Type *type);
150 };
151
152 /**
153 * ExtensionAddition (abstract class).
154 */
155 class ExtAdd : public Node {
156 public:
157 virtual ExtAdd *clone() const = 0;
158 virtual size_t get_nof_comps() const = 0;
159 virtual CompField* get_comp_byIndex(size_t n) const = 0;
160 virtual bool has_comp_withName(const Identifier& p_name) const = 0;
161 virtual CompField* get_comp_byName(const Identifier& p_name) const = 0;
162 virtual void tr_compsof(ReferenceChain *refch, bool is_set) = 0;
163 };
164
165 /**
166 * ExtensionAdditionList
167 */
168 class ExtAdds : public Node {
169 private:
170 vector<ExtAdd> eas;
171 /** Copy constructor not implemented */
172 ExtAdds(const ExtAdds& p);
173 /** Assignment disabled */
174 ExtAdds& operator=(const ExtAdds& p);
175 public:
176 ExtAdds() : Node(), eas() { }
177 virtual ~ExtAdds();
178 virtual ExtAdds *clone() const;
179 virtual void set_fullname(const string& p_fullname);
180 virtual void set_my_scope(Scope *p_scope);
181 size_t get_nof_comps() const;
182 CompField* get_comp_byIndex(size_t n) const;
183 bool has_comp_withName(const Identifier& p_name) const;
184 CompField* get_comp_byName(const Identifier& p_name) const;
185 void tr_compsof(ReferenceChain *refch, bool is_set);
186 void add_ea(ExtAdd* p_ea);
187 virtual void dump(unsigned level) const;
188 };
189
190 /**
191 * ExtensionAndException
192 */
193 class ExtAndExc : public Node {
194 private:
195 /** optional exception specification */
196 ExcSpec *excSpec;
197 ExtAdds *eas;
198 /** Copy constructor not implemented */
199 ExtAndExc(const ExtAndExc& p);
200 /** Assignment disabled */
201 ExtAndExc& operator=(const ExtAndExc& p);
202 public:
203 ExtAndExc(ExcSpec *p_excSpec, ExtAdds *p_eas=0);
204 virtual ~ExtAndExc();
205 virtual ExtAndExc *clone() const;
206 virtual void set_fullname(const string& p_fullname);
207 virtual void set_my_scope(Scope *p_scope);
208 size_t get_nof_comps() const { return eas->get_nof_comps(); }
209 CompField* get_comp_byIndex(size_t n) const
210 { return eas->get_comp_byIndex(n); }
211 bool has_comp_withName(const Identifier& p_name) const
212 { return eas->has_comp_withName(p_name); }
213 CompField* get_comp_byName(const Identifier& p_name) const
214 { return eas->get_comp_byName(p_name); }
215 void tr_compsof(ReferenceChain *refch, bool is_set)
216 { eas->tr_compsof(refch, is_set); }
217 void set_eas(ExtAdds *p_eas);
218 virtual void dump(unsigned level) const;
219 };
220
221 /**
222 * ExtensionAdditionGroup
223 */
224 class ExtAddGrp : public ExtAdd {
225 private:
226 /** can be NULL if not present */
227 Value *versionnumber;
228 CTs *cts;
229 /** Copy constructor not implemented */
230 ExtAddGrp(const ExtAddGrp& p);
231 /** Assignment disabled */
232 ExtAddGrp& operator=(const ExtAddGrp& p);
233 public:
234 ExtAddGrp(Value* p_versionnumber, CTs *p_cts);
235 virtual ~ExtAddGrp();
236 virtual ExtAddGrp *clone() const;
237 virtual void set_fullname(const string& p_fullname);
238 virtual void set_my_scope(Scope *p_scope);
239 virtual size_t get_nof_comps() const;
240 virtual CompField* get_comp_byIndex(size_t n) const;
241 virtual bool has_comp_withName(const Identifier& p_name) const;
242 virtual CompField* get_comp_byName(const Identifier& p_name) const;
243 virtual void tr_compsof(ReferenceChain *refch, bool is_set);
244 virtual void dump(unsigned level) const;
245 };
246
247 /**
248 * ComponentType (abstract class).
249 */
250 class CT : public ExtAdd, public Location {
251 public:
252 virtual CT *clone() const = 0;
253 };
254
255 /**
256 * ComponentType/regular (Contains only a Component).
257 */
258 class CT_reg : public CT {
259 private:
260 CompField *comp;
261 /** Copy constructor not implemented */
262 CT_reg(const CT_reg& p);
263 /** Assignment disabled */
264 CT_reg& operator=(const CT_reg& p);
265 public:
266 CT_reg(CompField *p_comp);
267 virtual ~CT_reg();
268 virtual CT_reg *clone() const;
269 virtual void set_fullname(const string& p_fullname);
270 virtual void set_my_scope(Scope *p_scope);
271 virtual size_t get_nof_comps() const;
272 virtual CompField* get_comp_byIndex(size_t n) const;
273 virtual bool has_comp_withName(const Identifier& p_name) const;
274 virtual CompField* get_comp_byName(const Identifier& p_name) const;
275 virtual void tr_compsof(ReferenceChain *refch, bool is_set);
276 virtual void dump(unsigned level) const;
277 };
278
279 /**
280 * ComponentsOf
281 */
282 class CT_CompsOf : public CT {
283 private:
284 Type *compsoftype;
285 bool tr_compsof_ready;
286 CTs *cts;
287 /** Copy constructor not implemented */
288 CT_CompsOf(const CT_CompsOf& p);
289 /** Assignment disabled */
290 CT_CompsOf& operator=(const CT_CompsOf& p);
291 public:
292 CT_CompsOf(Type *p_compsoftype);
293 virtual ~CT_CompsOf();
294 virtual CT_CompsOf *clone() const;
295 virtual void set_fullname(const string& p_fullname);
296 virtual void set_my_scope(Scope *p_scope);
297 virtual size_t get_nof_comps() const;
298 virtual CompField* get_comp_byIndex(size_t n) const;
299 virtual bool has_comp_withName(const Identifier& p_name) const;
300 virtual CompField* get_comp_byName(const Identifier& p_name) const;
301 virtual void tr_compsof(ReferenceChain *refch, bool is_set);
302 virtual void dump(unsigned level) const;
303 };
304
305 /** @} end of AST_Type group */
306
307 } // namespace Common
308
309 #endif // _Common_Typestuff_HH
This page took 0.041868 seconds and 5 git commands to generate.