mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #107 from chriseth/warningsForSoljson
Support warnings.
This commit is contained in:
commit
7ff6762917
@ -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))
|
||||
{
|
||||
bool succ = compiler.compile(_input, _optimize);
|
||||
for (auto const& error: compiler.errors())
|
||||
errors.append(formatError(*error, "Error", compiler));
|
||||
}
|
||||
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,11 +168,10 @@ string compile(string _input, bool _optimize)
|
||||
}
|
||||
|
||||
if (errors.size() > 0)
|
||||
{
|
||||
output["errors"] = errors;
|
||||
return Json::FastWriter().write(output);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
output["contracts"] = Json::Value(Json::objectValue);
|
||||
for (string const& contractName: compiler.contractNames())
|
||||
{
|
||||
@ -188,6 +191,7 @@ string compile(string _input, bool _optimize)
|
||||
output["sources"] = Json::Value(Json::objectValue);
|
||||
output["sources"][""] = Json::Value(Json::objectValue);
|
||||
output["sources"][""]["AST"] = ASTJsonConverter(compiler.ast("")).json();
|
||||
}
|
||||
|
||||
return Json::FastWriter().write(output);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user