-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrary.cc
60 lines (50 loc) · 1.51 KB
/
library.cc
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "library.h"
#include <fstream>
void LibraryIncluder::setFileSource(std::string sourceFile)
{
sourceFileName = sourceFile;
}
void LibraryIncluder::buildLibrary()
{
std::string lib [] = {
"int input(void) {}",
"void output(int number) {}"};
library.assign(std::begin(lib), std::end(lib));
}
FILE *LibraryIncluder::getFinalFile()
{
buildLibrary();
std::ofstream outputFile("temporary.o");
std::ifstream inputFile(sourceFileName);
std::string line;
for(auto fun : library)
outputFile << fun << std::endl;
if (inputFile.is_open())
while (getline(inputFile, line))
{
outputFile << line << "\n";
};
outputFile << "\n";
inputFile.close();
outputFile.close();
// std::cout << buffer.str() << std::endl;
// size_t bufferSize = 0;
// char *f_buffer = NULL;
// source = open_memstream(&f_buffer, &bufferSize);
// snprintf(f_buffer, bufferSize, buffer.str().c_str());
source = fopen("temporary.o", "r");
// source = fopen(sourceFileName.c_str(), "r") ;
return source;
}
void OSLibraryIncluder::buildLibrary()
{
std::string lib[] = {
"int input(void) {}",
"void output(int number) {}",
"int readFromMemory(int address){}",
"int extractFirstHW(int number){}",
"int extractSecondHW(int number){}",
"void assignPointer(int vector[], int address){}",
"int readPointer(int vector[]){}"};
library.assign(std::begin(lib), std::end(lib));
}