-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckConditions.h
64 lines (52 loc) · 1.76 KB
/
CheckConditions.h
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
61
62
63
64
/*
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef CHECKCONDITIONS_H
#define CHECKCONDITIONS_H
#include "RteModel.h"
class CheckConditions
{
public:
CheckConditions(RteGlobalModel& model) : m_model(model) {}
~CheckConditions() {};
RteGlobalModel& GetModel() { return m_model; };
void SetWorkingDir(const std::string& path) { m_workingDir = path; }
const std::string& GetWorkingDir() { return m_workingDir; }
bool AddDefinedCondition(RteCondition* condition);
bool AddUsedCondition(RteCondition* condition);
bool AddUsedCondition(const std::string& conditionId, int lineNo);
bool CheckForUnused();
bool TestSubConditions(RteItem* expression);
bool IsVisited(RteCondition* cond) const { return m_visitedConditions.find(cond) != m_visitedConditions.end(); }
private:
std::map<std::string, RteCondition*> m_definedConditions;
std::map<std::string, RteCondition*> m_unusedConditions;
std::list<RteCondition*> m_usedConditions;
std::set<RteCondition*> m_visitedConditions;
RteGlobalModel& m_model;
std::string m_workingDir;
};
class DefinedConditionsVisitor : public RteVisitor
{
public:
DefinedConditionsVisitor(CheckConditions* conditions);
~DefinedConditionsVisitor();
virtual VISIT_RESULT Visit(RteItem* item);
private:
CheckConditions* m_Conditions;
RteTarget* m_target; // for expression evaluation
RteModel* m_filteredModel; // needed to test conditions
};
class UsedConditionsVisitor : public RteVisitor
{
public:
UsedConditionsVisitor(CheckConditions* conditions);
~UsedConditionsVisitor();
virtual VISIT_RESULT Visit(RteItem* item);
void GetUsedSubConditions(RteCondition* cond);
private:
CheckConditions* m_Conditions;
};
#endif // CHECKCONDITIONS_H