4#include "internal/compilers.h"
9 rb_id_serial_t segments[FLEX_ARY_LEN];
29#define PACKED_FLAG 0x1
30#define ABSOLUTE_FLAG 0x2
33#define PACKED_ID_BITS 31
35#define PACKED_ID_BITS 30
38#define PACKED_ID_BITS_MASK (((uintptr_t)1 << PACKED_ID_BITS) - 1)
40#define PACKED_ID_STATIC_FLAG 0x1
45 return const_path.packed & PACKED_FLAG;
52 unpacked_path.packed &= ~ABSOLUTE_FLAG;
53 return unpacked_path.heap;
57const_path_memsize_for(
size_t size)
65 if (const_path_packed_p(const_path)) {
74 return const_path_memsize_for(heap->size);
80 if (!const_path_packed_p(const_path)) {
81 ruby_xfree_sized((
void *)const_path_heap(const_path), const_path_memsize(const_path));
88 return const_path.packed & ABSOLUTE_FLAG;
92const_path_unpack_id(uint32_t packed_id)
94 bool static_p = packed_id & PACKED_ID_STATIC_FLAG;
97 ID id = rb_id_from_serial_and_type(packed_id, RUBY_ID_CONST);
99 id |= RUBY_ID_STATIC_SYM;
107 rb_id_serial_t serial;
108 if (const_path_packed_p(const_path)) {
111 serial = ((const_path.packed >> PACKED_SHIFT) & PACKED_ID_BITS_MASK);
115 serial = (const_path.packed >> PACKED_SHIFT >> PACKED_ID_BITS) & PACKED_ID_BITS_MASK;
127 if (!heap || index >= heap->size) {
130 serial = heap->segments[index];
132 return const_path_unpack_id(serial);
Represent a constant's path, e.g.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.