ICG 2
Electric Boogaloo
AllocInfo.hpp
Go to the documentation of this file.
1 #ifndef ALLOCINFO_HH
2 #define ALLOCINFO_HH
3 
4 #include <stdexcept>
5 #include <vector>
6 #include <string>
7 #include <memory>
8 
9 class DataType;
10 class CompositeDataType;
11 class ArrayDataType;
12 class DataTypeInator;
13 class CheckpointAgent;
14 class MemoryManager;
15 class LexicalAnalyzer;
16 struct VarAccessInfo;
17 
18 
19 // FIXME: the follow define should be in a more appropriate place.
20 // #define TRICK_MAX_INDEX 8
21 
22 namespace StorageClass {
23  enum e {
24  LOCAL = 0,
25  EXTERN = 1
26  };
27 };
28 
33 class AllocInfo {
34 
35  public:
36  AllocInfo( const std::string& varName,
37  std::shared_ptr<const DataType> type,
38  void* suppliedAllocation = 0) ;
39 
40  // Delete the copy constructor.
41  AllocInfo(const AllocInfo& other) = delete;
42 
48  ~AllocInfo();
49 
54  std::string getName() const;
55 
56  std::string getSerialName() const;
57  unsigned int getSerialNumber() const;
58 
63  void * getStart() const;
64 
69  int getSize() const;
70 
75  std::string getTypeSpecifierName() const;
76 
81  unsigned int getDimensionsCount() const;
82 
88  int getDimensionSize( unsigned int n ) const;
89 
93  std::shared_ptr<const DataType> getDataType() const;
94 
99 
104  void clear() const;
105 
106 
109  // void* resize( size_t newElementCount );
110 
114  bool contains(void* address) const;
115 
118  bool getVarAccessInfo( LexicalAnalyzer* lexer, VarAccessInfo& varAccessInfo );
119 
120 
121  std::string toString() const;
122 
123 
124  private:
125 
126  void initialize( const std::string& varName,
127  std::shared_ptr<const DataType> type,
128  void* suppliedAllocation ) ;
129 
130  std::string name;
131  void* start;
132  void* end;
134  std::shared_ptr<const DataType> dataType;
136  StorageClass::e storageClass;
138  unsigned int serialNumber;
139  static unsigned int nextSerialNumber;
140 
141  static const std::string localPrefix;
142  static const std::string externPrefix;
143 } ;
144 #endif
Definition: AllocInfo.hpp:33
StorageClass::e getStorageClass() const
Definition: AllocInfo.cpp:98
int getSize() const
Definition: AllocInfo.cpp:83
bool contains(void *address) const
Definition: AllocInfo.cpp:110
std::string toString() const
Definition: AllocInfo.cpp:120
void * getStart() const
Definition: AllocInfo.cpp:78
bool getVarAccessInfo(LexicalAnalyzer *lexer, VarAccessInfo &varAccessInfo)
std::shared_ptr< const DataType > getDataType() const
Definition: AllocInfo.cpp:93
std::string getTypeSpecifierName() const
Definition: AllocInfo.cpp:88
std::string getName() const
Definition: AllocInfo.cpp:57
void clear() const
Clear the every element of the allocation to 0. Tested in: AllocInfoTest::clear.
Definition: AllocInfo.cpp:103
AllocInfo(const AllocInfo &other)=delete
~AllocInfo()
Definition: AllocInfo.cpp:49
unsigned int getDimensionsCount() const
unsigned int getSerialNumber() const
Definition: AllocInfo.cpp:73
AllocInfo(const std::string &varName, std::shared_ptr< const DataType > type, void *suppliedAllocation=0)
Definition: AllocInfo.cpp:42
int getDimensionSize(unsigned int n) const
std::string getSerialName() const
Definition: AllocInfo.cpp:62
Definition: ArrayDataType.hpp:13
Definition: CompositeDataType.hpp:16
Register and manage datatypes at runtime.
Definition: DataTypeInator.hpp:16
Abstract base class for DataTypes.
Definition: DataType.hpp:11
Definition: LexicalAnalyzer.hpp:43
Keep track of allocations and their type.
Definition: MemoryManager.hpp:18
Definition: AllocInfo.hpp:22
e
Definition: AllocInfo.hpp:23
@ EXTERN
Definition: AllocInfo.hpp:25
@ LOCAL
Definition: AllocInfo.hpp:24