@@ -25,11 +25,13 @@ std::string get_properties_type(const Instruction *inst) {
25
25
using namespace mfast ;
26
26
struct ext_cref_type_getter : mfast::field_instruction_visitor {
27
27
std::stringstream out_;
28
+ bool is_group_type_ = false ;
28
29
29
30
public:
30
31
ext_cref_type_getter () {}
31
32
32
33
std::string get () { return out_.str (); }
34
+ bool group_type () { return is_group_type_; }
33
35
34
36
virtual void visit (const int32_field_instruction *inst, void *) override {
35
37
out_ << " ext_cref<int32_cref, " << get_operator_tag (inst) << " , "
@@ -83,6 +85,7 @@ struct ext_cref_type_getter : mfast::field_instruction_visitor {
83
85
virtual void visit (const group_field_instruction *inst, void *) override {
84
86
out_ << " ext_cref< " << codegen_base::cpp_name (inst)
85
87
<< " _cref, group_type_tag, " << get_properties_type (inst) << " >" ;
88
+ is_group_type_ = true ;
86
89
}
87
90
88
91
virtual void visit (const sequence_field_instruction *inst, void *) override ;
@@ -132,6 +135,12 @@ std::string get_ext_cref_type(const field_instruction *inst) {
132
135
return getter.get ();
133
136
}
134
137
138
+ bool is_group_type (const field_instruction *inst) {
139
+ ext_cref_type_getter getter;
140
+ inst->accept (getter, nullptr );
141
+ return getter.group_type ();
142
+ }
143
+
135
144
void ext_cref_type_getter::visit (const sequence_field_instruction *inst,
136
145
void *) {
137
146
const uint32_field_instruction *length_inst = inst->length_instruction ();
@@ -473,9 +482,17 @@ void inl_gen::visit(const mfast::group_field_instruction *inst, void *pIndex) {
473
482
474
483
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
475
484
const field_instruction *subinst = inst->subinstructions ()[i];
476
- ;
477
- out_ << " visitor.visit(" << get_ext_cref_type (subinst) << " ((*this)["
478
- << i << " ]) );\n " ;
485
+
486
+ if (is_group_type (subinst) && subinst->optional ())
487
+ {
488
+ out_ << " {\n "
489
+ << " " << get_ext_cref_type (subinst) << " ext_cref_group((*this)[" << i << " ]);\n "
490
+ << " ext_cref_group.set_group_present(this->field_storage(" << i << " )->is_present());\n "
491
+ << " visitor.visit(ext_cref_group);\n "
492
+ << " }\n " ;
493
+ }
494
+ else
495
+ out_ << " visitor.visit(" << get_ext_cref_type (subinst) << " ((*this)[" << i << " ]) );\n " ;
479
496
}
480
497
481
498
out_ << " }\n\n " ;
@@ -508,6 +525,7 @@ void inl_gen::visit(const mfast::group_field_instruction *inst, void *pIndex) {
508
525
509
526
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
510
527
const field_instruction *subinst = inst->subinstructions ()[i];
528
+
511
529
out_ << " visitor.visit(" << get_ext_mref_type (subinst) << " ((*this)["
512
530
<< i << " ]) );\n " ;
513
531
}
@@ -662,7 +680,7 @@ void inl_gen::visit(const mfast::sequence_field_instruction *inst,
662
680
663
681
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
664
682
const field_instruction *subinst = inst->subinstructions ()[i];
665
- ;
683
+
666
684
out_ << " visitor.visit(" << get_ext_cref_type (subinst) << " ((*this)["
667
685
<< i << " ]) );\n " ;
668
686
}
@@ -677,7 +695,7 @@ void inl_gen::visit(const mfast::sequence_field_instruction *inst,
677
695
678
696
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
679
697
const field_instruction *subinst = inst->subinstructions ()[i];
680
- ;
698
+
681
699
out_ << " visitor.visit(" << get_ext_mref_type (subinst) << " ((*this)["
682
700
<< i << " ]) );\n " ;
683
701
}
@@ -791,9 +809,17 @@ void inl_gen::visit(const mfast::template_instruction *inst, void *) {
791
809
792
810
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
793
811
const field_instruction *subinst = inst->subinstructions ()[i];
794
- ;
795
- out_ << " visitor.visit(" << get_ext_cref_type (subinst) << " ((*this)["
796
- << i << " ]) );\n " ;
812
+
813
+ if (is_group_type (subinst) && subinst->optional ())
814
+ {
815
+ out_ << " {\n "
816
+ << " " << get_ext_cref_type (subinst) << " ext_cref_group((*this)[" << i << " ]);\n "
817
+ << " ext_cref_group.set_group_present(this->field_storage(" << i << " )->is_present());\n "
818
+ << " visitor.visit(ext_cref_group);\n "
819
+ << " }\n " ;
820
+ }
821
+ else
822
+ out_ << " visitor.visit(" << get_ext_cref_type (subinst) << " ((*this)[" << i << " ]) );\n " ;
797
823
}
798
824
799
825
out_ << " }\n\n " ;
@@ -842,7 +868,7 @@ void inl_gen::visit(const mfast::template_instruction *inst, void *) {
842
868
843
869
for (std::size_t i = 0 ; i < inst->subinstructions ().size (); ++i) {
844
870
const field_instruction *subinst = inst->subinstructions ()[i];
845
- ;
871
+
846
872
out_ << " visitor.visit(" << get_ext_mref_type (subinst) << " ((*this)["
847
873
<< i << " ]) );\n " ;
848
874
}
0 commit comments