Merge pull request #10180 from ethereum/convertDuringStoring

[SolYul] Convert properly during storing.
This commit is contained in:
Đorđe Mijović 2020-11-03 08:42:14 +01:00 committed by GitHub
commit e0529989da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -2192,8 +2192,9 @@ string YulUtilFunctions::updateStorageValueFunction(
solAssert(_toType.storageBytes() > 0, "Invalid storage bytes size."); solAssert(_toType.storageBytes() > 0, "Invalid storage bytes size.");
return Whiskers(R"( return Whiskers(R"(
function <functionName>(slot, <offset>value) { function <functionName>(slot, <offset><fromValues>) {
sstore(slot, <update>(sload(slot), <offset><prepare>(value))) let <toValues> := <convert>(<fromValues>)
sstore(slot, <update>(sload(slot), <offset><prepare>(<toValues>)))
} }
)") )")
@ -2204,6 +2205,9 @@ string YulUtilFunctions::updateStorageValueFunction(
updateByteSliceFunctionDynamic(_toType.storageBytes()) updateByteSliceFunctionDynamic(_toType.storageBytes())
) )
("offset", _offset.has_value() ? "" : "offset, ") ("offset", _offset.has_value() ? "" : "offset, ")
("convert", conversionFunction(_fromType, _toType))
("fromValues", suffixedVariableNameList("value_", 0, _fromType.sizeOnStack()))
("toValues", suffixedVariableNameList("convertedValue_", 0, _toType.sizeOnStack()))
("prepare", prepareStoreFunction(_toType)) ("prepare", prepareStoreFunction(_toType))
.render(); .render();
} }

View File

@ -17,6 +17,8 @@ contract C {
} }
} }
// ====
// compileViaYul: also
// ---- // ----
// test_store_ok() -> 1 // test_store_ok() -> 1
// x() -> 0 // x() -> 0

View File

@ -18,6 +18,8 @@ contract D {
return (stateBool, stateDecimal, stateBytes); return (stateBool, stateDecimal, stateBytes);
} }
} }
// ====
// compileViaYul: also
// ---- // ----
// stateBool() -> true // stateBool() -> true
// stateBool() -> right(true) // stateBool() -> right(true)