aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/declaration.cpp
blob: 5341b5b16d93056736840b9985b0935d6625c80b (plain)
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
#include "ast.hpp"


// Declaration definition

Declaration::Declaration(const std::string& _id)
    : id(_id) {}

void Declaration::print() const
{
    if(next_decl != nullptr)
	next_decl->print();
    
    if(id != "")
	std::cout << id << std::endl;
}

void Declaration::printxml() const
{    
    if(next_decl != nullptr)
	next_decl->printxml();

    if(decl_list != nullptr) {
	decl_list->printxml();
    }

    if(id != "")
	std::cout << "<Variable id=\""<< id << "\" />" << std::endl;
}

void Declaration::printasm() const {}

void Declaration::addDeclaration(Declaration* _next_decl)
{
    next_decl = _next_decl;
}

void Declaration::addList(Declaration* _next_decl)
{
    decl_list = _next_decl;
}

Declaration* Declaration::getNext() const
{
    return next_decl;
}

std::string Declaration::getId() const
{
    return id;
}