mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce expression statement.
This commit is contained in:
parent
c5f92c6bdc
commit
c007e16ee5
@ -44,6 +44,7 @@
|
||||
MACRO(AssignmentStmtGenerator) SEP \
|
||||
MACRO(BlockStmtGenerator) SEP \
|
||||
MACRO(ContractGenerator) SEP \
|
||||
MACRO(ExpressionStmtGenerator) SEP \
|
||||
MACRO(FunctionCallGenerator) SEP \
|
||||
MACRO(FunctionGenerator) SEP \
|
||||
MACRO(ImportGenerator) SEP \
|
||||
|
@ -425,12 +425,24 @@ string AssignmentStmtGenerator::visit()
|
||||
return indentation() + lhs.value().second + assignOp(operation) + rhs.value().second + ";\n";
|
||||
}
|
||||
|
||||
string ExpressionStmtGenerator::visit()
|
||||
{
|
||||
ExpressionGenerator exprGen{state};
|
||||
auto randomType = TypeProvider{state}.type();
|
||||
auto expression = exprGen.rOrLValueExpression({randomType, {}});
|
||||
if (expression.has_value())
|
||||
return indentation() + expression.value().second + ";\n";
|
||||
else
|
||||
return "\n";
|
||||
}
|
||||
|
||||
void StatementGenerator::setup()
|
||||
{
|
||||
set<pair<GeneratorPtr, unsigned>> dependsOn = {
|
||||
{mutator->generator<BlockStmtGenerator>(), 1},
|
||||
{mutator->generator<AssignmentStmtGenerator>(), 1},
|
||||
{mutator->generator<FunctionCallGenerator>(), 1}
|
||||
{mutator->generator<FunctionCallGenerator>(), 1},
|
||||
{mutator->generator<ExpressionStmtGenerator>(), 1}
|
||||
};
|
||||
addGenerators(std::move(dependsOn));
|
||||
}
|
||||
|
@ -816,7 +816,6 @@ struct ExpressionGenerator
|
||||
std::pair<SolidityTypePtr, std::string>& _typeName
|
||||
);
|
||||
|
||||
|
||||
void incrementNestingDepth()
|
||||
{
|
||||
nestingDepth++;
|
||||
@ -1056,6 +1055,19 @@ private:
|
||||
static constexpr unsigned s_uncheckedBlockInvProb = 37;
|
||||
};
|
||||
|
||||
class ExpressionStmtGenerator: public GeneratorBase
|
||||
{
|
||||
public:
|
||||
explicit ExpressionStmtGenerator(SolidityGenerator* _mutator):
|
||||
GeneratorBase(std::move(_mutator))
|
||||
{}
|
||||
std::string visit() override;
|
||||
std::string name() override
|
||||
{
|
||||
return "Expression statement generator";
|
||||
}
|
||||
};
|
||||
|
||||
class AssignmentStmtGenerator: public GeneratorBase
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user