diff options
author | chriseth <c@ethdev.com> | 2015-10-03 04:54:30 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-03 04:54:30 +0800 |
commit | 95fa516d9e856ced218be8817cc8c9a93289e8e2 (patch) | |
tree | bb2943ed1c7aa74f62c1b313185ac2b89a16123c /solc | |
parent | 795c894afc52033a9b5cd2d9fc223a1c4a09ac1b (diff) | |
download | dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar.gz dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar.bz2 dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar.lz dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar.xz dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.tar.zst dexon-solidity-95fa516d9e856ced218be8817cc8c9a93289e8e2.zip |
Support warnings.
Diffstat (limited to 'solc')
-rw-r--r-- | solc/jsonCompiler.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
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); } |