Commit | Line | Data |
---|---|---|
d44e3c4f | 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 | * Baji, Laszlo | |
10 | * Balasko, Jeno | |
11 | * Baranyi, Botond | |
12 | * Delic, Adam | |
13 | * Kovacs, Ferenc | |
14 | * Raduly, Csaba | |
15 | * Szabados, Kristof | |
16 | * Zalanyi, Balazs Andor | |
17 | * Pandi, Krisztian | |
18 | * | |
19 | ******************************************************************************/ | |
970ed795 EL |
20 | #ifndef _Asn_AST_HH |
21 | #define _Asn_AST_HH | |
22 | ||
23 | #include "../AST.hh" | |
24 | #include "../Int.hh" | |
25 | #include "Object0.hh" | |
26 | ||
27 | namespace Common { | |
28 | class CodeGenHelper; | |
29 | } | |
30 | ||
31 | /** | |
32 | * This namespace contains things related to ASN.1 compiler. | |
33 | */ | |
34 | namespace Asn { | |
35 | ||
36 | /** | |
37 | * \addtogroup AST | |
38 | * | |
39 | * @{ | |
40 | */ | |
41 | ||
42 | class Assignments; | |
43 | /** | |
44 | * This is used when parsing internal stuff (e.g., EXTERNAL, | |
45 | * EMBEDDED PDV, etc.). | |
46 | */ | |
47 | extern Assignments *parsed_assignments; | |
48 | ||
49 | using namespace Common; | |
50 | ||
51 | struct TagDefault; | |
52 | ||
53 | class Assignment; | |
54 | class Module; | |
55 | class Symbols; | |
56 | class Exports; | |
57 | class ImpMod; | |
58 | class Imports; | |
59 | class Ass_Undef; | |
60 | class Ass_T; | |
61 | class Ass_V; | |
62 | class Ass_VS; | |
63 | class Ass_OC; | |
64 | class Ass_O; | |
65 | class Ass_OS; | |
66 | ||
67 | /* not defined, only declared in this file */ | |
68 | ||
69 | class Block; | |
70 | class TokenBuf; | |
71 | class ValueSet; | |
72 | class ObjectClass; | |
73 | class Object; | |
74 | class ObjectSet; | |
75 | ||
76 | /** | |
77 | * Struct to represent default tagging. | |
78 | */ | |
79 | struct TagDefault { | |
80 | enum tagdef_t { | |
81 | EXPLICIT, /**< EXPLICIT TAGS */ | |
82 | IMPLICIT, /**< IMPLICIT TAGS */ | |
83 | AUTOMATIC /**< AUTOMATIC TAGS */ | |
84 | }; | |
85 | }; | |
86 | ||
87 | /** | |
88 | * Helper-class for parameterized assignments. | |
89 | */ | |
90 | class Ass_pard : public Node { | |
91 | private: | |
92 | Assignment *my_ass; // link to... | |
93 | Block *parlist_block; /**< parameter list */ | |
94 | /** if the block (parlist) is pre-parsed then it is deleted, and | |
95 | * the content is put into these vectors. */ | |
96 | vector<Identifier> dummyrefs; | |
97 | /** contains one tokenbuf for each parameter; e.g. for parameter | |
98 | * "INTEGER : i" it contains "i INTEGER ::=" */ | |
99 | vector<TokenBuf> governors; | |
100 | /** Instance counters: for each target module a separate counter is | |
101 | * maintained to get deterministic instance numbers in case of incremental | |
102 | * compilation. */ | |
103 | map<Common::Module*, size_t> inst_cnts; | |
104 | ||
105 | Ass_pard(const Ass_pard& p); | |
106 | Ass_pard& operator=(const Ass_pard& p); | |
107 | /** Split the formal parameterlist */ | |
108 | void preparse_pars(); | |
109 | public: | |
110 | Ass_pard(Block *p_parlist_block); | |
111 | virtual ~Ass_pard(); | |
112 | virtual Ass_pard* clone() const | |
113 | {return new Ass_pard(*this);} | |
114 | void set_my_ass(Assignment *p_my_ass) {my_ass=p_my_ass;} | |
115 | /** Returns the number of formal parameters. 0 means the parameter | |
116 | * list is erroneous. */ | |
117 | size_t get_nof_pars(); | |
118 | const Identifier& get_nth_dummyref(size_t i); | |
119 | TokenBuf* clone_nth_governor(size_t i); | |
120 | /** Returns the next instance number for target module \a p_mod */ | |
121 | size_t new_instnum(Common::Module *p_mod); | |
122 | }; | |
123 | ||
124 | /** | |
125 | * Abstract class to represent different kinds of assignments. | |
126 | */ | |
127 | class Assignment : public Common::Assignment { | |
128 | protected: // many classes derived | |
129 | Ass_pard *ass_pard; | |
130 | bool dontgen; | |
131 | ||
132 | Assignment(const Assignment& p); | |
133 | Assignment& operator=(const Assignment& p); | |
134 | virtual string get_genname() const; | |
135 | virtual Assignment* new_instance0(); | |
136 | public: | |
137 | Assignment(asstype_t p_asstype, Identifier *p_id, Ass_pard *p_ass_pard); | |
138 | virtual ~Assignment(); | |
139 | virtual Assignment* clone() const =0; | |
140 | virtual bool is_asstype(asstype_t p_asstype, ReferenceChain* refch=0); | |
141 | virtual void set_right_scope(Scope *p_scope) =0; | |
142 | void set_dontgen() {dontgen=true;} | |
143 | /** Returns 0 if assignment is not parameterized! */ | |
af710487 | 144 | virtual Ass_pard* get_ass_pard() const { return ass_pard; } |
970ed795 EL |
145 | /** Returns 0 if this assignment is not parameterized! */ |
146 | Assignment* new_instance(Common::Module *p_mod); | |
147 | virtual Type* get_Type(); | |
148 | virtual Value* get_Value(); | |
149 | virtual ValueSet* get_ValueSet(); | |
150 | virtual ObjectClass* get_ObjectClass(); | |
151 | virtual Object* get_Object(); | |
152 | virtual ObjectSet* get_ObjectSet(); | |
153 | virtual void chk(); | |
154 | virtual void dump(unsigned level) const; | |
155 | }; | |
156 | ||
157 | /** | |
158 | * Class to store assignments. It also contains the ASN-related | |
159 | * pre-defined (so-called "useful") stuff. | |
160 | */ | |
161 | class Assignments : public Common::Assignments { | |
162 | private: | |
163 | /** Special assignments. */ | |
164 | static Module *_spec_asss; | |
165 | public: | |
166 | static void create_spec_asss(); | |
167 | static void destroy_spec_asss(); | |
168 | /** Returns whether module \a p_mod is the module that contains the | |
169 | * special assignments */ | |
170 | static bool is_spec_asss(Common::Module *p_mod); | |
171 | private: | |
172 | /** The assignments. */ | |
173 | map<string, Assignment> asss_m; | |
174 | vector<Assignment> asss_v; | |
175 | /** Indicates whether the uniqueness of identifiers has been checked. */ | |
176 | bool checked; | |
177 | ||
178 | Assignments(const Assignments&); | |
179 | public: | |
180 | /** Constructor. */ | |
181 | Assignments() : Common::Assignments(), asss_m(), asss_v(), checked(false) | |
182 | { } | |
183 | /** Destructor. */ | |
184 | virtual ~Assignments(); | |
185 | virtual Assignments* clone() const; | |
186 | /** Sets the fullname. */ | |
187 | virtual void set_fullname(const string& p_fullname); | |
188 | /** Also looks into special assignments. */ | |
189 | virtual bool has_local_ass_withId(const Identifier& p_id); | |
190 | /** Also looks into special assignments. */ | |
191 | virtual Assignment* get_local_ass_byId(const Identifier& p_id); | |
192 | virtual size_t get_nof_asss(); | |
193 | virtual Common::Assignment* get_ass_byIndex(size_t p_i); | |
194 | /** Adds the Assignment. If \a checked flag is true and the id of the new | |
195 | * assignment is not unique it reports the error. */ | |
196 | void add_ass(Assignment *p_ass); | |
197 | /** Checks the uniqueness of identifiers. */ | |
198 | void chk_uniq(); | |
199 | /** Checks all assignments. */ | |
200 | void chk(); | |
201 | /** Sets the scope for the right side of assignments. Used in | |
202 | * parametrization. There is a strange situation that the left | |
203 | * and right sides of assignments can have different parent | |
204 | * scopes. */ | |
205 | void set_right_scope(Scope *p_scope); | |
206 | void generate_code(output_struct* target); | |
207 | void generate_code(CodeGenHelper& cgh); | |
208 | void dump(unsigned level) const; | |
209 | }; | |
210 | ||
211 | /** | |
212 | * Class to represent ASN-modules. | |
213 | */ | |
214 | class Module : public Common::Module { | |
215 | private: | |
216 | /** default tagging */ | |
217 | TagDefault::tagdef_t tagdef; | |
218 | /** extensibility implied */ | |
219 | bool extens_impl; | |
220 | /** exported stuff */ | |
221 | Exports *exp; | |
222 | /** imported stuff. */ | |
223 | Imports *imp; | |
224 | /** assignments of the module */ | |
225 | Assignments *asss; | |
226 | private: | |
227 | /** Copy constructor not implemented. */ | |
228 | Module(const Module&); | |
229 | /** Assignment not implemented */ | |
230 | Module& operator=(const Module&); | |
231 | public: | |
232 | Module(Identifier *p_modid, TagDefault::tagdef_t p_tagdef, | |
233 | bool p_extens_impl, Exports *p_exp, Imports *p_imp, | |
234 | Assignments *p_asss); | |
235 | virtual ~Module(); | |
236 | virtual Module* clone() const; | |
237 | virtual Common::Assignment* importAssignment( | |
238 | const Identifier& p_source_modid, const Identifier& p_id) const; | |
239 | /** Sets the fullname. */ | |
240 | virtual void set_fullname(const string& p_fullname); | |
241 | virtual Common::Assignments* get_scope_asss(); | |
242 | virtual bool has_imported_ass_withId(const Identifier& p_id); | |
243 | /** Returns the assignment referenced by p_ref. Appends an error | |
244 | * message an returns 0 if assignment is not found. */ | |
245 | virtual Common::Assignment* get_ass_bySRef(Ref_simple *p_ref); | |
246 | virtual Assignments *get_asss(); | |
247 | virtual bool exports_sym(const Identifier& p_id); | |
248 | virtual void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack); | |
249 | virtual void chk(); | |
250 | private: | |
251 | virtual void get_imported_mods(module_set_t& p_imported_mods); | |
252 | virtual bool has_circular_import(); | |
253 | virtual void generate_code_internal(CodeGenHelper& cgh); | |
254 | public: | |
255 | virtual void dump(unsigned level) const; | |
256 | void add_ass(Assignment *p_ass); | |
257 | TagDefault::tagdef_t get_tagdef() const { return tagdef; } | |
258 | ||
af710487 | 259 | /** Generates JSON schema segments for the types defined in the modules, |
260 | * and references to these types. | |
261 | * | |
262 | * @param json JSON document containing the main schema, schema segments for | |
263 | * the types will be inserted here | |
264 | * @param json_refs map of JSON documents containing the references to each type */ | |
265 | virtual void generate_json_schema(JSON_Tokenizer& json, map<Type*, JSON_Tokenizer>& json_refs); | |
7329404e BB |
266 | |
267 | /** Does nothing. Debugger initialization functions are not generated for | |
268 | * ASN.1 modules. */ | |
269 | virtual void generate_debugger_init(output_struct *output); | |
270 | ||
271 | /** Generates the variable adding code for all global variables defined | |
272 | * in this module. This function is called by generate_debugger_init() | |
273 | * for both the current module and all imported modules. */ | |
274 | virtual char* generate_debugger_global_vars(char* str, Common::Module* current_mod); | |
275 | ||
276 | /** Generates the debugger variable printing function, which can print values | |
277 | * and templates of all types defined in this module (excluding subtypes). */ | |
278 | virtual void generate_debugger_functions(output_struct *output); | |
970ed795 EL |
279 | }; |
280 | ||
281 | /** | |
282 | * SymbolList. | |
283 | * Used only while parsing a module (and building the AST). | |
284 | */ | |
285 | class Symbols : public Node { | |
286 | friend class Exports; | |
287 | friend class ImpMod; | |
288 | friend class Imports; | |
289 | private: | |
290 | /** string => Identifier container */ | |
291 | typedef map<string, Identifier> syms_t; | |
292 | /** temporary container for symbols (no uniqueness checks) */ | |
293 | vector<Identifier> syms_v; | |
294 | /** the symbols */ | |
295 | syms_t syms_m; | |
296 | private: | |
297 | /** Copy constructor not implemented. */ | |
298 | Symbols(const Symbols&); | |
299 | /** Assignment not implemented. */ | |
300 | Symbols& operator=(const Symbols&); | |
301 | public: | |
302 | /** Default constructor. */ | |
303 | Symbols() : Node(), syms_v(), syms_m() { } | |
304 | /** Destructor. */ | |
305 | virtual ~Symbols(); | |
306 | /** Not implemented. */ | |
307 | virtual Symbols* clone() const; | |
308 | /** Adds \a p_id to the symlist. */ | |
309 | void add_sym(Identifier *p_id); | |
310 | /** Ensures uniqueness of identifiers in syms */ | |
311 | void chk_uniq(const Location& p_loc); | |
312 | }; | |
313 | ||
314 | /** | |
315 | * Exported symbols of a module. | |
316 | */ | |
317 | class Exports : public Node, public Location { | |
318 | private: | |
319 | bool checked; | |
320 | /** string => Identifier container */ | |
321 | /** my module */ | |
322 | Module *my_mod; | |
323 | /** exports all */ | |
324 | bool expall; | |
325 | /** exported symbols */ | |
326 | Symbols *symbols; | |
327 | private: | |
328 | /** Copy constructor not implemented. */ | |
329 | Exports(const Exports&); | |
330 | /** Assignment not implemented */ | |
331 | Exports& operator=(const Exports&); | |
332 | public: | |
333 | /** Constructor used when the module exports all. */ | |
334 | Exports(bool p_expall=false); | |
335 | /** Constructor used when there is a SymbolList. */ | |
336 | Exports(Symbols *p_symlist); | |
337 | /** Destructor. */ | |
338 | virtual ~Exports(); | |
339 | /** Not implemented. */ | |
340 | virtual Exports* clone() const; | |
341 | /** Sets the internal pointer to its module. */ | |
342 | void set_my_mod(Module *p_mod) {my_mod=p_mod;} | |
343 | /** Returns true if a symbol with identifier \a p_id is | |
344 | * exported. */ | |
345 | bool exports_sym(const Identifier& p_id); | |
346 | /** Checks whether the exported symbols are defined in the module. */ | |
347 | void chk_exp(); | |
348 | }; | |
349 | ||
350 | /** | |
351 | * Imported module. | |
352 | */ | |
353 | class ImpMod : public Node, public Location { | |
354 | friend class Imports; | |
355 | private: | |
356 | /** my module */ | |
357 | Module *my_mod; | |
358 | /** identifier of imported module */ | |
359 | Identifier *modid; | |
360 | /** pointer to the imported module */ | |
361 | Common::Module *mod; | |
362 | /** imported symbols */ | |
363 | Symbols *symbols; | |
364 | private: | |
365 | /** Copy constructor not implemented. */ | |
366 | ImpMod(const ImpMod&); | |
367 | /** Assignment not implemented */ | |
368 | ImpMod& operator=(const ImpMod&); | |
369 | public: | |
370 | /** Constructor. */ | |
371 | ImpMod(Identifier *p_modid, Symbols *p_symlist); | |
372 | /** Destructor. */ | |
373 | virtual ~ImpMod(); | |
374 | /** Not implemented. */ | |
375 | virtual ImpMod* clone() const; | |
376 | /** Sets the internal pointer to its module. */ | |
377 | void set_my_mod(Module *p_mod) {my_mod=p_mod;} | |
378 | /** Gets the module id of imported module. */ | |
379 | const Identifier& get_modid() const {return *modid;} | |
380 | void set_mod(Common::Module *p_mod) { mod = p_mod; } | |
381 | Common::Module *get_mod() const { return mod; } | |
382 | bool has_sym(const Identifier& p_id) const; | |
383 | /** Checks whether the imported symbols exist. Appends error | |
384 | * messages when needed. */ | |
385 | void chk_imp(ReferenceChain& refch); | |
386 | void generate_code(output_struct *target); | |
387 | }; | |
388 | ||
389 | /** | |
390 | * Imported modules. | |
391 | */ | |
392 | class Imports : public Node, public Location { | |
393 | friend class Module; | |
394 | private: | |
395 | /** my module */ | |
396 | Module *my_mod; | |
397 | /** imported modules */ | |
398 | vector<Asn::ImpMod> impmods_v; | |
399 | map<string, Asn::ImpMod> impmods; | |
400 | /** these symbols are mentioned only once in IMPORTS */ | |
401 | map<string, Common::Module> impsyms_1; | |
402 | /** these symbols are mentioned more than once in IMPORTS. This | |
403 | * map is used as a set. */ | |
404 | map<string, void> impsyms_m; | |
405 | /** Indicates whether the import list has been checked. */ | |
406 | bool checked; | |
407 | /** Indicates whether the owner module is a part of a circular import | |
408 | * chain. */ | |
409 | bool is_circular; | |
410 | private: | |
411 | /** Copy constructor not implemented. */ | |
412 | Imports(const Imports&); | |
413 | /** Assignment not implemented */ | |
414 | Imports& operator=(const Imports&); | |
415 | public: | |
416 | /** Constructor. */ | |
417 | Imports() | |
418 | : Node(), my_mod(0), impmods_v(), impmods(), impsyms_1(), impsyms_m(), | |
419 | checked(false), is_circular(false) {} | |
420 | /** Destructor. */ | |
421 | virtual ~Imports(); | |
422 | /** Not implemented. */ | |
423 | virtual Imports* clone() const; | |
424 | /** Adds the ImpMod. If a module with that id already exists, | |
425 | * throws an Error_AST_uniq exception. */ | |
426 | void add_impmod(ImpMod *p_impmod); | |
427 | /** Sets the internal pointer my_mod to \a p_mod. */ | |
428 | void set_my_mod(Module *p_mod); | |
429 | /** Recursive check. Checks whether the modules with the id exist, | |
430 | * then checks that ImpMod. */ | |
431 | void chk_imp(ReferenceChain& refch); | |
432 | /** Returns whether symbols from module with identifier \a p_id | |
433 | * are imported. */ | |
434 | bool has_impmod_withId(const Identifier& p_id) const | |
435 | { return impmods.has_key(p_id.get_name()); } | |
436 | const ImpMod *get_impmod_byId(const Identifier& p_id) const | |
437 | { return impmods[p_id.get_name()]; } | |
438 | /** Returns whether a symbol with identifier \a p_id is imported from one | |
439 | * or more modules */ | |
440 | bool has_impsym_withId(const Identifier& p_id) const; | |
441 | void get_imported_mods(Module::module_set_t& p_imported_mods); | |
442 | bool get_is_circular() const { return is_circular; } | |
443 | void generate_code(output_struct *target); | |
444 | }; | |
445 | ||
446 | /** | |
447 | * Undefined assignment. | |
448 | */ | |
449 | class Ass_Undef : public Assignment { | |
450 | private: | |
451 | Node *left, *right; | |
452 | Scope *right_scope; | |
453 | /** the classified assignment */ | |
454 | Assignment *ass; | |
455 | ||
456 | void classify_ass(ReferenceChain *refch=0); | |
457 | virtual Assignment* new_instance0(); | |
458 | Ass_Undef(const Ass_Undef& p); | |
459 | /// Assignment disabled | |
460 | Ass_Undef& operator=(const Ass_Undef& p); | |
461 | public: | |
462 | Ass_Undef(Identifier *p_id, Ass_pard *p_ass_pard, | |
463 | Node *p_left, Node *p_right); | |
464 | virtual ~Ass_Undef(); | |
465 | virtual Assignment* clone() const; | |
466 | virtual asstype_t get_asstype() const; | |
467 | virtual void set_fullname(const string& p_fullname); | |
468 | virtual void set_my_scope(Scope *p_scope); | |
469 | virtual void set_right_scope(Scope *p_scope); | |
470 | virtual bool is_asstype(asstype_t p_asstype, ReferenceChain* refch=0); | |
af710487 | 471 | virtual Ass_pard* get_ass_pard() const; |
970ed795 EL |
472 | virtual Setting* get_Setting(); |
473 | virtual Type* get_Type(); | |
474 | virtual Value* get_Value(); | |
475 | virtual ValueSet* get_ValueSet(); | |
476 | virtual ObjectClass* get_ObjectClass(); | |
477 | virtual Object* get_Object(); | |
478 | virtual ObjectSet* get_ObjectSet(); | |
479 | virtual void chk(); | |
480 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
481 | virtual void generate_code(CodeGenHelper& cgh); | |
482 | virtual void dump(unsigned level) const; | |
483 | private: | |
484 | bool _error_if_pard(); | |
485 | }; | |
486 | ||
487 | /** | |
488 | * Erroneous assignment. | |
489 | */ | |
490 | class Ass_Error : public Assignment { | |
491 | private: | |
492 | Setting *setting_error; | |
493 | Type *type_error; | |
494 | Value *value_error; | |
495 | ||
496 | /// Copy constructor not implemented (even though clone works) | |
497 | Ass_Error(const Ass_Error& p); | |
498 | /// Assignment disabled | |
499 | Ass_Error& operator=(const Ass_Error& p); | |
500 | virtual Assignment* new_instance0(); | |
501 | public: | |
502 | Ass_Error(Identifier *p_id, Ass_pard *p_ass_pard); | |
503 | virtual ~Ass_Error(); | |
504 | virtual Assignment* clone() const; | |
505 | virtual bool is_asstype(asstype_t p_asstype, ReferenceChain* refch=0); | |
506 | virtual void set_right_scope(Scope *) {} | |
507 | virtual Setting* get_Setting(); | |
508 | virtual Type* get_Type(); | |
509 | virtual Value* get_Value(); | |
510 | virtual ValueSet* get_ValueSet(); | |
511 | virtual ObjectClass* get_ObjectClass(); | |
512 | virtual Object* get_Object(); | |
513 | virtual ObjectSet* get_ObjectSet(); | |
514 | virtual void chk(); | |
515 | virtual void dump(unsigned level) const; | |
516 | }; | |
517 | ||
518 | /** | |
519 | * Type assignment. | |
520 | */ | |
521 | class Ass_T : public Assignment { | |
522 | private: | |
523 | Type *right; | |
524 | ||
525 | virtual Assignment* new_instance0(); | |
526 | /// Copy constructor for clone() only | |
527 | Ass_T(const Ass_T& p); | |
528 | /// Assignment disabled | |
529 | Ass_T& operator=(const Ass_T& p); | |
530 | public: | |
531 | Ass_T(Identifier *p_id, Ass_pard *p_ass_pard, Type *p_right); | |
532 | virtual ~Ass_T(); | |
533 | virtual Ass_T* clone() const | |
534 | {return new Ass_T(*this);} | |
535 | virtual void set_fullname(const string& p_fullname); | |
536 | virtual void set_my_scope(Scope *p_scope); | |
537 | virtual void set_right_scope(Scope *p_scope); | |
538 | virtual Setting* get_Setting() {return get_Type();} | |
539 | virtual Type* get_Type(); | |
540 | virtual void chk(); | |
541 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
542 | virtual void generate_code(CodeGenHelper& cgh); | |
543 | virtual void dump(unsigned level) const; | |
544 | }; | |
545 | ||
546 | /** | |
547 | * Value assignment. | |
548 | */ | |
549 | class Ass_V : public Assignment { | |
550 | private: | |
551 | Type *left; | |
552 | Value *right; | |
553 | ||
554 | virtual Assignment* new_instance0(); | |
555 | /// Copy constructor for clone() only | |
556 | Ass_V(const Ass_V& p); | |
557 | /// Assignment disabled | |
558 | Ass_V& operator=(const Ass_V& p); | |
559 | public: | |
560 | Ass_V(Identifier *p_id, Ass_pard *p_ass_pard, | |
561 | Type *p_left, Value *p_right); | |
562 | virtual ~Ass_V(); | |
563 | virtual Ass_V* clone() const | |
564 | {return new Ass_V(*this);} | |
565 | virtual void set_fullname(const string& p_fullname); | |
566 | virtual void set_my_scope(Scope *p_scope); | |
567 | virtual void set_right_scope(Scope *p_scope); | |
568 | virtual Setting* get_Setting() {return get_Value();} | |
569 | virtual Type* get_Type(); | |
570 | virtual Value* get_Value(); | |
571 | virtual void chk(); | |
572 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
573 | virtual void generate_code(CodeGenHelper& cgh); | |
574 | virtual void dump(unsigned level) const; | |
575 | }; | |
576 | ||
577 | /** | |
578 | * ValueSet assignment. | |
579 | */ | |
580 | class Ass_VS : public Assignment { | |
581 | private: | |
582 | Type *left; | |
583 | Block *right; | |
584 | Scope *right_scope; | |
585 | ||
586 | virtual Assignment* new_instance0(); | |
587 | /// Copy constructor for clone() only | |
588 | Ass_VS(const Ass_VS& p); | |
589 | /// Assignment disabled | |
590 | Ass_VS& operator=(const Ass_VS& p); | |
591 | public: | |
592 | Ass_VS(Identifier *p_id, Ass_pard *p_ass_pard, | |
593 | Type *p_left, Block *p_right); | |
594 | virtual ~Ass_VS(); | |
595 | virtual Ass_VS* clone() const | |
596 | {return new Ass_VS(*this);} | |
597 | virtual void set_fullname(const string& p_fullname); | |
598 | virtual void set_my_scope(Scope *p_scope); | |
599 | virtual void set_right_scope(Scope *p_scope); | |
600 | virtual Setting* get_Setting() {return get_Type();} | |
601 | virtual Type* get_Type(); | |
602 | virtual void chk(); | |
603 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
604 | virtual void generate_code(CodeGenHelper& cgh); | |
605 | virtual void dump(unsigned level) const; | |
606 | }; | |
607 | ||
608 | /** | |
609 | * ObjectClass assignment. | |
610 | */ | |
611 | class Ass_OC : public Assignment { | |
612 | private: | |
613 | ObjectClass *right; | |
614 | ||
615 | virtual Assignment* new_instance0(); | |
616 | /// Copy constructor for clone() only | |
617 | Ass_OC(const Ass_OC& p); | |
618 | /// Assignment disabled | |
619 | Ass_OC& operator=(const Ass_OC& p); | |
620 | public: | |
621 | Ass_OC(Identifier *p_id, Ass_pard *p_ass_pard, ObjectClass *p_right); | |
622 | virtual ~Ass_OC(); | |
623 | virtual Ass_OC* clone() const | |
624 | {return new Ass_OC(*this);} | |
625 | virtual void set_fullname(const string& p_fullname); | |
626 | virtual void set_my_scope(Scope *p_scope); | |
627 | virtual void set_right_scope(Scope *p_scope); | |
628 | virtual void chk(); | |
629 | virtual Setting* get_Setting() {return get_ObjectClass();} | |
630 | virtual ObjectClass* get_ObjectClass(); | |
631 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
632 | virtual void generate_code(CodeGenHelper& cgh); | |
633 | virtual void dump(unsigned level) const; | |
634 | }; | |
635 | ||
636 | /** | |
637 | * Object assignment. | |
638 | */ | |
639 | class Ass_O : public Assignment { | |
640 | private: | |
641 | ObjectClass *left; | |
642 | Object *right; | |
643 | ||
644 | virtual Assignment* new_instance0(); | |
645 | /// Copy constructor for clone() only | |
646 | Ass_O(const Ass_O& p); | |
647 | /// Assignment disabled | |
648 | Ass_O& operator=(const Ass_O& p); | |
649 | public: | |
650 | Ass_O(Identifier *p_id, Ass_pard *p_ass_pard, | |
651 | ObjectClass *p_left, Object *p_right); | |
652 | virtual ~Ass_O(); | |
653 | virtual Ass_O* clone() const | |
654 | {return new Ass_O(*this);} | |
655 | virtual void set_fullname(const string& p_fullname); | |
656 | virtual void set_my_scope(Scope *p_scope); | |
657 | virtual void set_right_scope(Scope *p_scope); | |
658 | virtual Setting* get_Setting() {return get_Object();} | |
659 | //virtual ObjectClass* get_ObjectClass(); | |
660 | virtual Object* get_Object(); | |
661 | virtual void chk(); | |
662 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
663 | virtual void generate_code(CodeGenHelper& cgh); | |
664 | virtual void dump(unsigned level) const; | |
665 | }; | |
666 | ||
667 | /** | |
668 | * ObjectSet assignment. | |
669 | */ | |
670 | class Ass_OS : public Assignment { | |
671 | private: | |
672 | ObjectClass *left; | |
673 | ObjectSet *right; | |
674 | ||
675 | virtual Assignment* new_instance0(); | |
676 | /// Copy constructor for clone() only | |
677 | Ass_OS(const Ass_OS& p); | |
678 | /// Assignment disabled | |
679 | Ass_OS& operator=(const Ass_OS& p); | |
680 | public: | |
681 | Ass_OS(Identifier *p_id, Ass_pard *p_ass_pard, | |
682 | ObjectClass *p_left, ObjectSet *p_right); | |
683 | virtual ~Ass_OS(); | |
684 | virtual Ass_OS* clone() const | |
685 | {return new Ass_OS(*this);} | |
686 | virtual void set_fullname(const string& p_fullname); | |
687 | virtual void set_my_scope(Scope *p_scope); | |
688 | virtual void set_right_scope(Scope *p_scope); | |
689 | virtual Setting* get_Setting() {return get_ObjectSet();} | |
690 | //virtual ObjectClass* get_ObjectClass(); | |
691 | virtual ObjectSet* get_ObjectSet(); | |
692 | virtual void chk(); | |
693 | virtual void generate_code(output_struct *target, bool clean_up = false); | |
694 | virtual void generate_code(CodeGenHelper& cgh); | |
695 | virtual void dump(unsigned level) const; | |
696 | }; | |
697 | ||
698 | /** @} end of AST group */ | |
699 | ||
700 | } // namespace Asn | |
701 | ||
702 | #endif // _Asn_AST_HH |