Context.h 862 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef QLOW_SEM_CONTEXT_H
  2. #define QLOW_SEM_CONTEXT_H
  3. #include <unordered_map>
  4. #include <memory>
  5. #include <vector>
  6. #include <optional>
  7. #include "Type.h"
  8. namespace qlow::sem
  9. {
  10. class Type;
  11. class Context;
  12. }
  13. namespace std
  14. {
  15. template<>
  16. struct hash<std::reference_wrapper<qlow::sem::Type>>
  17. {
  18. size_t operator() (const std::reference_wrapper<qlow::sem::Type>& t) const;
  19. };
  20. }
  21. class qlow::sem::Context
  22. {
  23. private:
  24. std::string test = "ayayay";
  25. std::vector<Type> types;
  26. std::unordered_map<std::reference_wrapper<Type>, TypeId, std::hash<std::reference_wrapper<Type>>, std::equal_to<Type>> typesMap;
  27. public:
  28. TypeId addType(Type&& type);
  29. std::optional<std::reference_wrapper<Type>> getType(TypeId tid);
  30. TypeId getPointerTo(TypeId id);
  31. TypeId getArrayOf(TypeId id);
  32. };
  33. #endif // QLOW_SEM_CONTEXT_H