ICG 2
Electric Boogaloo
TypeDictionary.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <string>
5 #include <stdexcept>
6 #include <memory>
7 
8 #include "Type/DataType.hpp"
10 
11 class DataTypeInator;
12 
17 
18  public:
19 
21 
25  std::shared_ptr<const DataType> lookup(std::string typeName);
26 
30  void addTypeDefinition(std::string name, DataType * typeSpec);
31 
32 
40  bool validate(DataTypeInator * dataTypeInator);
41 
45  std::string toString();
46 
51 
52  // helper
53  // This probably doesn't belong here
54  void addBuiltinTypes();
55 
56  private:
57  bool is_valid;
58 
59  std::map<std::string, std::shared_ptr<DataType>> typeDictionary;
60 
61  // Make these guys unique_ptrs
62  // Or just objects? No reason to make this a pointer i think
63  std::map<std::string, TypeDictionary *> namespaceDictionary;
64 
65  // Helpers to avoid having to parse the declaration multiple times
66  void addTypeDefinition(MutableDeclaration& nameParts, DataType * typeSpec);
67  std::shared_ptr<const DataType> lookup(MutableDeclaration& nameParts);
68 };
Register and manage datatypes at runtime.
Definition: DataTypeInator.hpp:16
Abstract base class for DataTypes.
Definition: DataType.hpp:11
Definition: MutableDeclaration.hpp:12
Definition: TypeDictionary.hpp:16
~TypeDictionary()
Definition: TypeDictionary.cpp:205
std::shared_ptr< const DataType > lookup(std::string typeName)
Definition: TypeDictionary.cpp:47
void addTypeDefinition(std::string name, DataType *typeSpec)
Definition: TypeDictionary.cpp:85
std::string toString()
Definition: TypeDictionary.cpp:186
void addBuiltinTypes()
Definition: TypeDictionary.cpp:23
TypeDictionary()
Definition: TypeDictionary.cpp:19
bool validate(DataTypeInator *dataTypeInator)
Validate all types in this dictionary.
Definition: TypeDictionary.cpp:137