-
Notifications
You must be signed in to change notification settings - Fork 0
/
eBPF.cpp
45 lines (36 loc) · 1.06 KB
/
eBPF.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 "eBPF.h"
#include <bits/stdc++.h>
#include <fstream>
#include <iostream>
#include <utility>
#include "fileFountain.h"
#include "graph.h"
#include "graphFiller.h"
#include "results.h"
void EBPF::init(const std::string& filename) {
int i = 1;
std::ifstream reader;
reader.open(filename, std::ifstream::in);
while (reader.good()) {
std::string myText;
std::getline(reader, myText, '\n');
if (myText.empty()) continue;
filler.addInstructionToGraph(std::move(myText), i);
i++;
}
reader.close();
filler.connectLostTags();
}
EBPF::EBPF(Results& r, FileFountain& f) : results(r), fileFountain(f) {}
void EBPF::run() {
std::string filename;
while (!(filename = fileFountain.getNext()).empty()) {
this->init(filename);
results.addResult(std::move(filename), filler.hasCycle(),
filler.hasUnusedInstruction());
this->restart();
}
}
void EBPF::restart() { filler.restart(); }
bool EBPF::hasCycle() { return filler.hasCycle(); }
bool EBPF::hasUnusedInstruction() { return filler.hasUnusedInstruction(); }