-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass.hpp
32 lines (24 loc) · 803 Bytes
/
Class.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef CLASS_HPP
#define CLASS_HPP
#include <string>
#include <unordered_map>
#include "Method.hpp"
#include "Record.hpp"
#include "Variable.hpp"
class Class : public Record {
/*
* We use pointers here, since the Variable, Method, etc. objects are stored
* (and owned) as unique_ptrs to Records in the "records" unordered_map in
* the SymbolTable class.
* */
std::unordered_map<std::string, Variable *> variables;
std::unordered_map<std::string, Method *> methods;
public:
Class(const std::string &id) : Record(id, id){};
void addVariable(Variable *variable);
void addMethod(Method *method);
Variable *lookupVariable(const std::string &id);
Method *lookupMethod(const std::string &id);
std::string getRecord() const override;
};
#endif