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

#include <iostream>

// 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;
}

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

    return bindings;
}

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