add some comment
This commit is contained in:
parent
67b8d25d85
commit
2c4d9cdcc8
@ -25,19 +25,23 @@ typedef ClassTable *ClassTableP;
|
||||
|
||||
class ClassGraphNode {
|
||||
private:
|
||||
// tree-shape relation maintainer
|
||||
ClassGraphNode* parent;
|
||||
std::vector<ClassGraphNode*> children;
|
||||
// the `class__class` object for which it builds graph
|
||||
Class_ self;
|
||||
// for cycle detection
|
||||
int mark = 0;
|
||||
|
||||
public:
|
||||
// Note that, Class_ = Class__class*, itself is a ptr type, so just use it
|
||||
ClassGraphNode(Class_ self_class, ClassGraphNode* parent_class = nullptr) :
|
||||
parent(parent_class), self(self_class) { }
|
||||
// Explicitly disable copy constructor
|
||||
ClassGraphNode(const ClassGraphNode&) = delete;
|
||||
ClassGraphNode& operator=(const ClassGraphNode) = delete;
|
||||
// Long time no C++, god knows if the destructor works or not...
|
||||
~ ClassGraphNode() {
|
||||
// Long time no C++, god knows if the destructor works or not...
|
||||
while (!children.empty()) {
|
||||
auto child = children[children.size() - 1];
|
||||
children.pop_back();
|
||||
@ -112,9 +116,14 @@ private:
|
||||
int semant_errors;
|
||||
void install_basic_classes();
|
||||
ostream& error_stream;
|
||||
|
||||
// Root of the Inheritance Graph (hopefully it is a tree if the program is correct)
|
||||
ClassGraphNode* class_root;
|
||||
std::map<Symbol, ClassGraphNode*> name_to_node;
|
||||
|
||||
// again, the correctness of using ptr can be inferred from `Single Copy` of the symbol string
|
||||
// Actually, we could use the provided symbol table instead of a stl map for this
|
||||
// anyways we don't need name shadowing here, I just save my effort
|
||||
std::map<Symbol, ClassGraphNode*> name_to_node;
|
||||
|
||||
public:
|
||||
ClassTable(Classes);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user