Show message in case of compilation error caused by exception
This commit is contained in:
committed by
Pavel Punegov
parent
83a56f1931
commit
6b2257792c
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.CLITool
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.WARNING
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
@@ -34,13 +33,15 @@ import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.config.kotlinSourceRoots
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.TargetManager
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
|
||||
override fun doExecute(@NotNull arguments: K2NativeCompilerArguments, @NotNull configuration: CompilerConfiguration, @NotNull rootDisposable: Disposable, @Nullable paths: KotlinPaths?): ExitCode {
|
||||
override fun doExecute(@NotNull arguments: K2NativeCompilerArguments,
|
||||
@NotNull configuration: CompilerConfiguration,
|
||||
@NotNull rootDisposable: Disposable,
|
||||
@Nullable paths: KotlinPaths?): ExitCode {
|
||||
|
||||
if (arguments.version) {
|
||||
println("Kotlin/Native: ${KonanVersion.CURRENT}")
|
||||
@@ -60,9 +61,15 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
runTopLevelPhases(konanConfig, environment)
|
||||
} catch (e: KonanCompilationException) {
|
||||
return ExitCode.COMPILATION_ERROR
|
||||
} catch (e: Throwable) {
|
||||
configuration.report(ERROR, """
|
||||
|Compilation failed with exception: ${e.message}, caused by ${e.cause?.message ?: ""}
|
||||
|
||||
|Source files: ${ environment.getSourceFiles().joinToString(transform = KtFile::getName) }
|
||||
""".trimMargin())
|
||||
throw e
|
||||
}
|
||||
|
||||
// TODO: catch Errors and IllegalStateException.
|
||||
return ExitCode.OK
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.context.MutableModuleContextImpl
|
||||
import org.jetbrains.kotlin.context.ProjectContext
|
||||
import org.jetbrains.kotlin.konan.util.visibleName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
@@ -56,8 +57,13 @@ object TopDownAnalyzerFacadeForKonan {
|
||||
config: KonanConfig
|
||||
): AnalysisResult {
|
||||
|
||||
// we print out each file we compile for now
|
||||
files.forEach{println(it)}
|
||||
val verbose = config.configuration.get(KonanConfigKeys.VERBOSE_PHASES)
|
||||
?.contains(KonanPhase.FRONTEND.visibleName)
|
||||
?: false
|
||||
if (verbose) {
|
||||
// we print out each file we compile for now
|
||||
files.forEach { println(it) }
|
||||
}
|
||||
|
||||
val analyzerForKonan = createTopDownAnalyzerForKonan(
|
||||
moduleContext, trace,
|
||||
|
||||
+1
-1
@@ -577,7 +577,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
/**
|
||||
* Binds LLVM function parameters to IR parameter descriptors.
|
||||
*/
|
||||
private fun bindParameters(descriptor: FunctionDescriptor?): Map<ParameterDescriptor, LLVMValueRef> {
|
||||
private fun bindParameters(descriptor: FunctionDescriptor?): Map<ParameterDescriptor, LLVMValueRef> {
|
||||
if (descriptor == null) return emptyMap()
|
||||
val parameterDescriptors = descriptor.allParameters
|
||||
return parameterDescriptors.mapIndexed { i, parameterDescriptor ->
|
||||
|
||||
Reference in New Issue
Block a user