Moves default actions to be part of the rules

This commit is contained in:
Felipe Zimmerle
2020-04-06 20:27:10 -03:00
parent 1b7aa42c77
commit 3a189a131f
8 changed files with 27 additions and 30 deletions

View File

@@ -33,7 +33,7 @@ bool Block::evaluate(RuleWithActions *rule, Transaction *transaction,
std::shared_ptr<RuleMessage> rm) {
ms_dbg_a(transaction, 8, "Marking request as disruptive.");
for (auto &a : transaction->m_rules->m_defaultActions[rule->getPhase()]) {
for (auto &a : transaction->m_rules->m_rulesSetPhases[rule->getPhase()]->m_defaultActions) {
if (a->isDisruptive() == false) {
continue;
}

View File

@@ -2432,7 +2432,7 @@ namespace yy {
YYERROR;
}
if (!driver.m_defaultActions[definedPhase].empty()) {
if (!driver.m_rulesSetPhases[definedPhase]->m_defaultActions.empty()) {
std::stringstream ss;
ss << "SecDefaultActions can only be placed once per phase and configuration context. Phase ";
ss << secRuleDefinedPhase;
@@ -2442,7 +2442,7 @@ namespace yy {
}
for (actions::Action *a : checkedActions) {
driver.m_defaultActions[definedPhase].push_back(
driver.m_rulesSetPhases[definedPhase]->m_defaultActions.push_back(
std::unique_ptr<actions::Action>(a));
}

View File

@@ -1207,7 +1207,7 @@ expression:
YYERROR;
}
if (!driver.m_defaultActions[definedPhase].empty()) {
if (!driver.m_rulesSetPhases[definedPhase]->m_defaultActions.empty()) {
std::stringstream ss;
ss << "SecDefaultActions can only be placed once per phase and configuration context. Phase ";
ss << secRuleDefinedPhase;
@@ -1217,7 +1217,7 @@ expression:
}
for (actions::Action *a : checkedActions) {
driver.m_defaultActions[definedPhase].push_back(
driver.m_rulesSetPhases[definedPhase]->m_defaultActions.push_back(
std::unique_ptr<actions::Action>(a));
}

View File

@@ -222,7 +222,7 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans,
bool containsBlock, std::shared_ptr<RuleMessage> ruleMessage) {
bool disruptiveAlreadyExecuted = false;
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) {
for (auto &a : trans->m_rules->m_rulesSetPhases[getPhase()]->m_defaultActions) {
if (a.get()->action_kind != actions::Action::RunTimeOnlyIfMatchKind) {
continue;
}
@@ -356,7 +356,7 @@ void RuleWithActions::executeTransformations(
// Notice that first we make sure that won't be a t:none
// on the target rule.
if (none == 0) {
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) {
for (auto &a : trans->m_rules->m_rulesSetPhases[getPhase()]->m_defaultActions) {
if (a->action_kind \
!= actions::Action::RunTimeBeforeMatchAttemptKind) {
continue;

View File

@@ -61,6 +61,13 @@ int RulesSetPhases::append(RulesSetPhases *from, std::ostringstream *err) {
return res;
}
amount_of_rules = amount_of_rules + res;
std::vector<std::shared_ptr<actions::Action> > *actions_from = &from->at(phase)->m_defaultActions;
std::vector<std::shared_ptr<actions::Action> > *actions_to = &at(phase)->m_defaultActions;
for (size_t j = 0; j < actions_from->size(); j++) {
actions_to->push_back(actions_from->at(j));
}
}
return amount_of_rules;