aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/declaration.cpp
blob: e2f27cccb16a851bfd07c9ebf4dd9156f29cf326 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#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(list_next_decl != nullptr) {
	list_next_decl->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)
{
    list_next_decl = _next_decl;
}

void Declaration::setType(Type* _type)
{
    type = _type;
}

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

Declaration* Declaration::getNextListItem() const
{
    return list_next_decl;
}

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

std::string Declaration::getType() const
{
    return type->getType();
}