Skip to content

Commit

Permalink
Analyser: some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Aug 8, 2024
1 parent 9d7174d commit 8104375
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 40 deletions.
20 changes: 11 additions & 9 deletions src/analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3300,16 +3300,18 @@ void Analyser::AnalyserImpl::analyseModel(const ModelPtr &model)

auto equation = aie2aeMappings[internalEquation];

equation->mPimpl->populate(type,
(type == AnalyserEquation::Type::EXTERNAL) ?
equation->mPimpl->mType = type;
equation->mPimpl->mAst = (type == AnalyserEquation::Type::EXTERNAL) ?
nullptr :
internalEquation->mAst,
equationDependencies,
internalEquation->mNlaSystemIndex,
equationNlaSiblings,
computedConstants,
algebraic,
externals);
internalEquation->mAst;
equation->mPimpl->mNlaSystemIndex = internalEquation->mNlaSystemIndex;

std::copy(computedConstants.begin(), computedConstants.end(), back_inserter(equation->mPimpl->mComputedConstants));
std::copy(algebraic.begin(), algebraic.end(), back_inserter(equation->mPimpl->mAlgebraic));
std::copy(externals.begin(), externals.end(), back_inserter(equation->mPimpl->mExternals));

std::copy(equationDependencies.begin(), equationDependencies.end(), back_inserter(equation->mPimpl->mDependencies));
std::copy(equationNlaSiblings.begin(), equationNlaSiblings.end(), back_inserter(equation->mPimpl->mNlaSiblings));

mModel->mPimpl->mEquations.push_back(equation);
}
Expand Down
20 changes: 0 additions & 20 deletions src/analyserequation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,6 @@ AnalyserEquationPtr AnalyserEquation::AnalyserEquationImpl::create()
return std::shared_ptr<AnalyserEquation> {new AnalyserEquation {}};
}

void AnalyserEquation::AnalyserEquationImpl::populate(AnalyserEquation::Type type,
const AnalyserEquationAstPtr &ast,
const std::vector<AnalyserEquationPtr> &dependencies,
size_t nlaSystemIndex,
const std::vector<AnalyserEquationPtr> &nlaSiblings,
const std::vector<AnalyserVariablePtr> &computedConstants,
const std::vector<AnalyserVariablePtr> &algebraic,
const std::vector<AnalyserVariablePtr> &externals)
{
mType = type;
mAst = ast;
mNlaSystemIndex = nlaSystemIndex;

std::copy(dependencies.begin(), dependencies.end(), back_inserter(mDependencies));
std::copy(nlaSiblings.begin(), nlaSiblings.end(), back_inserter(mNlaSiblings));
std::copy(computedConstants.begin(), computedConstants.end(), back_inserter(mComputedConstants));
std::copy(algebraic.begin(), algebraic.end(), back_inserter(mAlgebraic));
std::copy(externals.begin(), externals.end(), back_inserter(mExternals));
}

bool AnalyserEquation::AnalyserEquationImpl::isEmptyDependency(const AnalyserEquationWeakPtr &dependency)
{
auto computedConstants = dependency.lock()->computedConstants();
Expand Down
15 changes: 4 additions & 11 deletions src/analyserequation_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,17 @@ struct AnalyserEquation::AnalyserEquationImpl
{
AnalyserEquation::Type mType = AnalyserEquation::Type::ALGEBRAIC;
AnalyserEquationAstPtr mAst;
std::vector<AnalyserEquationWeakPtr> mDependencies;
size_t mNlaSystemIndex;
std::vector<AnalyserEquationWeakPtr> mNlaSiblings;
bool mIsStateRateBased = false;

std::vector<AnalyserVariablePtr> mComputedConstants;
std::vector<AnalyserVariablePtr> mAlgebraic;
std::vector<AnalyserVariablePtr> mExternals;

static AnalyserEquationPtr create();
std::vector<AnalyserEquationWeakPtr> mDependencies;
std::vector<AnalyserEquationWeakPtr> mNlaSiblings;

void populate(AnalyserEquation::Type type,
const AnalyserEquationAstPtr &ast,
const std::vector<AnalyserEquationPtr> &dependencies,
size_t nlaSystemIndex,
const std::vector<AnalyserEquationPtr> &nlaSiblings,
const std::vector<AnalyserVariablePtr> &computedConstants,
const std::vector<AnalyserVariablePtr> &algebraic,
const std::vector<AnalyserVariablePtr> &externals);
static AnalyserEquationPtr create();

static bool isEmptyDependency(const AnalyserEquationWeakPtr &dependency);

Expand Down

0 comments on commit 8104375

Please sign in to comment.