Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Implementation of Programming Languages / Transpiler / src / LLVMVisitor / LLVMVisitor.cpp
blob: f68b80d6ea5773773d370b88e192961510ec66fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#include "LLVMVisitor.h"

LLVMVisitor::LLVMVisitor(const char* fileName) : outFile(std::ofstream(fileName)), reg() {
	if (!outFile.is_open())
		throw std::runtime_error("Couldn't open file for writing!");
}

std::string LLVMVisitor::Visit(const Integer& vint) {
	std::string valRegister = *(reg++);
	outFile << valRegister + " = " + std::to_string(vint.get_value()) + "\n";
	return valRegister;
}