FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

/* 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 . */ // SPDX-License-Identifier: GPL-3.0 /** * @author Lefteris * @author Gav Wood * @date 2014 * Solidity command line interface. */ #include #include #include "license.h" #include "solidity/BuildInfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _WIN32 // windows #include #define isatty _isatty #define fileno _fileno #else // unix #include #endif #include #if !defined(STDERR_FILENO) #define STDERR_FILENO 2 #endif using namespace std::string_literals; using namespace solidity; using namespace solidity::util; using namespace solidity::langutil; namespace { std::set const CompilerInputModes{ frontend::InputMode::Compiler, frontend::InputMode::CompilerWithASTImport, }; } // anonymous namespace namespace solidity::frontend { std::ostream& CommandLineInterface::sout(bool _markAsUsed) { if (_markAsUsed) m_hasOutput = true; return m_sout; } std::ostream& CommandLineInterface::serr(bool _markAsUsed) { if (_markAsUsed) m_hasOutput = true; return m_serr; } #define cin #define cout #define cerr static std::string const g_stdinFileName = ""; static std::string const g_strAbi = "abi"; static std::string const g_strAsm = "asm"; static std::string const g_strAst = "ast"; static std::string const g_strBinary = "bin"; static std::string const g_strBinaryRuntime = "bin-runtime"; static std::string const g_strContracts = "contracts"; static std::string const g_strFunDebug = "function-debug"; static std::string const g_strFunDebugRuntime = "function-debug-runtime"; static std::string const g_strGeneratedSources = "generated-sources"; static std::string const g_strGeneratedSourcesRuntime = "generated-sources-runtime"; static std::string const g_strNatspecDev = "devdoc"; static std::string const g_strNatspecUser = "userdoc"; static std::string const g_strOpcodes = "opcodes"; static std::string const g_strSignatureHashes = "hashes"; static std::string const g_strSourceList = "sourceList"; static std::string const g_strSources = "sources"; static std::string const g_strSrcMap = "srcmap"; static std::string const g_strSrcMapRuntime = "srcmap-runtime"; static std::string const g_strStorageLayout = "storage-layout"; static std::string const g_strVersion = "version"; static bool needsHumanTargetedStdout(CommandLineOptions const& _options) { if (_options.compiler.estimateGas) return true; if (!_options.output.dir.empty()) return false; return _options.compiler.outputs.abi || _options.compiler.outputs.asm_ || _options.compiler.outputs.asmJson || _options.compiler.outputs.binary || _options.compiler.outputs.binaryRuntime || _options.compiler.outputs.metadata || _options.compiler.outputs.natspecUser || _options.compiler.outputs.natspecDev || _options.compiler.outputs.opcodes || _options.compiler.outputs.signatureHashes || _options.compiler.outputs.storageLayout; } static bool coloredOutput(CommandLineOptions const& _options) { return (!_options.formatting.coloredOutput.has_value() && isatty(STDERR_FILENO)) || (_options.formatting.coloredOutput.has_value() && _options.formatting.coloredOutput.value()); } void CommandLineInterface::handleEVMAssembly(std::string const& _contract) { solAssert(m_assemblyStack); solAssert( CompilerInputModes.count(m_options.input.mode) == 1 || m_options.input.mode == frontend::InputMode::EVMAssemblerJSON ); if (!m_options.compiler.outputs.asm_ && !m_options.compiler.outputs.asmJson) return; std::string assembly; if (m_options.compiler.outputs.asmJson) assembly = util::jsonPrint(removeNullMembers(m_assemblyStack->assemblyJSON(_contract)), m_options.formatting.json); else assembly = m_assemblyStack->assemblyString(_contract, m_fileReader.sourceUnits()); if (!m_options.output.dir.empty()) createFile( m_compiler->filesystemFriendlyName(_contract) + (m_options.compiler.outputs.asmJson ? "_evm.json" : ".evm"), assembly ); else sout()

Back | FazBrowse Home | New Git URL