diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-01-04 20:04:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 20:04:19 +0800 |
commit | 2cdd789b5d371de6612dadb4ae9a18359cf150df (patch) | |
tree | 963ca2fdf9cf4859fb894205576592622ca934da /libjulia/optimiser/ASTCopier.h | |
parent | 14db10b21480ef0876e05ececa7e395ae05326a0 (diff) | |
parent | ca0d244bf7252e76b640f88fbefd6b497a4e9d09 (diff) | |
download | dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar.gz dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar.bz2 dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar.lz dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar.xz dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.tar.zst dexon-solidity-2cdd789b5d371de6612dadb4ae9a18359cf150df.zip |
Merge pull request #3297 from ethereum/separate_expression_and_statement
Separate expression and statement
Diffstat (limited to 'libjulia/optimiser/ASTCopier.h')
-rw-r--r-- | libjulia/optimiser/ASTCopier.h | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/libjulia/optimiser/ASTCopier.h b/libjulia/optimiser/ASTCopier.h index 5dde2ce9..36a1ced5 100644 --- a/libjulia/optimiser/ASTCopier.h +++ b/libjulia/optimiser/ASTCopier.h @@ -34,28 +34,55 @@ namespace dev namespace julia { +class ExpressionCopier: public boost::static_visitor<Expression> +{ +public: + virtual Expression operator()(Literal const& _literal) = 0; + virtual Expression operator()(Identifier const& _identifier) = 0; + virtual Expression operator()(FunctionalInstruction const& _instr) = 0; + virtual Expression operator()(FunctionCall const&) = 0; +}; + +class StatementCopier: public boost::static_visitor<Statement> +{ +public: + virtual Statement operator()(ExpressionStatement const& _statement) = 0; + virtual Statement operator()(Instruction const& _instruction) = 0; + virtual Statement operator()(Label const& _label) = 0; + virtual Statement operator()(StackAssignment const& _assignment) = 0; + virtual Statement operator()(Assignment const& _assignment) = 0; + virtual Statement operator()(VariableDeclaration const& _varDecl) = 0; + virtual Statement operator()(If const& _if) = 0; + virtual Statement operator()(Switch const& _switch) = 0; + virtual Statement operator()(FunctionDefinition const&) = 0; + virtual Statement operator()(ForLoop const&) = 0; + virtual Statement operator()(Block const& _block) = 0; +}; + /** * Creates a copy of a iulia AST potentially replacing identifier names. * Base class to be extended. */ -class ASTCopier: public boost::static_visitor<Statement> +class ASTCopier: public ExpressionCopier, public StatementCopier { public: - Statement operator()(Literal const& _literal); - Statement operator()(Instruction const& _instruction); - Statement operator()(Identifier const& _identifier); - Statement operator()(FunctionalInstruction const& _instr); - Statement operator()(FunctionCall const&); - Statement operator()(Label const& _label); - Statement operator()(StackAssignment const& _assignment); - Statement operator()(Assignment const& _assignment); - Statement operator()(VariableDeclaration const& _varDecl); - Statement operator()(If const& _if); - Statement operator()(Switch const& _switch); - Statement operator()(FunctionDefinition const&); - Statement operator()(ForLoop const&); - Statement operator()(Block const& _block); - + virtual Expression operator()(Literal const& _literal) override; + virtual Statement operator()(Instruction const& _instruction) override; + virtual Expression operator()(Identifier const& _identifier) override; + virtual Expression operator()(FunctionalInstruction const& _instr) override; + virtual Expression operator()(FunctionCall const&) override; + virtual Statement operator()(ExpressionStatement const& _statement) override; + virtual Statement operator()(Label const& _label) override; + virtual Statement operator()(StackAssignment const& _assignment) override; + virtual Statement operator()(Assignment const& _assignment) override; + virtual Statement operator()(VariableDeclaration const& _varDecl) override; + virtual Statement operator()(If const& _if) override; + virtual Statement operator()(Switch const& _switch) override; + virtual Statement operator()(FunctionDefinition const&) override; + virtual Statement operator()(ForLoop const&) override; + virtual Statement operator()(Block const& _block) override; + + virtual Expression translate(Expression const& _expression); virtual Statement translate(Statement const& _statement); protected: |