Added hashFunction to Dialect. For EVMDialect, it is keccak256

In a later PR, the functions `storageLoadFunction`, `storageStoreFunctions`, etc will be refactored
to return a YulString instead of a pointer to a BuiltinFunction.
This commit is contained in:
hrkrshnn 2021-04-19 12:51:07 +02:00
parent dd6300a53e
commit 94f9410abe
2 changed files with 2 additions and 0 deletions

View File

@ -79,6 +79,7 @@ struct Dialect: boost::noncopyable
virtual BuiltinFunction const* memoryLoadFunction(YulString /* _type */) const { return nullptr; } virtual BuiltinFunction const* memoryLoadFunction(YulString /* _type */) const { return nullptr; }
virtual BuiltinFunction const* storageStoreFunction(YulString /* _type */) const { return nullptr; } virtual BuiltinFunction const* storageStoreFunction(YulString /* _type */) const { return nullptr; }
virtual BuiltinFunction const* storageLoadFunction(YulString /* _type */) const { return nullptr; } virtual BuiltinFunction const* storageLoadFunction(YulString /* _type */) const { return nullptr; }
virtual YulString hashFunction(YulString /* _type */ ) const { return YulString{}; }
/// Check whether the given type is legal for the given literal value. /// Check whether the given type is legal for the given literal value.
/// Should only be called if the type exists in the dialect at all. /// Should only be called if the type exists in the dialect at all.

View File

@ -81,6 +81,7 @@ struct EVMDialect: public Dialect
BuiltinFunctionForEVM const* memoryLoadFunction(YulString /*_type*/) const override { return builtin("mload"_yulstring); } BuiltinFunctionForEVM const* memoryLoadFunction(YulString /*_type*/) const override { return builtin("mload"_yulstring); }
BuiltinFunctionForEVM const* storageStoreFunction(YulString /*_type*/) const override { return builtin("sstore"_yulstring); } BuiltinFunctionForEVM const* storageStoreFunction(YulString /*_type*/) const override { return builtin("sstore"_yulstring); }
BuiltinFunctionForEVM const* storageLoadFunction(YulString /*_type*/) const override { return builtin("sload"_yulstring); } BuiltinFunctionForEVM const* storageLoadFunction(YulString /*_type*/) const override { return builtin("sload"_yulstring); }
YulString hashFunction(YulString /*_type*/) const override { return "keccak256"_yulstring; }
static EVMDialect const& strictAssemblyForEVM(langutil::EVMVersion _version); static EVMDialect const& strictAssemblyForEVM(langutil::EVMVersion _version);
static EVMDialect const& strictAssemblyForEVMObjects(langutil::EVMVersion _version); static EVMDialect const& strictAssemblyForEVMObjects(langutil::EVMVersion _version);