-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentifier.cpp
98 lines (91 loc) · 2.06 KB
/
Identifier.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* SET07109 Coursework 2: Implementing a compiler symbol table (Part A) / Implementing a binary search tree (Part B)
* -----------------------------------------------------------------------------------------------------------------
* implementation functions for Identifier class
* author: Vinh Phat Tu (40507973)
* last date of modification: April 2021
*/
#include "Identifier.hpp"
using namespace std;
/*
* Method: Identifier - Constructor
* ----------------------------------
* constructor for Identifier class:
* - assigns all variables
*
* parameters:
* - type: return type
* - name: name of function
* - line_number: line number of declaration
*/
Identifier::Identifier(const string &type, const string &name, int line_number)
{
this->type = type;
this->name = name;
this->line_number = line_number;
}
/*
* Method: get_name - Getter
* -------------------------
* returns name of Identifier
*
* parameters: none
*
* returns: string - containing name of Identifier
*/
string Identifier::get_name() const
{
return name;
}
/*
* Method: get_line_number - Getter
* --------------------------------
* returns line number of declaration
*
* parameters: none
*
* returns: int - line number of declaration
*/
int Identifier::get_line_number() const
{
return line_number;
}
/*
* Method: get_references - Getter
* -------------------------------
* returns number of references
*
* parameters: none
*
* returns: int - number of times referenced
*/
int Identifier::get_references() const
{
return references;
}
/*
* Method: get_type - Getter
* -------------------------
* returns type of Identifier
*
* parameters: none
*
* returns: string - primitive type or return type
*/
string Identifier::get_type() const
{
return type;
}
/*
* Method: add_reference
* ---------------------
* increments reference count by 1
*
* parameters: none
*
* returns: void
*/
void Identifier::add_reference()
{
references++;
}