diff options
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | solc/jsonCompiler.cpp | 54 | ||||
| -rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 24 |
3 files changed, 44 insertions, 42 deletions
@@ -1,10 +1,10 @@ # The Solidity Contract-Oriented Programming Language - +[](https://gitter.im/ethereum/solidity?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Useful links To get started you can find a basic introduction to the language in [Solidity Tutorial](https://github.com/ethereum/wiki/wiki/Solidity-Tutorial). -You can start using [Solidity in your browser](https://chriseth.github.io/browser-solidity/) with no need to download or compile anything. This application only supports compilation - if you want to inject it into the blockchain, you have to use a client like [Geth](https://github.com/ethereum/go-ethereum/wiki) or [AlethZero](https://github.com/ethereum/cpp-ethereum/wiki/Using-AlethZero). +You can start using [Solidity in your browser](https://chriseth.github.io/browser-solidity/) with no need to download or compile anything. This application only supports compilation - if you want to inject it into the blockchain, you have to use a client like [Geth](https://github.com/ethereum/go-ethereum/wiki) or [AlethZero](https://github.com/ethereum/alethzero). Also check out more documentations for [Solidity ABI](https://github.com/ethereum/wiki/wiki/Solidity,-Docs-and-ABI) and a crowdfunding [example contract](https://github.com/chriseth/cpp-ethereum/wiki/Crowdfunding-example-contract-in-Solidity) written in Solidity. @@ -16,7 +16,7 @@ Solidity is still under development. So please do not hesitate and open an [issu ## Building -See the [Wiki](https://github.com/ethereum/cpp-ethereum/wiki) for build instructions, compatibility information and build tips. +See the [Wiki](https://github.com/ethereum/webthree-umbrella/wiki) for build instructions, compatibility information and build tips. ## How to Contribute @@ -32,4 +32,4 @@ Please add yourself in the `@author` doxygen section of the file your are addin with the same wording as the one you listed yourself in the external contributors section above, only replacing the word **contribution** by **file** -Please read [CodingStandards.txt](CodingStandards.txt) thoroughly before making alterations to the code base. Please do *NOT* use an editor that automatically reformats whitespace away from astylerc or the formatting guidelines as described in [CodingStandards.txt](CodingStandards.txt). +Please read [CodingStandards.txt](https://github.com/ethereum/webthree-umbrella/blob/develop/CodingStandards.txt) thoroughly before making alterations to the code base. Please do *NOT* use an editor that automatically reformats whitespace away from astylerc or the formatting guidelines as described in [CodingStandards.txt](https://github.com/ethereum/webthree-umbrella/blob/develop/CodingStandards.txt). diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index ba3e6912..00fd0370 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -122,13 +122,17 @@ string compile(string _input, bool _optimize) Json::Value output(Json::objectValue); Json::Value errors(Json::arrayValue); CompilerStack compiler; + bool success = false; try { - if (!compiler.compile(_input, _optimize)) - { - for (auto const& error: compiler.errors()) - errors.append(formatError(*error, "Error", compiler)); - } + bool succ = compiler.compile(_input, _optimize); + for (auto const& error: compiler.errors()) + errors.append(formatError( + *error, + (dynamic_pointer_cast<Warning const>(error)) ? "Warning" : "Error", + compiler + )); + success = succ; // keep success false on exception } catch (ParserError const& exception) { @@ -164,30 +168,30 @@ string compile(string _input, bool _optimize) } if (errors.size() > 0) - { output["errors"] = errors; - return Json::FastWriter().write(output); - } - output["contracts"] = Json::Value(Json::objectValue); - for (string const& contractName: compiler.contractNames()) + if (success) { - Json::Value contractData(Json::objectValue); - contractData["solidity_interface"] = compiler.solidityInterface(contractName); - contractData["interface"] = compiler.interface(contractName); - contractData["bytecode"] = compiler.object(contractName).toHex(); - contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex(); - contractData["opcodes"] = eth::disassemble(compiler.object(contractName).bytecode); - contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName)); - contractData["gasEstimates"] = estimateGas(compiler, contractName); - ostringstream unused; - contractData["assembly"] = compiler.streamAssembly(unused, contractName, sources, true); - output["contracts"][contractName] = contractData; - } + output["contracts"] = Json::Value(Json::objectValue); + for (string const& contractName: compiler.contractNames()) + { + Json::Value contractData(Json::objectValue); + contractData["solidity_interface"] = compiler.solidityInterface(contractName); + contractData["interface"] = compiler.interface(contractName); + contractData["bytecode"] = compiler.object(contractName).toHex(); + contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex(); + contractData["opcodes"] = eth::disassemble(compiler.object(contractName).bytecode); + contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName)); + contractData["gasEstimates"] = estimateGas(compiler, contractName); + ostringstream unused; + contractData["assembly"] = compiler.streamAssembly(unused, contractName, sources, true); + output["contracts"][contractName] = contractData; + } - output["sources"] = Json::Value(Json::objectValue); - output["sources"][""] = Json::Value(Json::objectValue); - output["sources"][""]["AST"] = ASTJsonConverter(compiler.ast("")).json(); + output["sources"] = Json::Value(Json::objectValue); + output["sources"][""] = Json::Value(Json::objectValue); + output["sources"][""]["AST"] = ASTJsonConverter(compiler.ast("")).json(); + } return Json::FastWriter().write(output); } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 961c10b4..c386e2b4 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -72,22 +72,20 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false) globalContext->setCurrentContract(*contract); resolver.updateDeclaration(*globalContext->currentThis()); TypeChecker typeChecker; - if (!typeChecker.checkTypeRequirements(*contract)) + bool success = typeChecker.checkTypeRequirements(*contract); + BOOST_CHECK(success || !typeChecker.errors().empty()); + for (auto const& firstError: typeChecker.errors()) { - for (auto const& firstError: typeChecker.errors()) + if (_reportWarnings || !dynamic_pointer_cast<Warning const>(firstError)) { - if (_reportWarnings || !dynamic_pointer_cast<Warning const>(firstError)) - { - err = firstError; - break; - } - else if (_reportWarnings) - { - err = firstError; - break; - } + err = firstError; + break; + } + else if (_reportWarnings) + { + err = firstError; + break; } - break; } } } |
