@@ -127,6 +127,11 @@ struct ext_cref_type_getter : mfast::field_instruction_visitor {
127127 out_ << " ext_cref<enum_cref, " << get_operator_tag (inst) << " , "
128128 << get_properties_type (inst) << " >" ;
129129 }
130+
131+ virtual void visit (const set_field_instruction *inst, void *) override {
132+ out_ << " ext_cref<set_cref, " << get_operator_tag (inst) << " , "
133+ << get_properties_type (inst) << " >" ;
134+ }
130135};
131136
132137std::string get_ext_cref_type (const field_instruction *inst) {
@@ -260,6 +265,11 @@ struct ext_mref_type_getter : mfast::field_instruction_visitor {
260265 out_ << " ext_mref<enum_mref, " << get_operator_tag (inst) << " , "
261266 << get_properties_type (inst) << " >" ;
262267 }
268+
269+ virtual void visit (const set_field_instruction *inst, void *) override {
270+ out_ << " ext_mref<set_mref, " << get_operator_tag (inst) << " , "
271+ << get_properties_type (inst) << " >" ;
272+ }
263273};
264274
265275std::string get_ext_mref_type (const field_instruction *inst) {
@@ -1045,6 +1055,76 @@ void inl_gen::visit(const mfast::enum_field_instruction *inst, void *pIndex) {
10451055 gen_accessors (inst, name, cref_type_name, mref_type_name, pIndex);
10461056}
10471057
1058+ void inl_gen::visit (const mfast::set_field_instruction *inst, void *pIndex)
1059+ {
1060+ std::string name (cpp_name (inst));
1061+ std::string cref_type_name = cref_scope_.str () + name + " _cref" ;
1062+ std::string mref_type_name = mref_scope_.str () + name + " _mref" ;
1063+ if (inst->ref_instruction () == nullptr )
1064+ {
1065+ out_ << " inline\n " << cref_type_name << " ::" << name << " _cref(\n "
1066+ << " const mfast::value_storage* storage,\n "
1067+ << " " << cref_type_name << " ::instruction_cptr instruction)\n "
1068+ << " : base_type(storage, instruction)\n "
1069+ << " {\n "
1070+ << " }\n\n "
1071+ << " inline\n " << cref_type_name << " ::" << name << " _cref(\n "
1072+ << " const mfast::field_cref& other)\n "
1073+ << " : base_type(other)\n "
1074+ << " {\n "
1075+ << " }\n\n "
1076+ << " inline\n " << mref_type_name << " ::" << name << " _mref(\n "
1077+ << " mfast::allocator* alloc,\n "
1078+ << " mfast::value_storage* storage,\n "
1079+ << " " << mref_type_name << " ::instruction_cptr instruction)\n "
1080+ << " : base_type(alloc, storage, instruction)\n "
1081+ << " {\n "
1082+ << " }\n\n "
1083+ << " inline\n " << mref_type_name << " ::" << name << " _mref(\n "
1084+ << " const mfast::field_mref_base& other)\n "
1085+ << " : base_type(other)\n "
1086+ << " {\n "
1087+ << " }\n\n "
1088+ << " inline\n " << cref_type_name << " ::element_type\n " << cref_type_name
1089+ << " ::value() const\n "
1090+ << " {\n "
1091+ << " return static_cast<" << name
1092+ << " ::element>(base_type::value());\n "
1093+ << " }\n\n " ;
1094+ for (auto i = 0ul ; i < inst->num_elements_ ; ++i)
1095+ {
1096+ std::string element_name = cpp_name (inst->elements_ [i]);
1097+ out_ << " inline\n "
1098+ << " bool " << cref_type_name << " ::has_" << element_name
1099+ << " () const\n "
1100+ << " {\n "
1101+ << " return this->value() & " << name << " ::" << element_name
1102+ << " ;\n "
1103+ << " }\n\n "
1104+ << " inline\n "
1105+ << " void " << mref_type_name << " ::set_" << element_name
1106+ << " () const\n "
1107+ << " {\n "
1108+ << " auto tmp = this->value() | "
1109+ << name << " ::" << element_name << " ;\n "
1110+ << " return this->as(static_cast<element_type>(tmp));\n "
1111+ << " }\n\n "
1112+ << " inline\n "
1113+ << " void " << mref_type_name << " ::unset_" << element_name
1114+ << " () const\n "
1115+ << " {\n "
1116+ << " auto tmp = this->value() & ~"
1117+ << name << " ::" << element_name << " ;\n "
1118+ << " return this->as(static_cast<element_type>(tmp));\n "
1119+ << " }\n\n " ;
1120+ }
1121+ }
1122+ std::string ret_type = cpp_type_of (inst, nullptr );
1123+ auto ret_cref = ret_type + " _cref" ;
1124+ auto ret_mref = ret_type + " _mref" ;
1125+ gen_accessors (inst, name, ret_cref, ret_mref, pIndex);
1126+ }
1127+
10481128void inl_gen::gen_accessors (const mfast::field_instruction *inst,
10491129 const std::string &name,
10501130 const std::string &cref_type_name,
0 commit comments