summaryrefslogtreecommitdiff
path: root/node/BaseNode.cc
blob: a923498c0e0d48e5b6c31cf9d2430b588b872815 (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
#include "Node.hh"

namespace pcc {
BaseNode::BaseNode(Context* context)
    : context_(context) {}

ProgramNode::ProgramNode(
    Context* context, std::string&& name,
    std::list<std::shared_ptr<DeclNode>>&& GlobalDeclarations,
    std::list<std::shared_ptr<FunctionNode>>&& functions)
    : BaseNode(context)
    , name_(std::move(name))
    , GlobalDeclarations_(std::move(GlobalDeclarations))
    , functions_(std::move(functions)) {}

Value ProgramNode::CodeGen() {
    context_->GetModule()->setModuleIdentifier(name_);
    for (auto&& decl : GlobalDeclarations_) {
        decl->CodeGen();
    }
    for (auto&& function : functions_) {
        function->CodeGen();
    }
    return nullptr;
}
} // namespace pcc