diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 2782245c60729568f3bdd27dfb6f447d4ed284b2..8e1d99e3c2b547ef3ad3b972e3d111480d1865f1 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -198,23 +198,23 @@ static int Run(Span args) return 1; } + int res; if (options->GetCompilationMode() == CompilationMode::PROJECT) { - diagnosticEngine.FlushDiagnostic(); - return CompileFromConfig(compiler, options.get(), diagnosticEngine); - } - - std::string sourceFile; - std::string_view parserInput; - if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { - sourceFile = "etsstdlib.ets"; - parserInput = ""; + res = CompileFromConfig(compiler, options.get(), diagnosticEngine); } else { - sourceFile = options->SourceFileName(); - auto [buf, size] = options->CStrParserInputContents(); - parserInput = std::string_view(buf, size); + std::string sourceFile; + std::string_view parserInput; + if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { + sourceFile = "etsstdlib.ets"; + parserInput = ""; + } else { + sourceFile = options->SourceFileName(); + auto [buf, size] = options->CStrParserInputContents(); + parserInput = std::string_view(buf, size); + } + es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); + res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); } - es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); - auto res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); diagnosticEngine.FlushDiagnostic(); return res; }