diff options
author | chriseth <chris@ethereum.org> | 2017-12-08 21:01:22 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-12-13 19:28:15 +0800 |
commit | 54b6739962ef45319777ce2aebafdf4b91412d84 (patch) | |
tree | d15c289ebb4e57b16678b93e223bc477e9093b6c /libjulia/optimiser/ASTCopier.cpp | |
parent | 7614b16dc9b2bb1e267e8f46834b40220fb9f9fb (diff) | |
download | dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar.gz dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar.bz2 dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar.lz dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar.xz dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.tar.zst dexon-solidity-54b6739962ef45319777ce2aebafdf4b91412d84.zip |
Separate expression and statement.
Diffstat (limited to 'libjulia/optimiser/ASTCopier.cpp')
-rw-r--r-- | libjulia/optimiser/ASTCopier.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libjulia/optimiser/ASTCopier.cpp b/libjulia/optimiser/ASTCopier.cpp index a461f434..5c47be64 100644 --- a/libjulia/optimiser/ASTCopier.cpp +++ b/libjulia/optimiser/ASTCopier.cpp @@ -37,6 +37,11 @@ Statement ASTCopier::operator()(Instruction const&) return {}; } +Statement ASTCopier::operator()(ExpressionStatement const& _statement) +{ + return ExpressionStatement{ _statement.location, translate(_statement.expression) }; +} + Statement ASTCopier::operator()(VariableDeclaration const& _varDecl) { return VariableDeclaration{ @@ -67,7 +72,7 @@ Statement ASTCopier::operator()(Label const&) return {}; } -Statement ASTCopier::operator()(FunctionCall const& _call) +Expression ASTCopier::operator()(FunctionCall const& _call) { return FunctionCall{ _call.location, @@ -76,7 +81,7 @@ Statement ASTCopier::operator()(FunctionCall const& _call) }; } -Statement ASTCopier::operator()(FunctionalInstruction const& _instruction) +Expression ASTCopier::operator()(FunctionalInstruction const& _instruction) { return FunctionalInstruction{ _instruction.location, @@ -85,12 +90,12 @@ Statement ASTCopier::operator()(FunctionalInstruction const& _instruction) }; } -Statement ASTCopier::operator()(Identifier const& _identifier) +Expression ASTCopier::operator()(Identifier const& _identifier) { return Identifier{_identifier.location, translateIdentifier(_identifier.name)}; } -Statement ASTCopier::operator()(Literal const& _literal) +Expression ASTCopier::operator()(Literal const& _literal) { return translate(_literal); } @@ -140,9 +145,14 @@ Statement ASTCopier::operator ()(Block const& _block) return translate(_block); } +Expression ASTCopier::translate(Expression const& _expression) +{ + return _expression.apply_visitor(static_cast<ExpressionCopier&>(*this)); +} + Statement ASTCopier::translate(Statement const& _statement) { - return boost::apply_visitor(*this, _statement); + return _statement.apply_visitor(static_cast<StatementCopier&>(*this)); } Block ASTCopier::translate(Block const& _block) |