-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathligador.cpp
45 lines (33 loc) · 1.17 KB
/
ligador.cpp
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
#include "include/datatypes.hpp"
#include "include/preprocessor.hpp"
#include "include/assembler.hpp"
#include "include/linker.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char** argv) {
vector<tokenMatrix> input_matrixes(argc - 1);
if (argc < 2 || argc > 5) {
cout << "Quantidade de argumentos invalida (" << argc << "),\ninsira até 4 arquivos no programa: nomedoprograma1 nomedoprograma2 nomedoprograma3 nomedoprograma4" << endl;
return 1;
}
for (int i = 1; i < argc; i++) {
fileData* input_file = new fileData{ .name = argv[i] };
input_file->name.append(".obj");
ifstream ifs(input_file->name);
stringstream buffer;
buffer << ifs.rdbuf();
input_file->content = buffer.str();
ConvertFileToMatrix(input_file, &input_matrixes.at(i-1));
delete input_file;
}
fileData* output_file = new fileData{ .name = argv[1] };
output_file->name.append(".exc");
Link(input_matrixes, output_file);
ofstream ofs(output_file->name);
ofs << output_file->content;
ofs.close();
delete output_file;
}