nany
clid.h
1 #pragma once
2 #include "libnanyc.h"
3 #include <yuni/core/string.h>
4 #include <functional> // std::hash
5 
6 
7 
8 
9 namespace ny {
10 
11 class CLID final {
12 public:
14  static CLID AtomMapID(uint32_t atomid);
15 
16 public:
18  CLID() = default;
20  CLID(uint32_t atomid, uint32_t lvid);
22  CLID(const CLID&) = default;
23 
25  bool isVoid() const;
26 
28  void reclass(uint32_t lvid);
30  void reclass(uint32_t atomid, uint32_t lvid);
32  void reclassToVoid();
33 
35  uint32_t atomid() const;
37  uint32_t lvid() const;
38 
40  size_t hash() const;
41 
43  CLID& operator = (const CLID&) = default;
45  bool operator == (const CLID&) const;
47  bool operator != (const CLID&) const;
49  bool operator < (const CLID&) const;
50 
51 
52 private:
53  union {
54  uint32_t u32[2];
55  uint64_t u64;
56  } m_data = {{0, 0}};
57 
58 }; // class CLID
59 
60 
61 
62 
63 } // namespace ny
64 
65 
66 
67 
68 std::ostream& operator << (std::ostream& out, const ny::CLID& rhs);
69 
70 #include "clid.hxx"
size_t hash() const
hash of the clid
Definition: clid.hxx:59
uint32_t atomid() const
Get the atom id of the clid.
Definition: clid.hxx:64
Definition: clid.h:11
static CLID AtomMapID(uint32_t atomid)
Create a CLID for an atom id.
Definition: clid.hxx:9
bool isVoid() const
Get if the clid is valid (aka != 0)
Definition: clid.hxx:21
Definition: ast.cpp:6
CLID()=default
Default constructor.
bool operator!=(const CLID &) const
Not equal operator.
Definition: clid.hxx:49
bool operator==(const CLID &) const
Equal operator.
Definition: clid.hxx:44
void reclass(uint32_t lvid)
update the class id from lvid only
Definition: clid.hxx:26
void reclassToVoid()
update to &#39;void&#39;
Definition: clid.hxx:39
CLID & operator=(const CLID &)=default
Assignment operator.
bool operator<(const CLID &) const
Comparison operator.
Definition: clid.hxx:54
uint32_t lvid() const
Get the lvid part.
Definition: clid.hxx:69