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(AssignmentStmtGenerator) SEP \
|
||||||
MACRO(BlockStmtGenerator) SEP \
|
MACRO(BlockStmtGenerator) SEP \
|
||||||
MACRO(ContractGenerator) SEP \
|
MACRO(ContractGenerator) SEP \
|
||||||
|
MACRO(ExpressionStmtGenerator) SEP \
|
||||||
MACRO(FunctionCallGenerator) SEP \
|
MACRO(FunctionCallGenerator) SEP \
|
||||||
MACRO(FunctionGenerator) SEP \
|
MACRO(FunctionGenerator) SEP \
|
||||||
MACRO(ImportGenerator) SEP \
|
MACRO(ImportGenerator) SEP \
|
||||||
|
@ -425,12 +425,24 @@ string AssignmentStmtGenerator::visit()
|
|||||||
return indentation() + lhs.value().second + assignOp(operation) + rhs.value().second + ";\n";
|
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()
|
void StatementGenerator::setup()
|
||||||
{
|
{
|
||||||
set<pair<GeneratorPtr, unsigned>> dependsOn = {
|
set<pair<GeneratorPtr, unsigned>> dependsOn = {
|
||||||
{mutator->generator<BlockStmtGenerator>(), 1},
|
{mutator->generator<BlockStmtGenerator>(), 1},
|
||||||
{mutator->generator<AssignmentStmtGenerator>(), 1},
|
{mutator->generator<AssignmentStmtGenerator>(), 1},
|
||||||
{mutator->generator<FunctionCallGenerator>(), 1}
|
{mutator->generator<FunctionCallGenerator>(), 1},
|
||||||
|
{mutator->generator<ExpressionStmtGenerator>(), 1}
|
||||||
};
|
};
|
||||||
addGenerators(std::move(dependsOn));
|
addGenerators(std::move(dependsOn));
|
||||||
}
|
}
|
||||||
|
@ -816,7 +816,6 @@ struct ExpressionGenerator
|
|||||||
std::pair<SolidityTypePtr, std::string>& _typeName
|
std::pair<SolidityTypePtr, std::string>& _typeName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
void incrementNestingDepth()
|
void incrementNestingDepth()
|
||||||
{
|
{
|
||||||
nestingDepth++;
|
nestingDepth++;
|
||||||
@ -1056,6 +1055,19 @@ private:
|
|||||||
static constexpr unsigned s_uncheckedBlockInvProb = 37;
|
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
|
class AssignmentStmtGenerator: public GeneratorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user