-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASTParamNode.cpp
76 lines (56 loc) · 1.55 KB
/
ASTParamNode.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
72
73
74
75
76
/*
* File: ASTParamNode.cpp
* Author: daniel
*
* Created on October 7, 2013, 11:15 PM
*/
#include "ASTParamNode.h"
#include "ScopeTable.h"
ASTParamNode::ASTParamNode() : ASTVariableDeclarationNode(), isRef(false) {
}
ASTParamNode::ASTParamNode(const ASTParamNode& orig):ASTVariableDeclarationNode(orig),
isRef(orig.isRef)
{
}
ASTParamNode& ASTParamNode::operator= (const ASTParamNode &rhs)
{
ASTVariableDeclarationNode::operator=(rhs);
// do the copy
isRef = rhs.isRef;
// return the existing object
return *this;
}
ASTParamNode::~ASTParamNode() {
}
void ASTParamNode::semAnalyze(){
if(init || !this->isGlobalDec){
this->scopeAnalyze();
if(init)
return;
}
/*if(this->isArray)
this->arrayExp->semAnalyze();*/
if(this->next != NULL)
this->next->semAnalyze();
//this->typeAnalyze();
}
void ASTParamNode::scopeAnalyze(){
sa->getST()->insertDeclaration(id, this);
}
void ASTParamNode::printNode(int indent, ostream * output) {
ostringstream oss;
this->output = output;
printIndented("param", indent);
if(ASTNode::lookup != NULL) {
printIndented("id: " + ASTNode::lookup->getIdentifierName(id), indent + 2);
}
printIndented("type: " + Scanner::namesRev[declarationType], indent + 2);
oss << "ref? " << (isRef ? "YES" : "NO");
printIndented(oss.str(), indent + 2);
oss.str("");
oss << "arrayParam? " << (isArray ? "YES" : "NO");
printIndented(oss.str(), indent + 2);
if(next != NULL) {
next->printNode(indent, output);
}
}