mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement function modifiers.
This commit is contained in:
@@ -40,8 +40,13 @@ class YulUtilFunctions;
|
||||
class IRGeneratorForStatements: public ASTConstVisitor
|
||||
{
|
||||
public:
|
||||
IRGeneratorForStatements(IRGenerationContext& _context, YulUtilFunctions& _utils):
|
||||
IRGeneratorForStatements(
|
||||
IRGenerationContext& _context,
|
||||
YulUtilFunctions& _utils,
|
||||
std::function<std::string()> _placeholderCallback = {}
|
||||
):
|
||||
m_context(_context),
|
||||
m_placeholderCallback(std::move(_placeholderCallback)),
|
||||
m_utils(_utils)
|
||||
{}
|
||||
|
||||
@@ -58,6 +63,9 @@ public:
|
||||
/// Calculates expression's value and returns variable where it was stored
|
||||
IRVariable evaluateExpression(Expression const& _expression, Type const& _to);
|
||||
|
||||
/// Defines @a _var using the value of @a _value while performing type conversions, if required.
|
||||
void define(IRVariable const& _var, IRVariable const& _value) { declareAssign(_var, _value, true); }
|
||||
|
||||
/// @returns the name of a function that computes the value of the given constant
|
||||
/// and also generates the function.
|
||||
std::string constantValueFunction(VariableDeclaration const& _constant);
|
||||
@@ -66,6 +74,7 @@ public:
|
||||
bool visit(Conditional const& _conditional) override;
|
||||
bool visit(Assignment const& _assignment) override;
|
||||
bool visit(TupleExpression const& _tuple) override;
|
||||
void endVisit(PlaceholderStatement const& _placeholder) override;
|
||||
bool visit(Block const& _block) override;
|
||||
void endVisit(Block const& _block) override;
|
||||
bool visit(IfStatement const& _ifStatement) override;
|
||||
@@ -135,8 +144,7 @@ private:
|
||||
/// @returns an output stream that can be used to define @a _var using a function call or
|
||||
/// single stack slot expression.
|
||||
std::ostream& define(IRVariable const& _var);
|
||||
/// Defines @a _var using the value of @a _value while performing type conversions, if required.
|
||||
void define(IRVariable const& _var, IRVariable const& _value) { declareAssign(_var, _value, true); }
|
||||
|
||||
/// Assigns @a _var to the value of @a _value while performing type conversions, if required.
|
||||
void assign(IRVariable const& _var, IRVariable const& _value) { declareAssign(_var, _value, false); }
|
||||
/// Declares variable @a _var.
|
||||
@@ -189,6 +197,7 @@ private:
|
||||
|
||||
std::ostringstream m_code;
|
||||
IRGenerationContext& m_context;
|
||||
std::function<std::string()> m_placeholderCallback;
|
||||
YulUtilFunctions& m_utils;
|
||||
std::optional<IRLValue> m_currentLValue;
|
||||
langutil::SourceLocation m_currentLocation;
|
||||
|
||||
Reference in New Issue
Block a user