symbol.h 1015 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*-----------------------------------------------------------------------------
  2. | Copyright (c) 2013-2017, Nucleic Development Team.
  3. |
  4. | Distributed under the terms of the Modified BSD License.
  5. |
  6. | The full license is in the file COPYING.txt, distributed with this software.
  7. |----------------------------------------------------------------------------*/
  8. #pragma once
  9. namespace kiwi
  10. {
  11. namespace impl
  12. {
  13. class Symbol
  14. {
  15. public:
  16. typedef unsigned long long Id;
  17. enum Type
  18. {
  19. Invalid,
  20. External,
  21. Slack,
  22. Error,
  23. Dummy
  24. };
  25. Symbol() : m_id( 0 ), m_type( Invalid ) {}
  26. Symbol( Type type, Id id ) : m_id( id ), m_type( type ) {}
  27. ~Symbol() {}
  28. Id id() const
  29. {
  30. return m_id;
  31. }
  32. Type type() const
  33. {
  34. return m_type;
  35. }
  36. private:
  37. Id m_id;
  38. Type m_type;
  39. friend bool operator<( const Symbol& lhs, const Symbol& rhs )
  40. {
  41. return lhs.m_id < rhs.m_id;
  42. }
  43. friend bool operator==( const Symbol& lhs, const Symbol& rhs )
  44. {
  45. return lhs.m_id == rhs.m_id;
  46. }
  47. };
  48. } // namespace impl
  49. } // namespace kiwi