Titan Core Initial Contribution
[deliverable/titan.core.git] / compiler2 / asn1 / Object.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 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 #ifndef _Asn_Object_HH
9 #define _Asn_Object_HH
10
11 #include "Object0.hh"
12 #include "../Type.hh"
13 #include "../Value.hh"
14 #include "../Code.hh"
15
16 namespace Asn {
17
18 using namespace Common;
19
20 class OC_defn;
21 class OC_refd;
22 class FieldSpec;
23 class FieldSpec_Undef;
24 class FieldSpec_Error;
25 class FieldSpec_T;
26 class FieldSpec_V_FT;
27 /*
28 class FieldSpec_V_VT;
29 class FieldSpec_VS_FT;
30 class FieldSpec_VS_VT;
31 */
32 class FieldSpec_O;
33 class FieldSpec_OS;
34
35 class FieldSpecs;
36
37 class OCS_Visitor;
38 class OCS_Node;
39 class OCS_seq;
40 class OCS_root;
41 class OCS_literal;
42 class OCS_setting;
43
44 class FieldSetting;
45 class FieldSetting_Type;
46 class FieldSetting_Value;
47 class FieldSetting_O;
48 class FieldSetting_OS;
49 class Obj_defn;
50 class Obj_refd;
51
52 class Objects;
53 class OSE_Visitor; // in Object0.hh
54 class OS_defn;
55 class OS_refd;
56
57 // not defined here
58 class Block;
59
60 /**
61 * Class to represent ObjectClassDefinition
62 */
63 class OC_defn : public ObjectClass {
64 private:
65 Block *block_fs; /**< field specs block */
66 Block *block_ws; /**< WITH SYNTAX block */
67 FieldSpecs *fss; /**< field specs */
68 OCS_root *ocs; /**< object class syntax */
69 bool is_erroneous;
70 bool is_generated;
71
72 OC_defn(const OC_defn& p);
73 public:
74 OC_defn();
75 OC_defn(Block *p_block_fs, Block *p_block_ws);
76 virtual ~OC_defn();
77 virtual OC_defn* clone() const {return new OC_defn(*this);}
78 virtual void set_fullname(const string& p_fullname);
79 virtual OC_defn* get_refd_last(ReferenceChain * =0) {return this;}
80 virtual void chk();
81 virtual void chk_this_obj(Object *obj);
82 virtual OCS_root* get_ocs();
83 virtual FieldSpecs* get_fss();
84 virtual void generate_code(output_struct *target);
85 virtual void dump(unsigned level) const;
86 private:
87 void parse_block_fs();
88 };
89
90 /**
91 * Class to represent a ReferencedObjectClass. It is a DefinedOC or
92 * OCFromObject or ValueSetFromObjects.
93 */
94 class OC_refd : public ObjectClass {
95 private:
96 Reference *ref;
97 OC_defn *oc_error;
98 ObjectClass *oc_refd; /**< cache */
99 OC_defn *oc_defn; /**< cache */
100
101 OC_refd(const OC_refd& p);
102 public:
103 OC_refd(Reference *p_ref);
104 virtual ~OC_refd();
105 virtual OC_refd* clone() const {return new OC_refd(*this);}
106 virtual void set_my_scope(Scope *p_scope);
107 virtual void set_fullname(const string& p_fullname);
108 ObjectClass* get_refd(ReferenceChain *refch=0);
109 virtual OC_defn* get_refd_last(ReferenceChain *refch=0);
110 virtual void chk();
111 virtual void chk_this_obj(Object *p_obj);
112 virtual OCS_root* get_ocs();
113 virtual FieldSpecs* get_fss();
114 virtual void generate_code(output_struct *target);
115 virtual void dump(unsigned level) const;
116 };
117
118 /**
119 * Class to represent a FieldSpec of an ObjectClass.
120 */
121 class FieldSpec : public Node, public Location {
122 public:
123 enum fstype_t {
124 FS_UNDEF, /**< undefined */
125 FS_ERROR, /**< erroneous fieldspec */
126 FS_T, /**< type fieldspec */
127 FS_V_FT, /**< fixedtype value fieldspec */
128 FS_V_VT, /**< variabletype value fieldspec */
129 FS_VS_FT, /**< fixedtype valueset fieldspec */
130 FS_VS_VT, /**< variabletype valueset fieldspec */
131 FS_O, /**< object fieldspec */
132 FS_OS /**< objectset fieldspec */
133 };
134 protected: // Several derived classes need access
135 fstype_t fstype;
136 Identifier *id;
137 bool is_optional;
138 OC_defn *my_oc;
139 bool checked;
140
141 FieldSpec(const FieldSpec& p);
142 public:
143 FieldSpec(fstype_t p_fstype, Identifier *p_id, bool p_is_optional);
144 virtual ~FieldSpec();
145 virtual FieldSpec* clone() const =0;
146 virtual void set_fullname(const string& p_fullname);
147 virtual const Identifier& get_id() const {return *id;}
148 virtual fstype_t get_fstype() {return fstype;}
149 virtual void set_my_oc(OC_defn *p_oc);
150 bool get_is_optional() {return is_optional;}
151 virtual bool has_default() =0;
152 virtual void chk() =0;
153 virtual Setting* get_default() =0;
154 virtual FieldSpec* get_last() {return this;}
155 virtual void generate_code(output_struct *target) =0;
156 };
157
158 /**
159 * Class to represent an undefined FieldSpec.
160 */
161 class FieldSpec_Undef : public FieldSpec {
162 private:
163 Ref_defd* govref;
164 Node* defsetting; /**< default setting */
165 FieldSpec *fs; /**< the classified fieldspec */
166
167 void classify_fs(ReferenceChain *refch=0);
168 FieldSpec_Undef(const FieldSpec_Undef& p);
169 public:
170 FieldSpec_Undef(Identifier *p_id, Ref_defd* p_govref,
171 bool p_is_optional, Node *p_defsetting);
172 virtual ~FieldSpec_Undef();
173 virtual FieldSpec* clone() const;
174 virtual void set_fullname(const string& p_fullname);
175 virtual fstype_t get_fstype();
176 virtual void set_my_oc(OC_defn *p_oc);
177 virtual bool has_default();
178 virtual void chk();
179 virtual Setting* get_default();
180 virtual FieldSpec* get_last();
181 virtual void generate_code(output_struct *target);
182 };
183
184 class FieldSpec_Error : public FieldSpec {
185 private:
186 Setting *setting_error;
187 bool has_default_flag;
188
189 FieldSpec_Error(const FieldSpec_Error& p);
190 public:
191 FieldSpec_Error(Identifier *p_id, bool p_is_optional,
192 bool p_has_default);
193 virtual ~FieldSpec_Error();
194 virtual FieldSpec_Error* clone() const;
195 virtual bool has_default();
196 virtual Setting* get_default();
197 virtual void chk();
198 virtual void generate_code(output_struct *target);
199 };
200
201 /**
202 * Class to represent a TypeFieldSpec.
203 */
204 class FieldSpec_T : public FieldSpec {
205 private:
206 Type *deftype; /**< default type */
207
208 FieldSpec_T(const FieldSpec_T& p);
209 public:
210 FieldSpec_T(Identifier *p_id, bool p_is_optional, Type *p_deftype);
211 virtual ~FieldSpec_T();
212 virtual FieldSpec_T* clone() const
213 {return new FieldSpec_T(*this);}
214 virtual void set_fullname(const string& p_fullname);
215 virtual void set_my_oc(OC_defn *p_oc);
216 virtual bool has_default() {return deftype;}
217 virtual Type* get_default();
218 virtual void chk();
219 virtual void generate_code(output_struct *target);
220 };
221
222 /**
223 * Class to represent a FixedTypeValueFieldSpec.
224 */
225 class FieldSpec_V_FT : public FieldSpec {
226 private:
227 Type *fixtype; /**< fixed type */
228 bool is_unique;
229 Value *defval; /**< default value */
230
231 FieldSpec_V_FT(const FieldSpec_V_FT& p);
232 public:
233 FieldSpec_V_FT(Identifier *p_id, Type *p_fixtype, bool p_is_unique,
234 bool p_is_optional, Value *p_defval);
235 virtual ~FieldSpec_V_FT();
236 virtual FieldSpec_V_FT* clone() const
237 {return new FieldSpec_V_FT(*this);}
238 virtual void set_fullname(const string& p_fullname);
239 virtual void set_my_oc(OC_defn *p_oc);
240 virtual bool has_default() {return defval;}
241 virtual Value* get_default();
242 Type* get_type() {return fixtype;}
243 virtual void chk();
244 virtual void generate_code(output_struct *target);
245 };
246
247 /*
248
249 / **
250 * Class to represent a VariableTypeValueFieldSpec.
251 * /
252 class FieldSpec_V_VT : public FieldSpec {
253 };
254
255 / **
256 * Class to represent a FixedTypeValueSetFieldSpec.
257 * /
258 class FieldSpec_VS_FT : public FieldSpec {
259 };
260
261 / **
262 * Class to represent a VariableTypeValueSetFieldSpec.
263 * /
264 class FieldSpec_VS_VT : public FieldSpec {
265 };
266
267 */
268
269 /**
270 * Class to represent an ObjectFieldSpec.
271 */
272 class FieldSpec_O : public FieldSpec {
273 private:
274 ObjectClass *oc;
275 Object *defobj; /**< default object */
276
277 FieldSpec_O(const FieldSpec_O& p);
278 public:
279 FieldSpec_O(Identifier *p_id, ObjectClass *p_oc,
280 bool p_is_optional, Object *p_defobj);
281 virtual ~FieldSpec_O();
282 virtual FieldSpec_O* clone() const
283 {return new FieldSpec_O(*this);}
284 virtual void set_fullname(const string& p_fullname);
285 virtual void set_my_oc(OC_defn *p_oc);
286 virtual bool has_default() {return defobj;}
287 virtual Object* get_default() {return defobj;}
288 ObjectClass* get_oc() {return oc;}
289 virtual void chk();
290 virtual void generate_code(output_struct *target);
291 };
292
293 /**
294 * Class to represent an ObjectSetFieldSpec.
295 */
296 class FieldSpec_OS : public FieldSpec {
297 private:
298 ObjectClass *oc;
299 ObjectSet *defobjset; /**< default objectset */
300
301 FieldSpec_OS(const FieldSpec_OS& p);
302 public:
303 FieldSpec_OS(Identifier *p_id, ObjectClass *p_oc,
304 bool p_is_optional, ObjectSet *p_defobjset);
305 virtual ~FieldSpec_OS();
306 virtual FieldSpec_OS* clone() const
307 {return new FieldSpec_OS(*this);}
308 virtual void set_fullname(const string& p_fullname);
309 virtual void set_my_oc(OC_defn *p_oc);
310 virtual bool has_default() {return defobjset;}
311 virtual ObjectSet* get_default() {return defobjset;}
312 ObjectClass* get_oc() {return oc;}
313 virtual void chk();
314 virtual void generate_code(output_struct *target);
315 };
316
317 /**
318 * Class to represent FieldSpecs.
319 */
320 class FieldSpecs : public Node {
321 private:
322 map<string, FieldSpec> fss; /**< the FieldSpecs */
323 vector<FieldSpec> fss_v;
324 FieldSpec_Error *fs_error;
325 OC_defn *my_oc;
326
327 FieldSpecs(const FieldSpecs& p);
328 public:
329 FieldSpecs();
330 virtual ~FieldSpecs();
331 virtual FieldSpecs* clone() const
332 {return new FieldSpecs(*this);}
333 virtual void set_fullname(const string& p_fullname);
334 void set_my_oc(OC_defn *p_oc);
335 void add_fs(FieldSpec *p_fs);
336 bool has_fs_withId(const Identifier& p_id);
337 FieldSpec* get_fs_byId(const Identifier& p_id);
338 FieldSpec* get_fs_byIndex(size_t p_i);
339 FieldSpec* get_fs_error();
340 size_t get_nof_fss() {return fss.size();}
341 void chk();
342 void generate_code(output_struct *target);
343 virtual void dump(unsigned level) const;
344 };
345
346 /**
347 * Abstract class for OCS visitors.
348 */
349 class OCS_Visitor : public Node {
350 private:
351 OCS_Visitor(const OCS_Visitor& p);
352 public:
353 OCS_Visitor() : Node() {}
354 virtual OCS_Visitor* clone() const;
355 virtual void visit_root(OCS_root& p) =0;
356 virtual void visit_seq(OCS_seq& p) =0;
357 virtual void visit_literal(OCS_literal& p) =0;
358 virtual void visit_setting(OCS_setting& p) =0;
359 };
360
361 /**
362 * ObjectClass Syntax. Class to build, manage, ... ObjectClass
363 * Syntax.
364 */
365 class OCS_Node : public Node, public Location {
366 private:
367 bool is_builded;
368
369 /// Copy constructor disabled.
370 OCS_Node(const OCS_Node& p);
371 /// Assignment disabled.
372 OCS_Node& operator=(const OCS_Node& p);
373 public:
374 OCS_Node() : Location(), is_builded(false) {}
375 virtual OCS_Node* clone() const;
376 virtual void accept(OCS_Visitor& v) =0;
377 bool get_is_builded() {return is_builded;}
378 void set_is_builded() {is_builded=true;}
379 virtual string get_dispname() const =0;
380 virtual void dump(unsigned level) const;
381 };
382
383 /**
384 * Class to represent a (perhaps optional) sequence of OCS_Nodes.
385 */
386 class OCS_seq : public OCS_Node {
387 private:
388 vector<OCS_Node> ocss;
389 bool is_opt;
390 /** This is used when default syntax is active. Then, if there is
391 * at least one parsed setting in the object, then the seq must
392 * begin with a comma (','). */
393 bool opt_first_comma;
394
395 /// Copy constructor disabled.
396 OCS_seq(const OCS_seq& p);
397 /// Assignment disabled.
398 OCS_seq& operator=(const OCS_seq& p);
399 public:
400 OCS_seq(bool p_is_opt, bool p_opt_first_comma=false)
401 : OCS_Node(), is_opt(p_is_opt), opt_first_comma(p_opt_first_comma) {}
402 virtual ~OCS_seq();
403 virtual void accept(OCS_Visitor& v)
404 {v.visit_seq(*this);}
405 void add_node(OCS_Node *p_node);
406 size_t get_nof_nodes() {return ocss.size();}
407 OCS_Node* get_nth_node(size_t p_i);
408 bool get_is_opt() {return is_opt;}
409 bool get_opt_first_comma() {return opt_first_comma;}
410 virtual string get_dispname() const;
411 virtual void dump(unsigned level) const;
412 };
413
414 /**
415 * Class to represent the root of an OCS.
416 */
417 class OCS_root : public OCS_Node {
418 private:
419 OCS_seq seq;
420
421 /// Copy constructor disabled.
422 OCS_root(const OCS_root& p);
423 /// Assignment disabled.
424 OCS_root& operator=(const OCS_root& p);
425 public:
426 OCS_root() : OCS_Node(), seq(false) {}
427 virtual void accept(OCS_Visitor& v)
428 {v.visit_root(*this);}
429 OCS_seq& get_seq() {return seq;}
430 virtual string get_dispname() const;
431 virtual void dump(unsigned level) const;
432 };
433
434 /**
435 * Class to represent a literal element in an OCS.
436 */
437 class OCS_literal : public OCS_Node {
438 private:
439 Identifier *word;
440 int keyword;
441
442 /// Copy constructor disabled.
443 OCS_literal(const OCS_literal& p);
444 /// Assignment disabled.
445 OCS_literal& operator=(const OCS_literal& p);
446 public:
447 OCS_literal(int p_keyword) : OCS_Node(), word(0), keyword(p_keyword) {}
448 OCS_literal(Identifier *p_word);
449 virtual ~OCS_literal();
450 virtual void accept(OCS_Visitor& v)
451 {v.visit_literal(*this);}
452 bool is_keyword() {return !word;}
453 int get_keyword() {return keyword;}
454 Identifier* get_word() {return word;}
455 virtual string get_dispname() const;
456 virtual void dump(unsigned level) const;
457 };
458
459 /**
460 * Class to represent a Setting in the OCS.
461 */
462 class OCS_setting : public OCS_Node {
463 public:
464 enum settingtype_t {
465 S_UNDEF, /**< undefined */
466 S_T, /**< Type */
467 S_V, /**< Value */
468 S_VS, /**< ValueSet */
469 S_O, /**< Object */
470 S_OS /**< ObjectSet */
471 };
472 private:
473 settingtype_t st;
474 Identifier *id;
475
476 /// Copy constructor disabled.
477 OCS_setting(const OCS_setting& p);
478 /// Assignment disabled.
479 OCS_setting& operator=(const OCS_setting& p);
480 public:
481 OCS_setting(settingtype_t p_st, Identifier *p_id);
482 virtual ~OCS_setting();
483 virtual void accept(OCS_Visitor& v)
484 {v.visit_setting(*this);}
485 settingtype_t get_st() {return st;}
486 Identifier* get_id() {return id;}
487 virtual string get_dispname() const;
488 virtual void dump(unsigned level) const;
489 };
490
491 /**
492 * Class to represent FieldSettings.
493 */
494 class FieldSetting : public Node, public Location {
495 protected: // Several derived classes need access
496 Identifier *name;
497 bool checked;
498
499 FieldSetting(const FieldSetting& p);
500 public:
501 FieldSetting(Identifier *p_name);
502 virtual ~FieldSetting();
503 virtual FieldSetting* clone() const =0;
504 virtual void set_fullname(const string& p_fullname);
505 Identifier& get_name() {return *name;}
506 virtual Setting* get_setting() =0;
507 void set_my_scope(Scope *p_scope);
508 void set_genname(const string& p_prefix,
509 const string& p_suffix);
510 virtual void chk(FieldSpec *p_fspec) =0;
511 virtual void generate_code(output_struct *target) =0;
512 virtual void dump(unsigned level) const =0;
513 };
514
515 /**
516 * Class to represent type FieldSettings.
517 */
518 class FieldSetting_Type : public FieldSetting {
519 private:
520 Type *setting;
521
522 FieldSetting_Type(const FieldSetting_Type& p);
523 public:
524 FieldSetting_Type(Identifier *p_name, Type *p_setting);
525 virtual ~FieldSetting_Type();
526 virtual FieldSetting_Type* clone() const
527 {return new FieldSetting_Type(*this);}
528 virtual Type* get_setting() {return setting;}
529 virtual void chk(FieldSpec *p_fspec);
530 virtual void generate_code(output_struct *target);
531 virtual void dump(unsigned level) const;
532 };
533
534 /**
535 * Class to represent value FieldSettings.
536 */
537 class FieldSetting_Value : public FieldSetting {
538 private:
539 Value *setting;
540
541 FieldSetting_Value(const FieldSetting_Value& p);
542 public:
543 FieldSetting_Value(Identifier *p_name, Value *p_setting);
544 virtual ~FieldSetting_Value();
545 virtual FieldSetting_Value* clone() const
546 {return new FieldSetting_Value(*this);}
547 virtual Value* get_setting() {return setting;}
548 virtual void chk(FieldSpec *p_fspec);
549 virtual void generate_code(output_struct *target);
550 virtual void dump(unsigned level) const;
551 };
552
553 /**
554 * Class to represent object FieldSettings.
555 */
556 class FieldSetting_O : public FieldSetting {
557 private:
558 Object *setting;
559
560 FieldSetting_O(const FieldSetting_O& p);
561 public:
562 FieldSetting_O(Identifier *p_name, Object *p_setting);
563 virtual ~FieldSetting_O();
564 virtual FieldSetting_O* clone() const
565 {return new FieldSetting_O(*this);}
566 virtual Object* get_setting() {return setting;}
567 virtual void chk(FieldSpec *p_fspec);
568 virtual void generate_code(output_struct *target);
569 virtual void dump(unsigned level) const;
570 };
571
572 /**
573 * Class to represent objectset FieldSettings.
574 */
575 class FieldSetting_OS : public FieldSetting {
576 private:
577 ObjectSet *setting;
578
579 FieldSetting_OS(const FieldSetting_OS& p);
580 public:
581 FieldSetting_OS(Identifier *p_name, ObjectSet *p_setting);
582 virtual ~FieldSetting_OS();
583 virtual FieldSetting_OS* clone() const
584 {return new FieldSetting_OS(*this);}
585 virtual ObjectSet* get_setting() {return setting;}
586 virtual void chk(FieldSpec *p_fspec);
587 virtual void generate_code(output_struct *target);
588 virtual void dump(unsigned level) const;
589 };
590
591 /**
592 * Class to represent ObjectDefinition.
593 */
594 class Obj_defn : public Object {
595 private:
596 Block *block;
597 map<string, FieldSetting> fss; /**< FieldSettings */
598 bool is_generated;
599
600 Obj_defn(const Obj_defn& p);
601 public:
602 Obj_defn(Block *p_block);
603 Obj_defn();
604 virtual ~Obj_defn();
605 virtual Obj_defn* clone() const {return new Obj_defn(*this);}
606 virtual void set_fullname(const string& p_fullname);
607 virtual void set_my_scope(Scope *p_scope);
608 virtual Obj_defn* get_refd_last(ReferenceChain * =0) {return this;}
609 virtual void chk();
610 void add_fs(FieldSetting *p_fs);
611 virtual size_t get_nof_fss() {return fss.size();}
612 virtual bool has_fs_withName(const Identifier& p_name);
613 virtual FieldSetting* get_fs_byName(const Identifier& p_name);
614 virtual bool has_fs_withName_dflt(const Identifier& p_name);
615 /** Returns the setting (or default if absent) */
616 virtual Setting* get_setting_byName_dflt(const Identifier& p_name);
617 virtual void generate_code(output_struct *target);
618 virtual void dump(unsigned level) const;
619 private:
620 void parse_block();
621 };
622
623 /**
624 * Class to represent a ReferencedObject. It is a DefinedObject or
625 * ObjectFromObject.
626 */
627 class Obj_refd : public Object {
628 private:
629 Reference *ref;
630 Obj_defn *o_error;
631 Object *o_refd; /**< cache */
632 Obj_defn *o_defn; /**< cache */
633
634 Obj_refd(const Obj_refd& p);
635 public:
636 Obj_refd(Reference *p_ref);
637 virtual ~Obj_refd();
638 virtual Obj_refd* clone() const {return new Obj_refd(*this);}
639 virtual void set_my_scope(Scope *p_scope);
640 virtual void set_fullname(const string& p_fullname);
641 Object* get_refd(ReferenceChain *refch=0);
642 virtual Obj_defn* get_refd_last(ReferenceChain *refch=0);
643 virtual void chk();
644 virtual void generate_code(output_struct *target);
645 virtual void dump(unsigned level) const;
646 };
647
648 /**
649 * ObjectSet elements (flat container). Warning: the objects are not
650 * owned by Objects, it stores only the pointers...
651 */
652 class Objects : public Node {
653 private:
654 vector<Obj_defn> objs;
655
656 Objects(const Objects&);
657 public:
658 Objects() : Node() {}
659 virtual ~Objects();
660 virtual Objects* clone() const {return new Objects(*this);}
661 void add_o(Obj_defn *p_o) {objs.add(p_o);}
662 void add_objs(Objects *p_objs);
663 size_t get_nof_objs() const {return objs.size();}
664 Obj_defn* get_obj_byIndex(size_t p_i) {return objs[p_i];}
665 virtual void dump(unsigned level) const;
666 };
667
668 /**
669 * ObjectSetElement Visitor, checker.
670 */
671 class OSEV_checker : public OSE_Visitor {
672 private:
673 ObjectClass *governor;
674 OC_defn *gov_defn;
675
676 public:
677 OSEV_checker(const Location *p_loc, ObjectClass *p_governor);
678 virtual void visit_Object(Object& p);
679 virtual void visit_OS_refd(OS_refd& p);
680 };
681
682 /**
683 * ObjectSetElement Visitor, object collector.
684 */
685 class OSEV_objcollctr : public OSE_Visitor {
686 private:
687 OC_defn *governor;
688 map<void*, void> visdes; /**< visited elements */
689 Objects *objs;
690
691 public:
692 OSEV_objcollctr(ObjectSet& parent);
693 OSEV_objcollctr(const Location *p_loc, ObjectClass *p_governor);
694 virtual ~OSEV_objcollctr();
695 virtual void visit_Object(Object& p);
696 virtual void visit_OS_refd(OS_refd& p);
697 void visit_ObjectSet(ObjectSet& p, bool force=false);
698 Objects* get_objs() {return objs;}
699 Objects* give_objs();
700 };
701
702 /**
703 * ObjectSetElement Visitor, code generator.
704 */
705 class OSEV_codegen : public OSE_Visitor {
706 private:
707 output_struct *target;
708 public:
709 OSEV_codegen(const Location *p_loc, output_struct *p_target)
710 : OSE_Visitor(p_loc), target(p_target) {}
711 virtual void visit_Object(Object& p);
712 virtual void visit_OS_refd(OS_refd& p);
713 };
714
715 /**
716 * ObjectSet definition.
717 */
718 class OS_defn : public ObjectSet {
719 private:
720 Block *block;
721 vector<OS_Element> *oses;
722 Objects *objs;
723 bool is_generated;
724
725 OS_defn(const OS_defn& p);
726 public:
727 OS_defn();
728 OS_defn(Block *p_block);
729 OS_defn(Objects *p_objs);
730 virtual ~OS_defn();
731 virtual OS_defn* clone() const {return new OS_defn(*this);}
732 void steal_oses(OS_defn *other_os);
733 virtual OS_defn* get_refd_last(ReferenceChain *refch=0);
734 virtual void set_fullname(const string& p_fullname);
735 virtual void set_my_scope(Scope *p_scope);
736 void add_ose(OS_Element *p_ose);
737 virtual size_t get_nof_objs();
738 virtual Object* get_obj_byIndex(size_t p_i);
739 virtual Objects* get_objs();
740 virtual void accept(OSEV_objcollctr& v) {v.visit_ObjectSet(*this);}
741 virtual void chk();
742 virtual void generate_code(output_struct *target);
743 virtual void dump(unsigned level) const;
744 private:
745 void parse_block();
746 void create_objs();
747 };
748
749 /**
750 * Referenced ObjectSet.
751 */
752 class OS_refd : public ObjectSet, public OS_Element {
753 private:
754 Reference *ref;
755 OS_defn *os_error;
756 ObjectSet *os_refd; /**< cache */
757 OS_defn *os_defn; /**< cache */
758
759 OS_refd(const OS_refd& p);
760 virtual string create_stringRepr();
761 public:
762 OS_refd(Reference *p_ref);
763 virtual ~OS_refd();
764 virtual OS_refd* clone() const {return new OS_refd(*this);}
765 virtual void set_my_scope(Scope *p_scope);
766 ObjectSet* get_refd(ReferenceChain *refch=0);
767 virtual OS_defn* get_refd_last(ReferenceChain *refch=0);
768 virtual size_t get_nof_objs();
769 virtual Object* get_obj_byIndex(size_t p_i);
770 virtual void accept(OSE_Visitor& v) {v.visit_OS_refd(*this);}
771 virtual void accept(OSEV_objcollctr& v) {v.visit_ObjectSet(*this);}
772 virtual void chk();
773 virtual void generate_code(output_struct *target);
774 virtual void dump(unsigned level) const;
775 virtual OS_Element *clone_ose() const;
776 virtual void set_fullname_ose(const string& p_fullname);
777 virtual void set_genname_ose(const string& p_prefix,
778 const string& p_suffix);
779 virtual void set_my_scope_ose(Scope *p_scope);
780 };
781
782 } // namespace Asn
783
784 #endif // _Asn_Object_HH
This page took 0.049741 seconds and 6 git commands to generate.