IdentifierTable.h 727 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DistinctNumeric.h>
  8. #include <AK/FlyString.h>
  9. #include <AK/Vector.h>
  10. namespace JS::Bytecode {
  11. TYPEDEF_DISTINCT_NUMERIC_GENERAL(size_t, false, true, false, false, false, false, IdentifierTableIndex);
  12. class IdentifierTable {
  13. AK_MAKE_NONMOVABLE(IdentifierTable);
  14. AK_MAKE_NONCOPYABLE(IdentifierTable);
  15. public:
  16. IdentifierTable() = default;
  17. IdentifierTableIndex insert(FlyString);
  18. FlyString const& get(IdentifierTableIndex) const;
  19. void dump() const;
  20. bool is_empty() const { return m_identifiers.is_empty(); }
  21. private:
  22. Vector<FlyString> m_identifiers;
  23. };
  24. }