Extract IrEnumConstructorCall

This commit is contained in:
Tamas Vajk
2021-09-20 16:42:49 +02:00
committed by Ian Lynagh
parent 9587e91f71
commit 5c72b52b97

View File

@@ -138,6 +138,34 @@ fun doFile(invocationTrapFile: String, fileTrapWriter: FileTrapWriter, checkTrap
}
}
}
private fun extractConstructorCall(
e: IrFunctionAccessExpression,
parent: Label<out DbExprparent>,
idx: Int,
callable: Label<out DbCallable>,
irCallable: IrFunction
) {
val id = tw.getFreshIdLabel<DbNewexpr>()
val typeId = useType(e.type)
val locId = tw.getLocation(e)
val methodId = useFunction(e.symbol.owner)
tw.writeExprs_newexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
tw.writeCallableBinding(id, methodId)
for (i in 0 until e.valueArgumentsCount) {
val arg = e.getValueArgument(i)
if (arg != null) {
extractExpression(arg, callable, irCallable, id, i)
}
}
val dr = e.dispatchReceiver
if (dr != null) {
extractExpression(dr, callable, irCallable, id, -3)
}
// todo: type arguments at index -4, -5, ...
}
}
fun <T> fakeLabel(): Label<T> {
@@ -716,25 +744,10 @@ class KotlinFileExtractor(val logger: FileLogger, val tw: FileTrapWriter, val fi
// todo: type arguments at index -2, -3, ...
}
is IrConstructorCall -> {
val id = tw.getFreshIdLabel<DbNewexpr>()
val typeId = useType(e.type)
val locId = tw.getLocation(e)
val methodId = useFunction(e.symbol.owner)
tw.writeExprs_newexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
tw.writeCallableBinding(id, methodId)
for (i in 0 until e.valueArgumentsCount) {
val arg = e.getValueArgument(i)
if (arg != null) {
extractExpression(arg, callable, irCallable, id, i)
}
}
val dr = e.dispatchReceiver
if (dr != null) {
extractExpression(dr, callable, irCallable, id, -3)
}
// todo: type arguments at index -4, -5, ...
extractConstructorCall(e, parent, idx, callable, irCallable)
}
is IrEnumConstructorCall -> {
extractConstructorCall(e, parent, idx, callable, irCallable)
}
is IrCall -> extractCall(e, callable, irCallable, parent, idx)
is IrConst<*> -> {