2c2
< * Copyright (c) 2016 ARM Limited
---
> * Copyright (c) 2016-2017 ARM Limited
49c49
< : PowerModelState(p), dyn_expr(p->dyn), st_expr(p->st)
---
> : PowerModelState(p), dyn_expr(p->dyn), st_expr(p->st), failed(false)
67a68,83
>
> tryEval(st_expr);
> const bool st_failed = failed;
>
> tryEval(dyn_expr);
> const bool dyn_failed = failed;
>
> if (st_failed || dyn_failed) {
> const auto *p = dynamic_cast<const Params *>(params());
> assert(p);
>
> fatal("Failed to evaluate power expressions:\n%s%s%s\n",
> st_failed ? p->st : "",
> st_failed && dyn_failed ? "\n" : "",
> dyn_failed ? p->dyn : "");
> }
70a87,112
> MathExprPowerModel::eval(const MathExpr &expr) const
> {
> const double value = tryEval(expr);
>
> // This shouldn't happen unless something went wrong the equations
> // were verified in startup().
> panic_if(failed, "Failed to evaluate power expression '%s'\n",
> expr.toStr());
>
> return value;
> }
>
> double
> MathExprPowerModel::tryEval(const MathExpr &expr) const
> {
> failed = false;
> const double value = expr.eval(
> std::bind(&MathExprPowerModel::getStatValue,
> this, std::placeholders::_1)
> );
>
> return value;
> }
>
>
> double
80c122,127
< Info *info = stats_map.at(name);
---
> const auto it = stats_map.find(name);
> if (it == stats_map.cend()) {
> warn("Failed to find stat '%s'\n", name);
> failed = true;
> return 0;
> }
82c129,131
< ScalarInfo *si = dynamic_cast<ScalarInfo*>(info);
---
> const Info *info = it->second;
>
> auto si = dynamic_cast<const ScalarInfo *>(info);
85c134
< FormulaInfo *fi = dynamic_cast<FormulaInfo*>(info);
---
> auto fi = dynamic_cast<const FormulaInfo *>(info);