mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Yul] leave statement.
This commit is contained in:
@@ -42,10 +42,11 @@ struct If;
|
||||
struct Loop;
|
||||
struct Break;
|
||||
struct BreakIf;
|
||||
struct Return;
|
||||
using Expression = boost::variant<
|
||||
Literal, StringLiteral, LocalVariable, GlobalVariable,
|
||||
FunctionCall, BuiltinCall, LocalAssignment, GlobalAssignment,
|
||||
Block, If, Loop, Break, BreakIf
|
||||
Block, If, Loop, Break, BreakIf, Return
|
||||
>;
|
||||
|
||||
struct Literal { uint64_t value; };
|
||||
@@ -65,6 +66,7 @@ struct If {
|
||||
};
|
||||
struct Loop { std::string labelName; std::vector<Expression> statements; };
|
||||
struct Break { Label label; };
|
||||
struct Return {};
|
||||
struct BreakIf { Label label; std::unique_ptr<Expression> condition; };
|
||||
|
||||
struct VariableDeclaration { std::string variableName; };
|
||||
|
||||
@@ -257,6 +257,11 @@ wasm::Expression EWasmCodeTransform::operator()(Continue const&)
|
||||
return wasm::Break{wasm::Label{m_breakContinueLabelNames.top().second}};
|
||||
}
|
||||
|
||||
wasm::Expression EWasmCodeTransform::operator()(Leave const&)
|
||||
{
|
||||
return wasm::Return{};
|
||||
}
|
||||
|
||||
wasm::Expression EWasmCodeTransform::operator()(Block const& _block)
|
||||
{
|
||||
return wasm::Block{{}, visit(_block.statements)};
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
wasm::Expression operator()(yul::ForLoop const&);
|
||||
wasm::Expression operator()(yul::Break const&);
|
||||
wasm::Expression operator()(yul::Continue const&);
|
||||
wasm::Expression operator()(yul::Leave const&);
|
||||
wasm::Expression operator()(yul::Block const& _block);
|
||||
|
||||
private:
|
||||
|
||||
@@ -128,6 +128,11 @@ string EWasmToText::operator()(wasm::BreakIf const& _break)
|
||||
return "(br_if $" + _break.label.name + " " + visit(*_break.condition) + ")\n";
|
||||
}
|
||||
|
||||
string EWasmToText::operator()(wasm::Return const&)
|
||||
{
|
||||
return "(return)\n";
|
||||
}
|
||||
|
||||
string EWasmToText::operator()(wasm::Block const& _block)
|
||||
{
|
||||
string label = _block.labelName.empty() ? "" : " $" + _block.labelName;
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
std::string operator()(wasm::If const& _if);
|
||||
std::string operator()(wasm::Loop const& _loop);
|
||||
std::string operator()(wasm::Break const& _break);
|
||||
std::string operator()(wasm::Return const& _return);
|
||||
std::string operator()(wasm::BreakIf const& _break);
|
||||
std::string operator()(wasm::Block const& _block);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user