Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-12-07 17:13:48 +01:00
34 changed files with 456 additions and 327 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ public:
}
VariableDeclaration const& declaration() const { return m_declaration; }
Kind kind() const { return m_occurrenceKind; };
Kind kind() const { return m_occurrenceKind; }
std::optional<langutil::SourceLocation> const& occurrence() const { return m_occurrence; }
private:
/// Declaration of the occurring variable.
+2 -1
View File
@@ -285,7 +285,8 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res
solAssert(_resolveInsideCode, "");
m_globalContext.setCurrentContract(*contract);
updateDeclaration(*m_globalContext.currentSuper());
if (!contract->isLibrary())
updateDeclaration(*m_globalContext.currentSuper());
updateDeclaration(*m_globalContext.currentThis());
for (ASTPointer<InheritanceSpecifier> const& baseContract: contract->baseContracts())
+16 -24
View File
@@ -219,23 +219,18 @@ string ABIFunctions::tupleDecoder(TypePointers const& _types, bool _fromMemory)
valueReturnParams.emplace_back("value" + to_string(stackPos));
stackPos++;
}
bool dynamic = decodingTypes[i]->isDynamicallyEncoded();
Whiskers elementTempl(
dynamic ?
R"(
Whiskers elementTempl(R"(
{
let offset := <load>(add(headStart, <pos>))
if gt(offset, 0xffffffffffffffff) { <revertString> }
<?dynamic>
let offset := <load>(add(headStart, <pos>))
if gt(offset, 0xffffffffffffffff) { <revertString> }
<!dynamic>
let offset := <pos>
</dynamic>
<values> := <abiDecode>(add(headStart, offset), dataEnd)
}
)" :
R"(
{
let offset := <pos>
<values> := <abiDecode>(add(headStart, offset), dataEnd)
}
)"
);
)");
elementTempl("dynamic", decodingTypes[i]->isDynamicallyEncoded());
// TODO add test
elementTempl("revertString", revertReasonIfDebug("ABI decoding: invalid tuple offset"));
elementTempl("load", _fromMemory ? "mload" : "calldataload");
@@ -1356,19 +1351,16 @@ string ABIFunctions::abiDecodingFunctionStruct(StructType const& _type, bool _fr
solAssert(!member.type->containsNestedMapping(), "");
auto decodingType = member.type->decodingType();
solAssert(decodingType, "");
bool dynamic = decodingType->isDynamicallyEncoded();
Whiskers memberTempl(
dynamic ?
R"(
Whiskers memberTempl(R"(
<?dynamic>
let offset := <load>(add(headStart, <pos>))
if gt(offset, 0xffffffffffffffff) { <revertString> }
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
)" :
R"(
<!dynamic>
let offset := <pos>
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
)"
);
</dynamic>
mstore(add(value, <memoryOffset>), <abiDecode>(add(headStart, offset), end))
)");
memberTempl("dynamic", decodingType->isDynamicallyEncoded());
// TODO add test
memberTempl("revertString", revertReasonIfDebug("ABI decoding: invalid struct offset"));
memberTempl("load", _fromMemory ? "mload" : "calldataload");
+1 -1
View File
@@ -135,7 +135,7 @@ public:
/// @returns a new copy of the utility function generator (but using the same function set).
YulUtilFunctions utils();
langutil::EVMVersion evmVersion() const { return m_evmVersion; };
langutil::EVMVersion evmVersion() const { return m_evmVersion; }
void setArithmetic(Arithmetic _value) { m_arithmetic = _value; }
Arithmetic arithmetic() const { return m_arithmetic; }
@@ -1462,7 +1462,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
solAssert(!functionType->gasSet(), "");
solAssert(!functionType->bound(), "");
static map<FunctionType::Kind, std::tuple<u160, size_t>> precompiles = {
static map<FunctionType::Kind, std::tuple<unsigned, size_t>> precompiles = {
{FunctionType::Kind::ECRecover, std::make_tuple(1, 0)},
{FunctionType::Kind::SHA256, std::make_tuple(2, 0)},
{FunctionType::Kind::RIPEMD160, std::make_tuple(3, 12)},