59 // Construct with the indicated concrete tag and tag set. 60 // Note: This constructor is public only to allow clients to set up 61 // "unusual" (or perhaps buggy) fake RTTI configurations. 62 FakeRttiSupport(TagType concrete_tag, uintx tag_set) : 63 _tag_set(tag_set), _concrete_tag(validate_tag(concrete_tag)) { } 64 65 // Get the concrete tag. 66 TagType concrete_tag() const { return _concrete_tag; } 67 68 // Test whether tag is in the tag set. 69 bool has_tag(TagType tag) const { 70 return (_tag_set & tag_bit(tag)) != 0; 71 } 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 | 59 // Construct with the indicated concrete tag and tag set. 60 // Note: This constructor is public only to allow clients to set up 61 // "unusual" (or perhaps buggy) fake RTTI configurations. 62 FakeRttiSupport(TagType concrete_tag, uintx tag_set) : 63 _tag_set(tag_set), _concrete_tag(validate_tag(concrete_tag)) { } 64 65 // Get the concrete tag. 66 TagType concrete_tag() const { return _concrete_tag; } 67 68 // Test whether tag is in the tag set. 69 bool has_tag(TagType tag) const { 70 return (_tag_set & tag_bit(tag)) != 0; 71 } 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 "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, "Tag " INTX_FORMAT " is negative", (intx)tag); 94 assert(tag < BitsPerWord, 95 "Tag " UINTX_FORMAT " is too large", (uintx)tag); 96 return tag; 97 } 98 }; 99 100 #endif // include guard |