summaryrefslogtreecommitdiff
path: root/Context.cc
blob: d0098358bbe225896e4d8717f09501a702b396d0 (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
#include <llvm/IR/LLVMContext.h>

#include "Context.hh"

namespace pcc {
// llvm needs a LLVMContext for every thread, but we only have one thread, so we
// just use this global context.
llvm::LLVMContext GlobalLLVMContext;

Context::Context(const char* name)
    : builder_(GlobalLLVMContext)
    , module_(name, GlobalLLVMContext) {
    scopes_.push(&globals_);
}

TypeManager* Context::GetTypeManager() { return &TypeManager_; }

VariableList Context::GetGlobals() { return &globals_; }

llvm::Module* Context::GetModule() { return &module_; }

llvm::IRBuilder<>* Context::GetBuilder() { return &builder_; }

VariableList* Context::GetCurrentScope() { return scopes_.top(); }

void Context::PushScope(VariableList* scope) { scopes_.push(scope); }

void Context::PopScope() { scopes_.pop(); }
} // namespace pcc