1 #ifndef RUST_TYTY_REGION_H
2 #define RUST_TYTY_REGION_H
21 uint16_t debruijn_index
;
25 Region () : Region (UNRESOLVED
) {}
26 Region (const Region
&other
)
27 : index (other
.index
), debruijn_index (other
.debruijn_index
),
28 variant (other
.variant
)
30 Region (Region
&&other
) noexcept
31 : index (other
.index
), debruijn_index (other
.debruijn_index
),
32 variant (other
.variant
)
34 Region
&operator= (const Region
&other
)
39 debruijn_index
= other
.debruijn_index
;
40 variant
= other
.variant
;
43 Region
&operator= (Region
&&other
) noexcept
48 debruijn_index
= other
.debruijn_index
;
49 variant
= other
.variant
;
53 static Region
make_static () { return Region (STATIC
); }
54 static Region
make_early_bound (uint32_t index
)
56 return Region (EARLY_BOUND
, index
);
58 static Region
make_late_bound (uint32_t index
, uint16_t debruijn_index
)
60 return Region (LATE_BOUND
, index
, debruijn_index
);
62 static Region
make_named (uint32_t index
) { return Region (NAMED
, index
); }
63 static Region
make_anonymous () { return Region (ANONYMOUS
); }
64 static Region
make_erased () { return Region (ERASED
); }
66 size_t get_index () const { return index
; }
68 bool is_static () const { return variant
== STATIC
; }
69 bool is_early_bound () const { return variant
== EARLY_BOUND
; }
70 bool is_late_bound () const { return variant
== LATE_BOUND
; }
71 bool is_named () const { return variant
== NAMED
; }
72 bool is_anonymous () const { return variant
== ANONYMOUS
; }
74 void shift_down () { debruijn_index
++; }
76 WARN_UNUSED_RESULT
std::string
as_string () const
85 return "'early(" + std::to_string (index
) + ")";
87 return "'late(" + std::to_string (debruijn_index
) + ", "
88 + std::to_string (index
) + ")";
90 return "'named(" + std::to_string (index
) + "";
101 explicit Region (Variant variant
, uint32_t index
= 0,
102 uint16_t debruijn_index
= 0)
103 : index (index
), debruijn_index (debruijn_index
), variant (variant
)
110 #endif // RUST_TYTY_REGION_H