| 407 | } |
| 408 | |
| 409 | std::pair<std::vector<std::optional<std::string>>, std::vector<VariableDeclaration const*>> Predicate::localVariableValues(std::vector<smtutil::Expression> const& _args) const |
| 410 | { |
| 411 | /// The signature of a local block predicate is: |
| 412 | /// block(error, this, abiFunctions, (optionally) bytesConcatFunctions, cryptoFunctions, txData, preBlockchainState, preStateVars, preInputVars, postBlockchainState, postStateVars, postInputVars, outputVars, localVars). |
| 413 | /// Here we are interested in localVars. |
| 414 | auto const* function = programFunction(); |
| 415 | solAssert(function, ""); |
| 416 | |
| 417 | auto const& localVars = SMTEncoder::localVariablesIncludingModifiers(*function, m_contractContext); |
| 418 | auto first = _args.end() - static_cast<int>(localVars.size()); |
| 419 | std::vector<smtutil::Expression> outValues(first, _args.end()); |
| 420 | |
| 421 | auto mask = util::applyMap( |
| 422 | localVars, |
| 423 | [this](auto _var) { |
| 424 | auto varScope = dynamic_cast<ScopeOpener const*>(_var->scope()); |
| 425 | return find(begin(m_scopeStack), end(m_scopeStack), varScope) != end(m_scopeStack); |
| 426 | } |
| 427 | ); |
| 428 | auto localVarsInScope = util::filter(localVars, mask); |
| 429 | auto outValuesInScope = util::filter(outValues, mask); |
| 430 | |
| 431 | auto outTypes = util::applyMap(localVarsInScope, [](auto _var) { return _var->type(); }); |
| 432 | return {formatExpressions(outValuesInScope, outTypes), localVarsInScope}; |
| 433 | } |
| 434 | |
| 435 | std::map<std::string, std::string> Predicate::expressionSubstitution(std::vector<std::string> const& _predArgs) const |
| 436 | { |
no test coverage detected