72
73 // Return a new support object which is the same as this, except tag
74 // has been added to the tag set. The tag must not already be
75 // present in the tag set.
76 FakeRttiSupport add_tag(TagType tag) const {
77 uintx tbit = tag_bit(tag);
78 assert((_tag_set & tbit) == 0,
79 err_msg("Tag " UINTX_FORMAT " is already present in tag set: " UINTX_FORMAT,
80 (uintx)tag, _tag_set));
81 return FakeRttiSupport(_concrete_tag, _tag_set | tbit);
82 }
83
84 private:
85 uintx _tag_set;
86 TagType _concrete_tag;
87
88 static uintx tag_bit(TagType tag) {
89 return ((uintx)1) << validate_tag(tag);
90 }
91
92 static TagType validate_tag(uintx tag) {
93 // Type of tag is not TagType to dodge useless MacOSX compiler warning.
94 assert(tag < (sizeof(uintx) * BitsPerByte),
95 err_msg("Tag " UINTX_FORMAT " is too large", tag));
96 return static_cast<TagType>(tag);
97 }
98 };
99
100 #endif // include guard
|
72
73 // Return a new support object which is the same as this, except tag
74 // has been added to the tag set. The tag must not already be
75 // present in the tag set.
76 FakeRttiSupport add_tag(TagType tag) const {
77 uintx tbit = tag_bit(tag);
78 assert((_tag_set & tbit) == 0,
79 err_msg("Tag " UINTX_FORMAT " is already present in tag set: " UINTX_FORMAT,
80 (uintx)tag, _tag_set));
81 return FakeRttiSupport(_concrete_tag, _tag_set | tbit);
82 }
83
84 private:
85 uintx _tag_set;
86 TagType _concrete_tag;
87
88 static uintx tag_bit(TagType tag) {
89 return ((uintx)1) << validate_tag(tag);
90 }
91
92 static TagType validate_tag(TagType tag) {
93 assert(0 <= tag, err_msg("Tag " INTX_FORMAT " is negative", (intx)tag));
94 assert(tag < BitsPerWord,
95 err_msg("Tag " UINTX_FORMAT " is too large", (uintx)tag));
96 return tag;
97 }
98 };
99
100 #endif // include guard
|