Add contract

This commit is contained in:
Bhargava Shastry 2021-04-22 10:49:03 +02:00
parent d86136679a
commit b3b72a2b91
3 changed files with 18 additions and 1 deletions

View File

@ -41,6 +41,7 @@
*
*/
#define GENERATORLIST(MACRO, SEP, ENDSEP) \
MACRO(ContractGenerator) SEP \
MACRO(ImportGenerator) SEP \
MACRO(PragmaGenerator) SEP \
MACRO(SourceUnitGenerator) SEP \

View File

@ -134,7 +134,8 @@ void SourceUnitGenerator::setup()
{
addGenerators({
{mutator->generator<ImportGenerator>(), s_maxImports},
{mutator->generator<PragmaGenerator>(), 1}
{mutator->generator<PragmaGenerator>(), 1},
{mutator->generator<ContractGenerator>(), 1}
});
}
@ -184,6 +185,11 @@ string ImportGenerator::visit()
return os.str();
}
string ContractGenerator::visit()
{
return "contract C {}\n";
}
template <typename T>
shared_ptr<T> SolidityGenerator::generator()
{

View File

@ -335,6 +335,16 @@ public:
std::string name() override { return "Import generator"; }
};
class ContractGenerator: public GeneratorBase
{
public:
explicit ContractGenerator(std::shared_ptr<SolidityGenerator> _mutator):
GeneratorBase(std::move(_mutator))
{}
std::string visit() override;
std::string name() override { return "Contract generator"; }
};
class SolidityGenerator: public std::enable_shared_from_this<SolidityGenerator>
{
public: