Extract ErrorReportingContext from CommonBackendContext
This commit is contained in:
committed by
Space Team
parent
c22cad07ed
commit
0b2bc06870
+5
-3
@@ -27,10 +27,12 @@ interface LoggingContext {
|
|||||||
fun log(message: () -> String)
|
fun log(message: () -> String)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CommonBackendContext : BackendContext, LoggingContext {
|
interface ErrorReportingContext {
|
||||||
override val ir: Ir<CommonBackendContext>
|
|
||||||
|
|
||||||
fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
|
fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CommonBackendContext : BackendContext, LoggingContext, ErrorReportingContext {
|
||||||
|
override val ir: Ir<CommonBackendContext>
|
||||||
|
|
||||||
val configuration: CompilerConfiguration
|
val configuration: CompilerConfiguration
|
||||||
val scriptMode: Boolean
|
val scriptMode: Boolean
|
||||||
|
|||||||
+4
-4
@@ -5,19 +5,19 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan
|
package org.jetbrains.kotlin.backend.konan
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
import org.jetbrains.kotlin.backend.common.ErrorReportingContext
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
|
|
||||||
internal fun CommonBackendContext.reportCompilationError(message: String, irFile: IrFile, irElement: IrElement): Nothing {
|
internal fun ErrorReportingContext.reportCompilationError(message: String, irFile: IrFile, irElement: IrElement): Nothing {
|
||||||
report(irElement, irFile, message, true)
|
report(irElement, irFile, message, true)
|
||||||
throw KonanCompilationException()
|
throw KonanCompilationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun CommonBackendContext.reportCompilationError(message: String): Nothing {
|
internal fun ErrorReportingContext.reportCompilationError(message: String): Nothing {
|
||||||
report(null, null, message, true)
|
report(null, null, message, true)
|
||||||
throw KonanCompilationException()
|
throw KonanCompilationException()
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ internal fun CompilerConfiguration.reportCompilationError(message: String): Noth
|
|||||||
throw KonanCompilationException()
|
throw KonanCompilationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun CommonBackendContext.reportCompilationWarning(message: String) {
|
internal fun ErrorReportingContext.reportCompilationWarning(message: String) {
|
||||||
report(null, null, message, false)
|
report(null, null, message, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.ir.util
|
package org.jetbrains.kotlin.ir.util
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||||
|
import org.jetbrains.kotlin.backend.common.ErrorReportingContext
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanCompilationException
|
import org.jetbrains.kotlin.backend.konan.KonanCompilationException
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
||||||
@@ -126,7 +127,7 @@ tailrec fun IrDeclaration.getContainingFile(): IrFile? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun KonanBackendContext.report(declaration: IrDeclaration, message: String, isError: Boolean) {
|
internal fun ErrorReportingContext.report(declaration: IrDeclaration, message: String, isError: Boolean) {
|
||||||
val irFile = declaration.getContainingFile()
|
val irFile = declaration.getContainingFile()
|
||||||
this.report(
|
this.report(
|
||||||
declaration,
|
declaration,
|
||||||
|
|||||||
Reference in New Issue
Block a user