| 4111 | } |
| 4112 | |
| 4113 | std::string YulUtilFunctions::packedHashFunction( |
| 4114 | std::vector<Type const*> const& _givenTypes, |
| 4115 | std::vector<Type const*> const& _targetTypes |
| 4116 | ) |
| 4117 | { |
| 4118 | std::string functionName = std::string("packed_hashed_"); |
| 4119 | for (auto const& t: _givenTypes) |
| 4120 | functionName += t->identifier() + "_"; |
| 4121 | functionName += "_to_"; |
| 4122 | for (auto const& t: _targetTypes) |
| 4123 | functionName += t->identifier() + "_"; |
| 4124 | size_t sizeOnStack = 0; |
| 4125 | for (Type const* t: _givenTypes) |
| 4126 | sizeOnStack += t->sizeOnStack(); |
| 4127 | return m_functionCollector.createFunction(functionName, [&]() { |
| 4128 | Whiskers templ(R"( |
| 4129 | function <functionName>(<variables>) -> hash { |
| 4130 | let pos := <allocateUnbounded>() |
| 4131 | let end := <packedEncode>(pos <comma> <variables>) |
| 4132 | hash := keccak256(pos, sub(end, pos)) |
| 4133 | } |
| 4134 | )"); |
| 4135 | templ("functionName", functionName); |
| 4136 | templ("variables", suffixedVariableNameList("var_", 1, 1 + sizeOnStack)); |
| 4137 | templ("comma", sizeOnStack > 0 ? "," : ""); |
| 4138 | templ("allocateUnbounded", allocateUnboundedFunction()); |
| 4139 | templ( |
| 4140 | "packedEncode", |
| 4141 | ABIFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector).tupleEncoderPacked(_givenTypes, _targetTypes) |
| 4142 | ); |
| 4143 | return templ.render(); |
| 4144 | }); |
| 4145 | } |
| 4146 | |
| 4147 | std::string YulUtilFunctions::forwardingRevertFunction() |
| 4148 | { |
no test coverage detected