mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8293 from ethereum/fixTypedEVMTypes
Fix builtin function types for typed evm dialect.
This commit is contained in:
commit
814d4b6690
@ -151,13 +151,13 @@ bool ScopeFiller::registerVariable(TypedName const& _name, SourceLocation const&
|
|||||||
|
|
||||||
bool ScopeFiller::registerFunction(FunctionDefinition const& _funDef)
|
bool ScopeFiller::registerFunction(FunctionDefinition const& _funDef)
|
||||||
{
|
{
|
||||||
vector<Scope::YulType> arguments;
|
vector<Scope::YulType> parameters;
|
||||||
for (auto const& _argument: _funDef.parameters)
|
for (auto const& parameter: _funDef.parameters)
|
||||||
arguments.emplace_back(_argument.type.str());
|
parameters.emplace_back(parameter.type);
|
||||||
vector<Scope::YulType> returns;
|
vector<Scope::YulType> returns;
|
||||||
for (auto const& _return: _funDef.returnVariables)
|
for (auto const& returnVariable: _funDef.returnVariables)
|
||||||
returns.emplace_back(_return.type.str());
|
returns.emplace_back(returnVariable.type);
|
||||||
if (!m_currentScope->registerFunction(_funDef.name, std::move(arguments), std::move(returns)))
|
if (!m_currentScope->registerFunction(_funDef.name, std::move(parameters), std::move(returns)))
|
||||||
{
|
{
|
||||||
//@TODO secondary location
|
//@TODO secondary location
|
||||||
m_errorReporter.declarationError(
|
m_errorReporter.declarationError(
|
||||||
|
@ -221,6 +221,15 @@ EVMDialectTyped::EVMDialectTyped(langutil::EVMVersion _evmVersion, bool _objectA
|
|||||||
boolType = "bool"_yulstring;
|
boolType = "bool"_yulstring;
|
||||||
types = {defaultType, boolType};
|
types = {defaultType, boolType};
|
||||||
|
|
||||||
|
// Set all types to ``defaultType``
|
||||||
|
for (auto& fun: m_functions)
|
||||||
|
{
|
||||||
|
for (auto& p: fun.second.parameters)
|
||||||
|
p = defaultType;
|
||||||
|
for (auto& r: fun.second.returns)
|
||||||
|
r = defaultType;
|
||||||
|
}
|
||||||
|
|
||||||
m_functions["lt"_yulstring].returns = {"bool"_yulstring};
|
m_functions["lt"_yulstring].returns = {"bool"_yulstring};
|
||||||
m_functions["gt"_yulstring].returns = {"bool"_yulstring};
|
m_functions["gt"_yulstring].returns = {"bool"_yulstring};
|
||||||
m_functions["slt"_yulstring].returns = {"bool"_yulstring};
|
m_functions["slt"_yulstring].returns = {"bool"_yulstring};
|
||||||
@ -260,6 +269,7 @@ EVMDialectTyped::EVMDialectTyped(langutil::EVMVersion _evmVersion, bool _objectA
|
|||||||
_visitArguments();
|
_visitArguments();
|
||||||
}));
|
}));
|
||||||
m_functions["bool_to_u256"_yulstring].parameters = {"bool"_yulstring};
|
m_functions["bool_to_u256"_yulstring].parameters = {"bool"_yulstring};
|
||||||
|
m_functions["bool_to_u256"_yulstring].returns = {"u256"_yulstring};
|
||||||
m_functions.insert(createFunction("u256_to_bool", 1, 1, {}, false, [](
|
m_functions.insert(createFunction("u256_to_bool", 1, 1, {}, false, [](
|
||||||
FunctionCall const&,
|
FunctionCall const&,
|
||||||
AbstractAssembly& _assembly,
|
AbstractAssembly& _assembly,
|
||||||
@ -276,6 +286,7 @@ EVMDialectTyped::EVMDialectTyped(langutil::EVMVersion _evmVersion, bool _objectA
|
|||||||
_assembly.appendInstruction(evmasm::Instruction::INVALID);
|
_assembly.appendInstruction(evmasm::Instruction::INVALID);
|
||||||
_assembly.appendLabel(inRange);
|
_assembly.appendLabel(inRange);
|
||||||
}));
|
}));
|
||||||
|
m_functions["u256_to_bool"_yulstring].parameters = {"u256"_yulstring};
|
||||||
m_functions["u256_to_bool"_yulstring].returns = {"bool"_yulstring};
|
m_functions["u256_to_bool"_yulstring].returns = {"bool"_yulstring};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user