JS IR IC: invalid loops references exist after lowerings
This commit is contained in:
committed by
teamcityserver
parent
0130d18ea9
commit
c6ab195a87
+23
-6
@@ -82,6 +82,7 @@ class IrBodyDeserializer(
|
|||||||
private val declarationDeserializer: IrDeclarationDeserializer,
|
private val declarationDeserializer: IrDeclarationDeserializer,
|
||||||
private val statementOriginIndex: Map<String, IrStatementOrigin>,
|
private val statementOriginIndex: Map<String, IrStatementOrigin>,
|
||||||
private val allowErrorStatementOrigins: Boolean, // TODO: support InlinerExpressionLocationHint
|
private val allowErrorStatementOrigins: Boolean, // TODO: support InlinerExpressionLocationHint
|
||||||
|
private val allowErrorLoopIndices: Boolean, // TODO: fix lowerings, which reference out-of-scope loops
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val fileLoops = mutableMapOf<Int, IrLoop>()
|
private val fileLoops = mutableMapOf<Int, IrLoop>()
|
||||||
@@ -501,7 +502,8 @@ class IrBodyDeserializer(
|
|||||||
|
|
||||||
val delegate = declarationDeserializer.deserializeIrSymbolAndRemap(proto.delegate) as IrVariableSymbol
|
val delegate = declarationDeserializer.deserializeIrSymbolAndRemap(proto.delegate) as IrVariableSymbol
|
||||||
val getter = declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol
|
val getter = declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol
|
||||||
val setter = if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null
|
val setter =
|
||||||
|
if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null
|
||||||
val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrLocalDelegatedPropertySymbol
|
val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrLocalDelegatedPropertySymbol
|
||||||
val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null
|
val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null
|
||||||
|
|
||||||
@@ -520,8 +522,10 @@ class IrBodyDeserializer(
|
|||||||
val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrPropertySymbol
|
val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrPropertySymbol
|
||||||
|
|
||||||
val field = if (proto.hasField()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.field) as IrFieldSymbol else null
|
val field = if (proto.hasField()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.field) as IrFieldSymbol else null
|
||||||
val getter = if (proto.hasGetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol else null
|
val getter =
|
||||||
val setter = if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null
|
if (proto.hasGetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol else null
|
||||||
|
val setter =
|
||||||
|
if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null
|
||||||
val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null
|
val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null
|
||||||
|
|
||||||
val callable = IrPropertyReferenceImpl(
|
val callable = IrPropertyReferenceImpl(
|
||||||
@@ -772,7 +776,13 @@ class IrBodyDeserializer(
|
|||||||
private fun deserializeBreak(proto: ProtoBreak, start: Int, end: Int, type: IrType): IrBreak {
|
private fun deserializeBreak(proto: ProtoBreak, start: Int, end: Int, type: IrType): IrBreak {
|
||||||
val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null
|
val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null
|
||||||
val loopId = proto.loopId
|
val loopId = proto.loopId
|
||||||
val loop = deserializeLoopHeader(loopId) { error("break clause before loop header") }
|
val loop = deserializeLoopHeader(loopId) {
|
||||||
|
if (allowErrorLoopIndices) {
|
||||||
|
IrWhileLoopImpl(-1, -1, builtIns.unitType, null)
|
||||||
|
} else {
|
||||||
|
error("break clause before loop header")
|
||||||
|
}
|
||||||
|
}
|
||||||
val irBreak = IrBreakImpl(start, end, type, loop)
|
val irBreak = IrBreakImpl(start, end, type, loop)
|
||||||
irBreak.label = label
|
irBreak.label = label
|
||||||
|
|
||||||
@@ -782,7 +792,13 @@ class IrBodyDeserializer(
|
|||||||
private fun deserializeContinue(proto: ProtoContinue, start: Int, end: Int, type: IrType): IrContinue {
|
private fun deserializeContinue(proto: ProtoContinue, start: Int, end: Int, type: IrType): IrContinue {
|
||||||
val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null
|
val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null
|
||||||
val loopId = proto.loopId
|
val loopId = proto.loopId
|
||||||
val loop = deserializeLoopHeader(loopId) { error("continue clause before loop header") }
|
val loop = deserializeLoopHeader(loopId) {
|
||||||
|
if (allowErrorLoopIndices) {
|
||||||
|
IrWhileLoopImpl(-1, -1, builtIns.unitType, null)
|
||||||
|
} else {
|
||||||
|
error("break clause before loop header")
|
||||||
|
}
|
||||||
|
}
|
||||||
val irContinue = IrContinueImpl(start, end, type, loop)
|
val irContinue = IrContinueImpl(start, end, type, loop)
|
||||||
irContinue.label = label
|
irContinue.label = label
|
||||||
|
|
||||||
@@ -881,7 +897,8 @@ class IrBodyDeserializer(
|
|||||||
it.startsWith(componentPrefix) -> {
|
it.startsWith(componentPrefix) -> {
|
||||||
IrStatementOrigin.COMPONENT_N.withIndex(it.removePrefix(componentPrefix).toInt())
|
IrStatementOrigin.COMPONENT_N.withIndex(it.removePrefix(componentPrefix).toInt())
|
||||||
}
|
}
|
||||||
else -> statementOriginIndex[it] ?: if (allowErrorStatementOrigins) object : IrStatementOriginImpl(it) {} else error("Unexpected statement origin: $it")
|
else -> statementOriginIndex[it] ?: if (allowErrorStatementOrigins) object :
|
||||||
|
IrStatementOriginImpl(it) {} else error("Unexpected statement origin: $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -71,10 +71,20 @@ class IrDeclarationDeserializer(
|
|||||||
additionalStatementOriginIndex: Map<String, IrStatementOrigin> = emptyMap(),
|
additionalStatementOriginIndex: Map<String, IrStatementOrigin> = emptyMap(),
|
||||||
allowErrorStatementOrigins: Boolean = false,
|
allowErrorStatementOrigins: Boolean = false,
|
||||||
private val compatibilityMode: CompatibilityMode,
|
private val compatibilityMode: CompatibilityMode,
|
||||||
private val allowRedeclaration: Boolean = false
|
private val allowRedeclaration: Boolean = false,
|
||||||
|
allowErrorLoopIndices: Boolean = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val bodyDeserializer = IrBodyDeserializer(builtIns, allowErrorNodes, irFactory, fileReader, this, statementOriginIndex + additionalStatementOriginIndex, allowErrorStatementOrigins)
|
val bodyDeserializer = IrBodyDeserializer(
|
||||||
|
builtIns,
|
||||||
|
allowErrorNodes,
|
||||||
|
irFactory,
|
||||||
|
fileReader,
|
||||||
|
this,
|
||||||
|
statementOriginIndex + additionalStatementOriginIndex,
|
||||||
|
allowErrorStatementOrigins,
|
||||||
|
allowErrorLoopIndices,
|
||||||
|
)
|
||||||
|
|
||||||
private fun deserializeName(index: Int): Name {
|
private fun deserializeName(index: Int): Name {
|
||||||
val name = fileReader.deserializeString(index)
|
val name = fileReader.deserializeString(index)
|
||||||
|
|||||||
+2
-1
@@ -173,7 +173,8 @@ class IcFileDeserializer(
|
|||||||
additionalStatementOriginIndex = additionalStatementOriginIndex,
|
additionalStatementOriginIndex = additionalStatementOriginIndex,
|
||||||
allowErrorStatementOrigins = true,
|
allowErrorStatementOrigins = true,
|
||||||
allowRedeclaration = true,
|
allowRedeclaration = true,
|
||||||
compatibilityMode = CompatibilityMode.CURRENT
|
compatibilityMode = CompatibilityMode.CURRENT,
|
||||||
|
allowErrorLoopIndices = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val protoFile: ProtoIrFile by lazy { ProtoIrFile.parseFrom(icFileData.file.fileData.codedInputStream, ExtensionRegistryLite.newInstance()) }
|
private val protoFile: ProtoIrFile by lazy { ProtoIrFile.parseFrom(icFileData.file.fileData.codedInputStream, ExtensionRegistryLite.newInstance()) }
|
||||||
|
|||||||
Reference in New Issue
Block a user