Semantic.h 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef QLOW_SEMANTIC_H
  2. #define QLOW_SEMANTIC_H
  3. #include <string>
  4. #include <map>
  5. #include "Util.h"
  6. #include "Ast.h"
  7. namespace qlow
  8. {
  9. namespace sem
  10. {
  11. /*!
  12. * \brief contains owning pointers to elements
  13. */
  14. template<typename T>
  15. using SymbolTable = std::map<std::string, std::unique_ptr<T>>;
  16. struct SemanticObject;
  17. struct Class;
  18. struct Field;
  19. struct Method;
  20. SymbolTable<qlow::sem::Class> createFromAst(std::vector<std::unique_ptr<qlow::ast::Class>>& classes);
  21. }
  22. }
  23. struct qlow::sem::SemanticObject
  24. {
  25. virtual ~SemanticObject(void);
  26. };
  27. struct qlow::sem::Class : public SemanticObject
  28. {
  29. std::string name;
  30. SymbolTable<Field> fields;
  31. SymbolTable<Method> methods;
  32. };
  33. struct qlow::sem::Field : public SemanticObject
  34. {
  35. Class* type;
  36. std::string name;
  37. };
  38. struct qlow::sem::Method : public SemanticObject
  39. {
  40. Class* returnType;
  41. std::string name;
  42. };
  43. #endif // QLOW_SEMANTIC_H