mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Extract IrEnumConstructorCall
This commit is contained in:
@@ -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<*> -> {
|
||||
|
||||
Reference in New Issue
Block a user