-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
56 lines (48 loc) · 2.1 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <memory>
#include <clara.hpp>
#include "src/StateMachine/DataHolder/ProcessDatabase.h"
#include "src/StateMachine/StateChain.h"
#include "src/StateMachine/BaseState.h"
#include "src/StateMachine/DataHolder/ProcessDatabase.h"
#include "src/StateMachine/States/includes/LoadAssembly.h"
#include "src/StateMachine/States/includes/SplitAssembly.h"
#include "src/StateMachine/States/includes/CleanupAssembly.h"
#include "src/StateMachine/States/includes/ParseAssembly.h"
#include "src/StateMachine/States/includes/TimingCalculation.h"
#include "src/StateMachine/States/includes/TimingInsertion.h"
#include "src/commandline/parse.h"
[[nodiscard]] int pgmEnd() {
#if defined(DEBUG_BUILD) && defined(_MSC_VER)
std::this_thread::sleep_until(std::chrono::system_clock::now() + std::chrono::hours(std::numeric_limits<int>::max()));
#endif
return 0;
}
int main(int argc, const char* argv[]) {
Parse clParser{argc, argv};
if(!clParser) {
std::cout << clParser;
return pgmEnd();
}
ProcessDatabase database;
database.fileLocation(clParser.asmLocation());
database.arch(clParser.arch());
LoadAssembly loadAssembly{ database };
SplitAssembly splitAssembly{ database };
CleanupAssembly cleanupAssembly{ database };
ParseAssembly parseAssembly{ database };
TimingCalculation timingCalculation{ database };
TimingInsertion timingInsertion{ database };
StateChain<BaseState*> stateChain{ &loadAssembly };
stateChain.addChain(&loadAssembly, &splitAssembly);
stateChain.addChain(&splitAssembly, &cleanupAssembly);
stateChain.addChain(&cleanupAssembly, &parseAssembly);
stateChain.addChain(&parseAssembly, &timingCalculation);
stateChain.addChain(&timingCalculation, &timingInsertion);
stateChain.addChain(&timingInsertion, &cleanupAssembly, [&] { return (splitAssembly).remainingSplits() > 0; });
stateChain.addChain(&timingInsertion, [&] { return splitAssembly.remainingSplits() <= 0;} );
do {
stateChain.current()->execute();
} while (stateChain.next());
//std::cout << database.fileContents() << std::endl;
}