Reorder code for readability

This commit is contained in:
Alex Beregszaszi 2017-07-18 14:43:10 +01:00
parent 7b0f877421
commit 33ac1f29b5

View File

@ -352,11 +352,6 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
)); ));
} }
Json::Value output = Json::objectValue;
if (errors.size() > 0)
output["errors"] = errors;
bool analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful; bool analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful;
bool compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful; bool compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful;
@ -364,15 +359,20 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
if (!compilationSuccess && (errors.size() == 0)) if (!compilationSuccess && (errors.size() == 0))
return formatFatalError("InternalCompilerError", "No error reported, but compilation failed."); return formatFatalError("InternalCompilerError", "No error reported, but compilation failed.");
Json::Value output = Json::objectValue;
if (errors.size() > 0)
output["errors"] = errors;
output["sources"] = Json::objectValue; output["sources"] = Json::objectValue;
unsigned sourceIndex = 0; unsigned sourceIndex = 0;
for (auto const& source: analysisSuccess ? m_compilerStack.sourceNames() : vector<string>()) for (string const& sourceName: analysisSuccess ? m_compilerStack.sourceNames() : vector<string>())
{ {
Json::Value sourceResult = Json::objectValue; Json::Value sourceResult = Json::objectValue;
sourceResult["id"] = sourceIndex++; sourceResult["id"] = sourceIndex++;
sourceResult["ast"] = ASTJsonConverter(false, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(source)); sourceResult["ast"] = ASTJsonConverter(false, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(sourceName));
sourceResult["legacyAST"] = ASTJsonConverter(true, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(source)); sourceResult["legacyAST"] = ASTJsonConverter(true, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(sourceName));
output["sources"][source] = sourceResult; output["sources"][sourceName] = sourceResult;
} }
Json::Value contractsOutput = Json::objectValue; Json::Value contractsOutput = Json::objectValue;