| 31 | using namespace solidity::util; |
| 32 | |
| 33 | CompilabilityChecker::CompilabilityChecker( |
| 34 | Object const& _object, |
| 35 | bool _optimizeStackAllocation |
| 36 | ) |
| 37 | { |
| 38 | yulAssert(_object.hasCode()); |
| 39 | if (auto const* evmDialect = dynamic_cast<EVMDialect const*>(_object.dialect())) |
| 40 | { |
| 41 | NoOutputEVMDialect noOutputDialect(*evmDialect); |
| 42 | |
| 43 | yul::AsmAnalysisInfo analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect( |
| 44 | noOutputDialect, |
| 45 | _object.code()->root(), |
| 46 | _object.summarizeStructure() |
| 47 | ); |
| 48 | |
| 49 | BuiltinContext builtinContext; |
| 50 | builtinContext.currentObject = &_object; |
| 51 | if (!_object.name.empty()) |
| 52 | builtinContext.subIDs[_object.name] = {1}; |
| 53 | for (auto const& subNode: _object.subObjects) |
| 54 | builtinContext.subIDs[subNode->name] = {1}; |
| 55 | NoOutputAssembly assembly{evmDialect->evmVersion()}; |
| 56 | CodeTransform transform( |
| 57 | assembly, |
| 58 | analysisInfo, |
| 59 | _object.code()->root(), |
| 60 | noOutputDialect, |
| 61 | builtinContext, |
| 62 | _optimizeStackAllocation |
| 63 | ); |
| 64 | transform(_object.code()->root()); |
| 65 | |
| 66 | for (StackTooDeepError const& error: transform.stackErrors()) |
| 67 | { |
| 68 | auto& unreachables = unreachableVariables[error.functionName]; |
| 69 | if (!util::contains(unreachables, error.variable)) |
| 70 | unreachables.emplace_back(error.variable); |
| 71 | int& deficit = stackDeficit[error.functionName]; |
| 72 | deficit = std::max(error.depth, deficit); |
| 73 | } |
| 74 | } |
| 75 | } |
nothing calls this directly
no test coverage detected