Compile layer test into CONSTRAINT_WITH_CONDITIONS.
Also processes constraints in correct order for priority (reversed) and removes multiple-expression-conditions for a single constraint (which is not supported in the grammar).
This commit is contained in:
parent
8420fcc33b
commit
d47d119d5f
|
@ -293,7 +293,7 @@ static wxString formatConstraint( const DRC_CONSTRAINT& constraint )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DRC_ENGINE::LoadRules( wxFileName aPath )
|
bool DRC_ENGINE::LoadRules( const wxFileName& aPath )
|
||||||
{
|
{
|
||||||
NULL_REPORTER nullReporter;
|
NULL_REPORTER nullReporter;
|
||||||
REPORTER* reporter = m_reporter ? m_reporter : &nullReporter;
|
REPORTER* reporter = m_reporter ? m_reporter : &nullReporter;
|
||||||
|
@ -374,8 +374,8 @@ bool DRC_ENGINE::CompileRules()
|
||||||
|
|
||||||
CONSTRAINT_WITH_CONDITIONS* rcons = new CONSTRAINT_WITH_CONDITIONS;
|
CONSTRAINT_WITH_CONDITIONS* rcons = new CONSTRAINT_WITH_CONDITIONS;
|
||||||
|
|
||||||
if( condition )
|
rcons->layerTest = rule->m_LayerCondition;
|
||||||
rcons->conditions.push_back( condition );
|
rcons->condition = condition;
|
||||||
|
|
||||||
matchingConstraints.push_back( constraint );
|
matchingConstraints.push_back( constraint );
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ bool DRC_ENGINE::CompileRules()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DRC_ENGINE::InitEngine( wxFileName aRulePath )
|
void DRC_ENGINE::InitEngine( const wxFileName& aRulePath )
|
||||||
{
|
{
|
||||||
m_testProviders = DRC_TEST_PROVIDER_REGISTRY::Instance().GetTestProviders();
|
m_testProviders = DRC_TEST_PROVIDER_REGISTRY::Instance().GetTestProviders();
|
||||||
|
|
||||||
|
@ -520,43 +520,34 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ruleset = m_constraintMap[ aConstraintId ];
|
CONSTRAINT_SET* ruleset = m_constraintMap[ aConstraintId ];
|
||||||
|
|
||||||
for( const CONSTRAINT_WITH_CONDITIONS* rcond : ruleset->sortedConstraints )
|
for( int ii = ruleset->sortedConstraints.size() - 1; ii >= 0; --ii )
|
||||||
{
|
{
|
||||||
DRC_RULE* rule = rcond->parentRule;
|
const CONSTRAINT_WITH_CONDITIONS* rcons = ruleset->sortedConstraints[ ii ];
|
||||||
REPORT( wxString::Format( _( "Checking rule \"%s\"." ), rule->m_Name ) );
|
REPORT( wxString::Format( _( "Checking rule \"%s\"." ),
|
||||||
|
rcons->parentRule->m_Name ) );
|
||||||
|
|
||||||
if( aLayer != UNDEFINED_LAYER && !rule->m_LayerCondition.test( aLayer ) )
|
if( aLayer != UNDEFINED_LAYER && !rcons->layerTest.test( aLayer ) )
|
||||||
{
|
{
|
||||||
REPORT( wxString::Format( _( "Rule layer \"%s\" not matched." ),
|
REPORT( wxString::Format( _( "Rule layer \"%s\" not matched." ),
|
||||||
rule->m_LayerSource ) );
|
rcons->parentRule->m_LayerSource ) );
|
||||||
REPORT( "Rule not applied." );
|
REPORT( "Rule not applied." );
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rcond->conditions.size() == 0 ) // uconditional
|
bool result = rcons->condition->EvaluateFor( a, b, aLayer, aReporter );
|
||||||
{
|
|
||||||
REPORT( _( "Unconditional constraint; rule applied." ) );
|
|
||||||
|
|
||||||
return rcond->constraint;
|
if( result )
|
||||||
|
{
|
||||||
|
REPORT( _( "Rule applied." ) );
|
||||||
|
return rcons->constraint;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for( DRC_RULE_CONDITION* condition : rcond->conditions )
|
|
||||||
{
|
{
|
||||||
bool result = condition->EvaluateFor( a, b, aLayer, aReporter );
|
REPORT( _( "Condition not satisfied; rule not applied." ) );
|
||||||
|
REPORT( "" );
|
||||||
if( result )
|
|
||||||
{
|
|
||||||
REPORT( _( "Rule applied." ) );
|
|
||||||
return rcond->constraint;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
REPORT( _( "Condition not satisfied; rule not applied." ) );
|
|
||||||
REPORT( "" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,14 +131,12 @@ public:
|
||||||
|
|
||||||
void SetLogReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
void SetLogReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
|
||||||
|
|
||||||
bool LoadRules( wxFileName aPath );
|
bool LoadRules( const wxFileName& aPath );
|
||||||
|
|
||||||
void InitEngine( wxFileName aRulePath );
|
void InitEngine( const wxFileName& aRulePath );
|
||||||
|
|
||||||
void RunTests();
|
void RunTests();
|
||||||
|
|
||||||
void SetErrorLimit( int aLimit );
|
|
||||||
|
|
||||||
BOARD_DESIGN_SETTINGS* GetDesignSettings() const { return m_designSettings; }
|
BOARD_DESIGN_SETTINGS* GetDesignSettings() const { return m_designSettings; }
|
||||||
|
|
||||||
BOARD* GetBoard() const { return m_board; }
|
BOARD* GetBoard() const { return m_board; }
|
||||||
|
@ -193,9 +191,10 @@ private:
|
||||||
|
|
||||||
struct CONSTRAINT_WITH_CONDITIONS
|
struct CONSTRAINT_WITH_CONDITIONS
|
||||||
{
|
{
|
||||||
std::vector<DRC_RULE_CONDITION*> conditions;
|
LSET layerTest;
|
||||||
DRC_RULE* parentRule;
|
DRC_RULE_CONDITION* condition;
|
||||||
DRC_CONSTRAINT constraint;
|
DRC_RULE* parentRule;
|
||||||
|
DRC_CONSTRAINT constraint;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CONSTRAINT_SET
|
struct CONSTRAINT_SET
|
||||||
|
|
Loading…
Reference in New Issue