diff --git a/Changelog.md b/Changelog.md index 224a8331c..84c8dffc2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### 0.6.0 (unreleased) Breaking changes: + * Commandline interface: remove the text-based ast printer (``--ast``). * General: Disallow explicit conversions from external function types to ``address`` and add a member called ``address`` to them as replacement. * Type checker: Resulting type of exponentiation is equal to the type of the base. Also allow signed types for the base. diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 5b2e9b8ca..b8c518bc5 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -14,7 +14,7 @@ Using the Commandline Compiler One of the build targets of the Solidity repository is ``solc``, the solidity commandline compiler. Using ``solc --help`` provides you with an explanation of all options. The compiler can produce various outputs, ranging from simple binaries and assembly over an abstract syntax tree (parse tree) to estimations of gas usage. -If you only want to compile a single file, you run it as ``solc --bin sourceFile.sol`` and it will print the binary. If you want to get some of the more advanced output variants of ``solc``, it is probably better to tell it to output everything to separate files using ``solc -o outputDirectory --bin --ast --asm sourceFile.sol``. +If you only want to compile a single file, you run it as ``solc --bin sourceFile.sol`` and it will print the binary. If you want to get some of the more advanced output variants of ``solc``, it is probably better to tell it to output everything to separate files using ``solc -o outputDirectory --bin --ast-json --asm sourceFile.sol``. Before you deploy your contract, activate the optimizer when compiling using ``solc --optimize --bin sourceFile.sol``. By default, the optimizer will optimize the contract assuming it is called 200 times across its lifetime diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 81e86e621..384d3cb6c 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -39,8 +39,6 @@ set(sources ast/ASTForward.h ast/ASTJsonConverter.cpp ast/ASTJsonConverter.h - ast/ASTPrinter.cpp - ast/ASTPrinter.h ast/ASTVisitor.h ast/ExperimentalFeatures.h ast/Types.cpp diff --git a/libsolidity/ast/ASTPrinter.cpp b/libsolidity/ast/ASTPrinter.cpp deleted file mode 100644 index 1d9f40876..000000000 --- a/libsolidity/ast/ASTPrinter.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** - * @author Christian - * @date 2014 - * Pretty-printer for the abstract syntax tree (the "pretty" is arguable), used for debugging. - */ - -#include - -#include -#include -#include - -using namespace std; -using namespace langutil; - -namespace dev -{ -namespace solidity -{ - -ASTPrinter::ASTPrinter( - ASTNode const& _ast, - string const& _source, - GasEstimator::ASTGasConsumption const& _gasCosts -): m_indentation(0), m_source(_source), m_ast(&_ast), m_gasCosts(_gasCosts) -{ -} - -void ASTPrinter::print(ostream& _stream) -{ - m_ostream = &_stream; - m_ast->accept(*this); - m_ostream = nullptr; -} - - -bool ASTPrinter::visit(PragmaDirective const& _node) -{ - writeLine("PragmaDirective"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ImportDirective const& _node) -{ - writeLine("ImportDirective \"" + _node.path() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ContractDefinition const& _node) -{ - writeLine("ContractDefinition \"" + _node.name() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(InheritanceSpecifier const& _node) -{ - writeLine("InheritanceSpecifier"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(UsingForDirective const& _node) -{ - writeLine("UsingForDirective"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(StructDefinition const& _node) -{ - writeLine("StructDefinition \"" + _node.name() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(EnumDefinition const& _node) -{ - writeLine("EnumDefinition \"" + _node.name() + "\""); - return goDeeper(); -} - -bool ASTPrinter::visit(EnumValue const& _node) -{ - writeLine("EnumValue \"" + _node.name() + "\""); - return goDeeper(); -} - -bool ASTPrinter::visit(ParameterList const& _node) -{ - writeLine("ParameterList"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(OverrideSpecifier const& _node) -{ - writeLine("OverrideSpecifier"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(FunctionDefinition const& _node) -{ - writeLine( - "FunctionDefinition \"" + - _node.name() + - "\"" + - (_node.isPublic() ? " - public" : "") + - (_node.stateMutability() == StateMutability::View ? " - const" : "") - ); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(VariableDeclaration const& _node) -{ - writeLine("VariableDeclaration \"" + _node.name() + "\""); - *m_ostream << indentation() << ( - _node.annotation().type ? - string(" Type: ") + _node.annotation().type->toString() : - string(" Type unknown.") - ) << "\n"; - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ModifierDefinition const& _node) -{ - writeLine("ModifierDefinition \"" + _node.name() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ModifierInvocation const& _node) -{ - writeLine("ModifierInvocation \"" + _node.name()->name() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(EventDefinition const& _node) -{ - writeLine("EventDefinition \"" + _node.name() + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ElementaryTypeName const& _node) -{ - writeLine(string("ElementaryTypeName ") + _node.typeName().toString()); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(UserDefinedTypeName const& _node) -{ - writeLine("UserDefinedTypeName \"" + boost::algorithm::join(_node.namePath(), ".") + "\""); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(FunctionTypeName const& _node) -{ - writeLine("FunctionTypeName"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Mapping const& _node) -{ - writeLine("Mapping"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ArrayTypeName const& _node) -{ - writeLine("ArrayTypeName"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(InlineAssembly const& _node) -{ - writeLine("InlineAssembly"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Block const& _node) -{ - writeLine("Block"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(PlaceholderStatement const& _node) -{ - writeLine("PlaceholderStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(IfStatement const& _node) -{ - writeLine("IfStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(WhileStatement const& _node) -{ - writeLine(_node.isDoWhile() ? "DoWhileStatement" : "WhileStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ForStatement const& _node) -{ - writeLine("ForStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Continue const& _node) -{ - writeLine("Continue"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Break const& _node) -{ - writeLine("Break"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Return const& _node) -{ - writeLine("Return"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Throw const& _node) -{ - writeLine("Throw"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(EmitStatement const& _node) -{ - writeLine("EmitStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(VariableDeclarationStatement const& _node) -{ - writeLine("VariableDeclarationStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ExpressionStatement const& _node) -{ - writeLine("ExpressionStatement"); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Conditional const& _node) -{ - writeLine("Conditional"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Assignment const& _node) -{ - writeLine(string("Assignment using operator ") + TokenTraits::toString(_node.assignmentOperator())); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(TupleExpression const& _node) -{ - writeLine(string("TupleExpression")); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(UnaryOperation const& _node) -{ - writeLine( - string("UnaryOperation (") + - (_node.isPrefixOperation() ? "prefix" : "postfix") + - ") " + - TokenTraits::toString(_node.getOperator()) - ); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(BinaryOperation const& _node) -{ - writeLine(string("BinaryOperation using operator ") + TokenTraits::toString(_node.getOperator())); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(FunctionCall const& _node) -{ - writeLine("FunctionCall"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(NewExpression const& _node) -{ - writeLine("NewExpression"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(MemberAccess const& _node) -{ - writeLine("MemberAccess to member " + _node.memberName()); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(IndexAccess const& _node) -{ - writeLine("IndexAccess"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Identifier const& _node) -{ - writeLine(string("Identifier ") + _node.name()); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(ElementaryTypeNameExpression const& _node) -{ - writeLine(string("ElementaryTypeNameExpression ") + _node.typeName().toString()); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -bool ASTPrinter::visit(Literal const& _node) -{ - char const* tokenString = TokenTraits::toString(_node.token()); - if (!tokenString) - tokenString = "[no token]"; - writeLine(string("Literal, token: ") + tokenString + " value: " + _node.value()); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - -void ASTPrinter::endVisit(PragmaDirective const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ImportDirective const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ContractDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(InheritanceSpecifier const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(UsingForDirective const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(StructDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(EnumDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(EnumValue const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ParameterList const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(OverrideSpecifier const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(FunctionDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(VariableDeclaration const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ModifierDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ModifierInvocation const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(EventDefinition const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ElementaryTypeName const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(UserDefinedTypeName const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(FunctionTypeName const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Mapping const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ArrayTypeName const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(InlineAssembly const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Block const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(PlaceholderStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(IfStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(WhileStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ForStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Continue const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Break const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Return const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Throw const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(EmitStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(VariableDeclarationStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ExpressionStatement const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Conditional const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Assignment const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(TupleExpression const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(UnaryOperation const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(BinaryOperation const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(FunctionCall const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(NewExpression const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(MemberAccess const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(IndexAccess const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Identifier const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(ElementaryTypeNameExpression const&) -{ - m_indentation--; -} - -void ASTPrinter::endVisit(Literal const&) -{ - m_indentation--; -} - -void ASTPrinter::printSourcePart(ASTNode const& _node) -{ - if (m_gasCosts.count(&_node)) - *m_ostream << indentation() << " Gas costs: " << m_gasCosts.at(&_node) << endl; - if (!m_source.empty()) - { - SourceLocation const& location(_node.location()); - *m_ostream << - indentation() << - " Source: " << - Json::valueToQuotedString(m_source.substr(location.start, location.end - location.start).c_str()) << - endl; - } -} - -void ASTPrinter::printType(Expression const& _expression) -{ - if (_expression.annotation().type) - *m_ostream << indentation() << " Type: " << _expression.annotation().type->toString() << "\n"; - else - *m_ostream << indentation() << " Type unknown.\n"; -} - -string ASTPrinter::indentation() const -{ - return string(m_indentation * 2, ' '); -} - -void ASTPrinter::writeLine(string const& _line) -{ - *m_ostream << indentation() << _line << endl; -} - -} -} diff --git a/libsolidity/ast/ASTPrinter.h b/libsolidity/ast/ASTPrinter.h deleted file mode 100644 index 697db4378..000000000 --- a/libsolidity/ast/ASTPrinter.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** - * @author Christian - * @date 2014 - * Pretty-printer for the abstract syntax tree (the "pretty" is arguable), used for debugging. - */ - -#pragma once - -#include -#include -#include - -namespace dev -{ -namespace solidity -{ - -/** - * Pretty-printer for the abstract syntax tree (the "pretty" is arguable) for debugging purposes. - */ -class ASTPrinter: public ASTConstVisitor -{ -public: - /// Create a printer for the given abstract syntax tree. If the source is specified, - /// the corresponding parts of the source are printed with each node. - ASTPrinter( - ASTNode const& _ast, - std::string const& _source = std::string(), - GasEstimator::ASTGasConsumption const& _gasCosts = GasEstimator::ASTGasConsumption() - ); - /// Output the string representation of the AST to _stream. - void print(std::ostream& _stream); - - bool visit(PragmaDirective const& _node) override; - bool visit(ImportDirective const& _node) override; - bool visit(ContractDefinition const& _node) override; - bool visit(InheritanceSpecifier const& _node) override; - bool visit(UsingForDirective const& _node) override; - bool visit(StructDefinition const& _node) override; - bool visit(EnumDefinition const& _node) override; - bool visit(EnumValue const& _node) override; - bool visit(ParameterList const& _node) override; - bool visit(OverrideSpecifier const& _node) override; - bool visit(FunctionDefinition const& _node) override; - bool visit(VariableDeclaration const& _node) override; - bool visit(ModifierDefinition const& _node) override; - bool visit(ModifierInvocation const& _node) override; - bool visit(EventDefinition const& _node) override; - bool visit(ElementaryTypeName const& _node) override; - bool visit(UserDefinedTypeName const& _node) override; - bool visit(FunctionTypeName const& _node) override; - bool visit(Mapping const& _node) override; - bool visit(ArrayTypeName const& _node) override; - bool visit(InlineAssembly const& _node) override; - bool visit(Block const& _node) override; - bool visit(PlaceholderStatement const& _node) override; - bool visit(IfStatement const& _node) override; - bool visit(WhileStatement const& _node) override; - bool visit(ForStatement const& _node) override; - bool visit(Continue const& _node) override; - bool visit(Break const& _node) override; - bool visit(Return const& _node) override; - bool visit(Throw const& _node) override; - bool visit(EmitStatement const& _node) override; - bool visit(VariableDeclarationStatement const& _node) override; - bool visit(ExpressionStatement const& _node) override; - bool visit(Conditional const& _node) override; - bool visit(Assignment const& _node) override; - bool visit(TupleExpression const& _node) override; - bool visit(UnaryOperation const& _node) override; - bool visit(BinaryOperation const& _node) override; - bool visit(FunctionCall const& _node) override; - bool visit(NewExpression const& _node) override; - bool visit(MemberAccess const& _node) override; - bool visit(IndexAccess const& _node) override; - bool visit(Identifier const& _node) override; - bool visit(ElementaryTypeNameExpression const& _node) override; - bool visit(Literal const& _node) override; - - void endVisit(PragmaDirective const&) override; - void endVisit(ImportDirective const&) override; - void endVisit(ContractDefinition const&) override; - void endVisit(InheritanceSpecifier const&) override; - void endVisit(UsingForDirective const&) override; - void endVisit(StructDefinition const&) override; - void endVisit(EnumDefinition const&) override; - void endVisit(EnumValue const&) override; - void endVisit(ParameterList const&) override; - void endVisit(OverrideSpecifier const&) override; - void endVisit(FunctionDefinition const&) override; - void endVisit(VariableDeclaration const&) override; - void endVisit(ModifierDefinition const&) override; - void endVisit(ModifierInvocation const&) override; - void endVisit(EventDefinition const&) override; - void endVisit(ElementaryTypeName const&) override; - void endVisit(UserDefinedTypeName const&) override; - void endVisit(FunctionTypeName const&) override; - void endVisit(Mapping const&) override; - void endVisit(ArrayTypeName const&) override; - void endVisit(InlineAssembly const&) override; - void endVisit(Block const&) override; - void endVisit(PlaceholderStatement const&) override; - void endVisit(IfStatement const&) override; - void endVisit(WhileStatement const&) override; - void endVisit(ForStatement const&) override; - void endVisit(Continue const&) override; - void endVisit(Break const&) override; - void endVisit(Return const&) override; - void endVisit(Throw const&) override; - void endVisit(EmitStatement const&) override; - void endVisit(VariableDeclarationStatement const&) override; - void endVisit(ExpressionStatement const&) override; - void endVisit(Conditional const&) override; - void endVisit(Assignment const&) override; - void endVisit(TupleExpression const&) override; - void endVisit(UnaryOperation const&) override; - void endVisit(BinaryOperation const&) override; - void endVisit(FunctionCall const&) override; - void endVisit(NewExpression const&) override; - void endVisit(MemberAccess const&) override; - void endVisit(IndexAccess const&) override; - void endVisit(Identifier const&) override; - void endVisit(ElementaryTypeNameExpression const&) override; - void endVisit(Literal const&) override; - -private: - void printSourcePart(ASTNode const& _node); - void printType(Expression const& _expression); - std::string indentation() const; - void writeLine(std::string const& _line); - bool goDeeper() { m_indentation++; return true; } - - int m_indentation; - std::string m_source; - ASTNode const* m_ast; - GasEstimator::ASTGasConsumption m_gasCosts; - std::ostream* m_ostream = nullptr; -}; - -} -} diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 79d85d82f..f73bccba4 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -158,7 +157,6 @@ static string const g_argAllowPaths = g_strAllowPaths; static string const g_argAsm = g_strAsm; static string const g_argAsmJson = g_strAsmJson; static string const g_argAssemble = g_strAssemble; -static string const g_argAst = g_strAst; static string const g_argAstCompactJson = g_strAstCompactJson; static string const g_argAstJson = g_strAstJson; static string const g_argBinary = g_strBinary; @@ -711,7 +709,6 @@ Allowed options)", (g_argIgnoreMissingFiles.c_str(), "Ignore missing files."); po::options_description outputComponents("Output Components"); outputComponents.add_options() - (g_argAst.c_str(), "AST of all source files.") (g_argAstJson.c_str(), "AST of all source files in JSON format.") (g_argAstCompactJson.c_str(), "AST of all source files in a compact JSON format.") (g_argAsm.c_str(), "EVM assembly of the contracts.") @@ -1108,9 +1105,7 @@ void CommandLineInterface::handleAst(string const& _argStr) { string title; - if (_argStr == g_argAst) - title = "Syntax trees:"; - else if (_argStr == g_argAstJson) + if (_argStr == g_argAstJson) title = "JSON AST:"; else if (_argStr == g_argAstCompactJson) title = "JSON AST (compact format):"; @@ -1143,16 +1138,8 @@ void CommandLineInterface::handleAst(string const& _argStr) { stringstream data; string postfix = ""; - if (_argStr == g_argAst) - { - ASTPrinter printer(m_compiler->ast(sourceCode.first), sourceCode.second); - printer.print(data); - } - else - { - ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first)); - postfix += "_json"; - } + ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first)); + postfix += "_json"; boost::filesystem::path path(sourceCode.first); createFile(path.filename().string() + postfix + ".ast", data.str()); } @@ -1163,17 +1150,7 @@ void CommandLineInterface::handleAst(string const& _argStr) for (auto const& sourceCode: m_sourceCodes) { sout() << endl << "======= " << sourceCode.first << " =======" << endl; - if (_argStr == g_argAst) - { - ASTPrinter printer( - m_compiler->ast(sourceCode.first), - sourceCode.second, - gasCosts - ); - printer.print(sout()); - } - else - ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(sout(), m_compiler->ast(sourceCode.first)); + ASTJsonConverter(legacyFormat, m_compiler->sourceIndices()).print(sout(), m_compiler->ast(sourceCode.first)); } } } @@ -1398,7 +1375,6 @@ void CommandLineInterface::outputCompilationResults() handleCombinedJSON(); // do we need AST output? - handleAst(g_argAst); handleAst(g_argAstJson); handleAst(g_argAstCompactJson);