-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASTDeclarationNode.cpp
71 lines (52 loc) · 1.36 KB
/
ASTDeclarationNode.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* File: ASTDeclarationNode.cpp
* Author: claire
*
* Created on October 6, 2013, 2:43 PM
*/
#include "ASTDeclarationNode.h"
#include "ScopeTable.h"
ASTDeclarationNode::ASTDeclarationNode() : ASTNode(), declarationType(0), id(0)
{
}
ASTDeclarationNode::ASTDeclarationNode(const ASTDeclarationNode& orig):ASTNode(orig),
declarationType(orig.declarationType), id(orig.id)
{
}
ASTDeclarationNode& ASTDeclarationNode::operator= (const ASTDeclarationNode &rhs)
{
ASTNode::operator=(rhs);
// do the copy
declarationType= rhs.declarationType;
id=rhs.id;
// return the existing object
return *this;
}
ASTDeclarationNode::~ASTDeclarationNode() {
}
// Generic functionality used for stuff that happens at the global level
string ASTDeclarationNode::genQuadruples() {
if(this->next != NULL) {
this->next->genQuadruples();
}
return "";
}
void ASTDeclarationNode::semAnalyze(){
if(init || !this->isGlobalDec){
this->scopeAnalyze();
if(init)
return;
}
if(this->next != NULL)
this->next->semAnalyze();
//this->typeAnalyze();
}
void ASTDeclarationNode::scopeAnalyze(){
sa->getST()->insertDeclaration(this->id, this);
}
void ASTDeclarationNode::printNode(int indent, ostream * output) {
this->output = output;
if(next != NULL) {
next->printNode(indent, output);
}
}