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