P4C
The P4 Compiler
Loading...
Searching...
No Matches
linesOfCodeMetric.h
1
/*
2
Counts the number of "real" lines of code in the compiled program
3
by inserting the numbers of lines which contain code into a set,
4
and retrieving it's size at the end.
5
*/
6
7
#ifndef FRONTENDS_P4_METRICS_LINESOFCODEMETRIC_H_
8
#define FRONTENDS_P4_METRICS_LINESOFCODEMETRIC_H_
9
10
#include <filesystem>
11
#include <string>
12
#include <unordered_set>
13
14
#include "frontends/p4/metrics/metricsStructure.h"
15
#include "ir/ir.h"
16
17
namespace
P4
{
18
19
class
LinesOfCodeMetricPass :
public
Inspector
{
20
private
:
21
Metrics
&metrics;
22
std::string sourceFile;
23
std::unordered_set<unsigned> lines;
24
25
public
:
26
explicit
LinesOfCodeMetricPass(
Metrics
&metricsRef, std::filesystem::path sourceFile)
27
: metrics(metricsRef), sourceFile(sourceFile.stem().string()) {
28
setName(
"LinesOfCodeMetricPass"
);
29
}
30
31
void
postorder(
const
IR::Node
*node)
override
;
32
void
postorder(
const
IR::P4Program *
/*program*/
)
override
;
33
};
34
35
}
// namespace P4
36
37
#endif
/* FRONTENDS_P4_METRICS_LINESOFCODEMETRIC_H_ */
P4::IR::Node
Definition
node.h:94
P4::Inspector
Definition
visitor.h:413
P4
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition
applyOptionsPragmas.cpp:24
P4::Metrics
Definition
metricsStructure.h:119
frontends
p4
metrics
linesOfCodeMetric.h
Generated by
1.13.2