aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/translation_unit.cpp
blob: a3566d74672ba4443eabc13fcf84c9f3a3d8d7cb (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
#include "ast.hpp"


// Translation Unit definition

TranslationUnit::TranslationUnit(Node* decl)
{
    push(decl);
}

void TranslationUnit::print() const
{
    for(auto& node : translation_unit) {
	node->print();
    }
}

void TranslationUnit::printxml() const
{
    std::cout << "<?xml version=\"1.0\"?>\n<Program>" << std::endl;
    for(auto& node : translation_unit) {
	node->printxml();
    }
    std::cout << "</Program>" << std::endl;
}

void TranslationUnit::printasm() const
{
    for(auto& node : translation_unit) {
	node->printasm();
    }
}

void TranslationUnit::push(Node* decl)
{
    translation_unit.push_back(decl);
}