mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Refactor type access extraction
This commit is contained in:
@@ -638,7 +638,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeFieldDeclaredIn(id, fieldDeclarationId, 0)
|
||||
tw.writeHasLocation(fieldDeclarationId, locId)
|
||||
|
||||
extractTypeAccess(t, locId, fieldDeclarationId, 0)
|
||||
extractTypeAccessRecursive(type, locId, fieldDeclarationId, 0)
|
||||
}
|
||||
|
||||
return id
|
||||
@@ -1033,7 +1033,7 @@ open class KotlinFileExtractor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
tw.writeIsAnonymClass(ids.type.javaResult.id as Label<DbClass>, idNewexpr)
|
||||
|
||||
extractTypeAccess(pluginContext.irBuiltIns.anyType, enclosingCallable, idNewexpr, -3, callsite, enclosingStmt)
|
||||
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyType, enclosingCallable, idNewexpr, -3, callsite, enclosingStmt)
|
||||
} else {
|
||||
// Returns true if type is C<T1, T2, ...> where C is declared `class C<T1, T2, ...> { ... }`
|
||||
fun isUnspecialised(type: IrSimpleType) =
|
||||
@@ -1058,7 +1058,7 @@ open class KotlinFileExtractor(
|
||||
if (dispatchReceiver != null) {
|
||||
extractExpressionExpr(dispatchReceiver, enclosingCallable, id, -1, enclosingStmt)
|
||||
} else if(callTarget.isStaticMethodOfClass) {
|
||||
extractTypeAccess(callTarget.parentAsClass.toRawType(), enclosingCallable, id, -1, callsite, enclosingStmt)
|
||||
extractTypeAccessRecursive(callTarget.parentAsClass.toRawType(), enclosingCallable, id, -1, callsite, enclosingStmt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1251,19 +1251,19 @@ open class KotlinFileExtractor(
|
||||
|
||||
extractRawMethodAccess(syntacticCallTarget, c, callable, parent, idx, enclosingStmt, (0 until c.valueArgumentsCount).map { c.getValueArgument(it) }, c.dispatchReceiver, c.extensionReceiver, typeArgs, extractClassTypeArguments)
|
||||
}
|
||||
|
||||
|
||||
fun extractSpecialEnumFunction(fnName: String){
|
||||
if (c.typeArgumentsCount != 1) {
|
||||
logger.errorElement("Expected to find exactly one type argument", c)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
val func = ((c.getTypeArgument(0) as? IrSimpleType)?.classifier?.owner as? IrClass)?.declarations?.find { it is IrFunction && it.name.asString() == fnName }
|
||||
if (func == null) {
|
||||
logger.errorElement("Couldn't find function $fnName on enum type", c)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
extractMethodAccess(func as IrFunction, false)
|
||||
}
|
||||
|
||||
@@ -1306,7 +1306,7 @@ open class KotlinFileExtractor(
|
||||
fun binopExtensionMethod(id: Label<out DbExpr>) {
|
||||
binopReceiver(id, c.extensionReceiver, "Extension receiver")
|
||||
}
|
||||
|
||||
|
||||
val dr = c.dispatchReceiver
|
||||
when {
|
||||
c.origin == IrStatementOrigin.PLUS &&
|
||||
@@ -1453,7 +1453,7 @@ open class KotlinFileExtractor(
|
||||
if(c.origin != IrStatementOrigin.EXCLEXCL) {
|
||||
logger.errorElement("Unexpected origin for CHECK_NOT_NULL: ${c.origin}", c)
|
||||
}
|
||||
|
||||
|
||||
val id = tw.getFreshIdLabel<DbNotnullexpr>()
|
||||
val type = useType(c.type)
|
||||
tw.writeExprs_notnullexpr(id, type.javaResult.id, parent, idx)
|
||||
@@ -1511,13 +1511,13 @@ open class KotlinFileExtractor(
|
||||
val locId = tw.getLocation(c)
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
|
||||
|
||||
if (c.typeArgumentsCount == 1) {
|
||||
extractTypeArguments(c, id, callable, enclosingStmt, -1)
|
||||
} else {
|
||||
logger.errorElement("Expected to find exactly one type argument in an arrayOfNulls call", c)
|
||||
}
|
||||
|
||||
|
||||
if (c.valueArgumentsCount == 1) {
|
||||
val dim = c.getValueArgument(0)
|
||||
if (dim != null) {
|
||||
@@ -1582,7 +1582,7 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
} else {
|
||||
val elementType = c.type.getArrayElementType(pluginContext.irBuiltIns)
|
||||
extractTypeAccess(elementType, callable, id, -1, c, enclosingStmt)
|
||||
extractTypeAccessRecursive(elementType, callable, id, -1, c, enclosingStmt)
|
||||
}
|
||||
|
||||
arg?.let {
|
||||
@@ -1666,7 +1666,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(c.getTypeArgument(1)!!, callable, id, 0, c, enclosingStmt)
|
||||
extractTypeAccessRecursive(c.getTypeArgument(1)!!, callable, id, 0, c, enclosingStmt)
|
||||
extractExpressionExpr(c.getValueArgument(0)!!, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
else -> {
|
||||
@@ -1684,10 +1684,32 @@ open class KotlinFileExtractor(
|
||||
enclosingStmt: Label<out DbStmt>,
|
||||
startIndex: Int = 0,
|
||||
reverse: Boolean = false
|
||||
) {
|
||||
extractTypeArguments(typeArgs, tw.getLocation(elementForLocation), parentExpr, enclosingCallable, enclosingStmt, startIndex, reverse)
|
||||
}
|
||||
|
||||
private fun extractTypeArguments(
|
||||
typeArgs: List<IrType>,
|
||||
location: Label<DbLocation>,
|
||||
parentExpr: Label<out DbExprparent>,
|
||||
enclosingCallable: Label<out DbCallable>,
|
||||
enclosingStmt: Label<out DbStmt>,
|
||||
startIndex: Int = 0,
|
||||
reverse: Boolean = false
|
||||
) {
|
||||
typeArgs.forEachIndexed { argIdx, arg ->
|
||||
val mul = if (reverse) -1 else 1
|
||||
extractTypeAccess(arg, enclosingCallable, parentExpr, argIdx * mul + startIndex, elementForLocation, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
|
||||
extractTypeAccessRecursive(arg, enclosingCallable, parentExpr, argIdx * mul + startIndex, location, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractTypeArguments(
|
||||
typeArgs: List<IrType>,
|
||||
location: Label<DbLocation>,
|
||||
parentExpr: Label<out DbExprparent>
|
||||
) {
|
||||
typeArgs.forEachIndexed { argIdx, arg ->
|
||||
extractTypeAccessRecursive(arg, location, parentExpr, argIdx, TypeContext.GENERIC_ARGUMENT)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1712,7 +1734,20 @@ open class KotlinFileExtractor(
|
||||
startIndex: Int = 0,
|
||||
reverse: Boolean = false
|
||||
) {
|
||||
extractTypeArguments(typeArgs.filterIsInstance<IrType>(), elementForLocation, parentExpr, enclosingCallable, enclosingStmt, startIndex, reverse)
|
||||
extractTypeArguments(typeArgs, tw.getLocation(elementForLocation), parentExpr, enclosingCallable, enclosingStmt, startIndex, reverse)
|
||||
}
|
||||
|
||||
@JvmName("extractTypeArguments1")
|
||||
private fun extractTypeArguments(
|
||||
typeArgs: List<IrTypeArgument>,
|
||||
location: Label<DbLocation>,
|
||||
parentExpr: Label<out DbExprparent>,
|
||||
enclosingCallable: Label<out DbCallable>,
|
||||
enclosingStmt: Label<out DbStmt>,
|
||||
startIndex: Int = 0,
|
||||
reverse: Boolean = false
|
||||
) {
|
||||
extractTypeArguments(typeArgs.filterIsInstance<IrType>(), location, parentExpr, enclosingCallable, enclosingStmt, startIndex, reverse)
|
||||
}
|
||||
|
||||
private fun extractNewExpr(
|
||||
@@ -1792,12 +1827,13 @@ open class KotlinFileExtractor(
|
||||
type
|
||||
}
|
||||
|
||||
val typeAccessId = extractTypeAccess(typeAccessType, callable, id, -3, e, enclosingStmt)
|
||||
val typeAccessId =
|
||||
extractTypeAccess(typeAccessType, callable, id, -3, e, enclosingStmt)
|
||||
|
||||
if (e is IrConstructorCall) {
|
||||
// Only extract type arguments relating to the constructed type, not the constructor itself:
|
||||
e.getClassTypeArguments().forEachIndexed({ argIdx, argType ->
|
||||
extractTypeAccess(argType!!, callable, typeAccessId, argIdx, e, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
|
||||
extractTypeAccessRecursive(argType!!, callable, typeAccessId, argIdx, e, enclosingStmt, TypeContext.GENERIC_ARGUMENT)
|
||||
})
|
||||
} else {
|
||||
extractTypeArguments(e, typeAccessId, callable, enclosingStmt)
|
||||
@@ -2042,7 +2078,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeStmts_catchclause(catchId, id, catchIdx, callable)
|
||||
val catchLocId = tw.getLocation(catchClause)
|
||||
tw.writeHasLocation(catchId, catchLocId)
|
||||
extractTypeAccess(catchClause.catchParameter.type, callable, catchId, -1, catchClause.catchParameter, catchId)
|
||||
extractTypeAccessRecursive(catchClause.catchParameter.type, callable, catchId, -1, catchClause.catchParameter, catchId)
|
||||
extractVariableExpr(catchClause.catchParameter, callable, catchId, 0, catchId)
|
||||
extractExpressionStmt(catchClause.result, callable, catchId, 1)
|
||||
}
|
||||
@@ -2225,7 +2261,7 @@ open class KotlinFileExtractor(
|
||||
|
||||
|
||||
fun extractTypeAccess(parent: IrClass){
|
||||
extractTypeAccess(parent.typeWith(listOf()), locId, callable, id, 0, exprParent.enclosingStmt)
|
||||
extractTypeAccessRecursive(parent.typeWith(listOf()), callable, id, 0, locId, exprParent.enclosingStmt)
|
||||
}
|
||||
|
||||
when(val ownerParent = owner.parent) {
|
||||
@@ -2503,7 +2539,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeCallableBinding(idLambdaExpr, ids.constructor)
|
||||
|
||||
val typeAccessArguments = if (isBigArity) listOf(types.last()) else types
|
||||
extractTypeAccess(fnInterfaceType, typeAccessArguments, e, idLambdaExpr, -3, callable, exprParent.enclosingStmt)
|
||||
extractTypeAccessRecursive(fnInterfaceType, typeAccessArguments, e, idLambdaExpr, -3, callable, exprParent.enclosingStmt)
|
||||
|
||||
// todo: fix hard coded block body of lambda
|
||||
tw.writeLambdaKind(idLambdaExpr, 1)
|
||||
@@ -2521,7 +2557,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, exprParent.enclosingStmt)
|
||||
|
||||
extractTypeAccess(e.classType, locId, callable, id, 0, exprParent.enclosingStmt)
|
||||
extractTypeAccessRecursive(e.classType, callable, id, 0, locId, exprParent.enclosingStmt)
|
||||
}
|
||||
is IrPropertyReference -> {
|
||||
extractPropertyReference(e, parent, callable)
|
||||
@@ -2844,7 +2880,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeStatementEnclosingExpr(idPropertyRef, exprParent.enclosingStmt)
|
||||
tw.writeCallableBinding(idPropertyRef, ids.constructor)
|
||||
|
||||
extractTypeAccess(kPropertyType, parameterTypes, propertyReferenceExpr, idPropertyRef, -3, callable, exprParent.enclosingStmt)
|
||||
extractTypeAccessRecursive(kPropertyType, parameterTypes, propertyReferenceExpr, idPropertyRef, -3, callable, exprParent.enclosingStmt)
|
||||
|
||||
helper.extractConstructorArguments(callable, idPropertyRef, exprParent.enclosingStmt)
|
||||
|
||||
@@ -2955,7 +2991,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeExprs_newexpr(callId, callType.javaResult.id, retId, 0)
|
||||
tw.writeExprsKotlinType(callId, callType.kotlinResult.id)
|
||||
|
||||
val typeAccessId = extractTypeAccess(callType, locId, funLabels.methodId, callId, -3, retId)
|
||||
val typeAccessId = extractTypeAccess(callType, funLabels.methodId, callId, -3, locId, retId)
|
||||
|
||||
extractTypeArguments(functionReferenceExpr, typeAccessId, funLabels.methodId, retId)
|
||||
return callId
|
||||
@@ -2988,7 +3024,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeCallableBinding(idMemberRef, ids.constructor)
|
||||
|
||||
val typeAccessArguments = if (isBigArity) listOf(parameterTypes.last()) else parameterTypes
|
||||
extractTypeAccess(fnInterfaceType, typeAccessArguments, functionReferenceExpr, idMemberRef, -3, callable, exprParent.enclosingStmt)
|
||||
extractTypeAccessRecursive(fnInterfaceType, typeAccessArguments, functionReferenceExpr, idMemberRef, -3, callable, exprParent.enclosingStmt)
|
||||
|
||||
tw.writeMemberRefBinding(idMemberRef, targetCallableId)
|
||||
|
||||
@@ -3160,7 +3196,7 @@ open class KotlinFileExtractor(
|
||||
extractCommonExpr(castId)
|
||||
|
||||
// type access `Ti`
|
||||
extractTypeAccess(pType, locId, funLabels.methodId, castId, 0, enclosingStmtId)
|
||||
extractTypeAccessRecursive(pType, funLabels.methodId, castId, 0, locId, enclosingStmtId)
|
||||
|
||||
// element access: `a0[i]`
|
||||
val arrayAccessId = tw.getFreshIdLabel<DbArrayaccess>()
|
||||
@@ -3200,13 +3236,6 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(type: TypeResults, location: Label<DbLocation>, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
|
||||
val id = extractTypeAccess(type, location, parent, idx)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
return id
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(type: TypeResults, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int): Label<out DbExpr> {
|
||||
// TODO: elementForLocation allows us to give some sort of
|
||||
// location, but a proper location for the type access will
|
||||
@@ -3218,23 +3247,38 @@ open class KotlinFileExtractor(
|
||||
return id
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(t: IrType, location: Label<DbLocation>, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
|
||||
return extractTypeAccess(useType(t, typeContext), location, callable, parent, idx, enclosingStmt)
|
||||
private fun extractTypeAccess(type: TypeResults, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, location: Label<DbLocation>, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
|
||||
val id = extractTypeAccess(type, location, parent, idx)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
return id
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(t: TypeResults, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement, enclosingStmt: Label<out DbStmt>): Label<out DbExpr> {
|
||||
return extractTypeAccess(t, tw.getLocation(elementForLocation), callable, parent, idx, enclosingStmt)
|
||||
return extractTypeAccess(t, callable, parent, idx, tw.getLocation(elementForLocation), enclosingStmt)
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(t: IrType, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
|
||||
val typeAccessId = extractTypeAccess(useType(t, typeContext), callable, parent, idx, elementForLocation, enclosingStmt)
|
||||
private fun extractTypeAccessRecursive(t: IrType, location: Label<DbLocation>, parent: Label<out DbExprparent>, idx: Int, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
|
||||
val typeAccessId = extractTypeAccess(useType(t, typeContext), location, parent, idx)
|
||||
if (t is IrSimpleType) {
|
||||
extractTypeArguments(t.arguments, elementForLocation, typeAccessId, callable, enclosingStmt)
|
||||
extractTypeArguments(t.arguments.filterIsInstance<IrType>(), location, typeAccessId)
|
||||
}
|
||||
return typeAccessId
|
||||
}
|
||||
|
||||
private fun extractTypeAccess(
|
||||
private fun extractTypeAccessRecursive(t: IrType, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, location: Label<DbLocation>, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
|
||||
val typeAccessId = extractTypeAccess(useType(t, typeContext), callable, parent, idx, location, enclosingStmt)
|
||||
if (t is IrSimpleType) {
|
||||
extractTypeArguments(t.arguments, location, typeAccessId, callable, enclosingStmt)
|
||||
}
|
||||
return typeAccessId
|
||||
}
|
||||
|
||||
private fun extractTypeAccessRecursive(t: IrType, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement, enclosingStmt: Label<out DbStmt>, typeContext: TypeContext = TypeContext.OTHER): Label<out DbExpr> {
|
||||
return extractTypeAccessRecursive(t, callable, parent, idx, tw.getLocation(elementForLocation), enclosingStmt, typeContext)
|
||||
}
|
||||
|
||||
private fun extractTypeAccessRecursive(
|
||||
t: IrType,
|
||||
typeAccessArguments: List<IrType>,
|
||||
elementForLocation: IrElement,
|
||||
@@ -3261,7 +3305,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.IMPLICIT_CAST -> {
|
||||
@@ -3273,7 +3317,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.IMPLICIT_NOTNULL -> {
|
||||
@@ -3285,7 +3329,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> {
|
||||
@@ -3297,7 +3341,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.SAFE_CAST -> {
|
||||
@@ -3309,7 +3353,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 1, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.INSTANCEOF -> {
|
||||
@@ -3322,7 +3366,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 0, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 1, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 1, e, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.NOT_INSTANCEOF -> {
|
||||
val id = tw.getFreshIdLabel<DbNotinstanceofexpr>()
|
||||
@@ -3334,7 +3378,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractExpressionExpr(e.argument, callable, id, 0, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 1, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 1, e, enclosingStmt)
|
||||
}
|
||||
IrTypeOperator.SAM_CONVERSION -> {
|
||||
|
||||
@@ -3476,7 +3520,8 @@ open class KotlinFileExtractor(
|
||||
tw.writeVariableBinding(argsAccessId, useValueParameter(p, ids.function))
|
||||
}
|
||||
|
||||
if (st.arguments.size > BuiltInFunctionArity.BIG_ARITY) {
|
||||
val isBigArity = st.arguments.size > BuiltInFunctionArity.BIG_ARITY
|
||||
if (isBigArity) {
|
||||
//<fn>.invoke(new Object[x]{vp0, vp1, vp2, ...})
|
||||
val arrayCreationId = tw.getFreshIdLabel<DbArraycreationexpr>()
|
||||
val arrayType = pluginContext.irBuiltIns.arrayClass.typeWith(pluginContext.irBuiltIns.anyNType)
|
||||
@@ -3485,7 +3530,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeExprsKotlinType(arrayCreationId, at.kotlinResult.id)
|
||||
extractCommonExpr(arrayCreationId)
|
||||
|
||||
extractTypeAccess(pluginContext.irBuiltIns.anyNType, ids.function, arrayCreationId, -1, e, returnId)
|
||||
extractTypeAccessRecursive(pluginContext.irBuiltIns.anyNType, ids.function, arrayCreationId, -1, e, returnId)
|
||||
|
||||
val initId = tw.getFreshIdLabel<DbArrayinit>()
|
||||
tw.writeExprs_arrayinit(initId, at.javaResult.id, arrayCreationId, -2)
|
||||
@@ -3518,14 +3563,14 @@ open class KotlinFileExtractor(
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
extractTypeAccess(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, id, 0, e, enclosingStmt)
|
||||
|
||||
val idNewexpr = extractNewExpr(ids.constructor, ids.type, locId, id, 1, callable, enclosingStmt)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
tw.writeIsAnonymClass(ids.type.javaResult.id as Label<DbClass>, idNewexpr)
|
||||
|
||||
extractTypeAccess(e.typeOperand, callable, idNewexpr, -3, e, enclosingStmt)
|
||||
extractTypeAccessRecursive(e.typeOperand, callable, idNewexpr, -3, e, enclosingStmt)
|
||||
|
||||
extractExpressionExpr(e.argument, callable, idNewexpr, 0, enclosingStmt)
|
||||
}
|
||||
|
||||
@@ -2368,6 +2368,8 @@ samConversion.kt:
|
||||
# 2| 1: [VarAccess] <fn>
|
||||
# 2| 1: [FieldDeclaration] Function1<Integer,Boolean> <fn>;
|
||||
# 2| -1: [TypeAccess] Function1<Integer,Boolean>
|
||||
# 2| 0: [TypeAccess] Integer
|
||||
# 2| 1: [TypeAccess] Boolean
|
||||
# 17| 3: [Method] accept
|
||||
#-----| 4: (Parameters)
|
||||
# 17| 0: [Parameter] i
|
||||
@@ -2413,6 +2415,9 @@ samConversion.kt:
|
||||
# 4| 1: [VarAccess] <fn>
|
||||
# 4| 1: [FieldDeclaration] Function2<Integer,Integer,Unit> <fn>;
|
||||
# 4| -1: [TypeAccess] Function2<Integer,Integer,Unit>
|
||||
# 4| 0: [TypeAccess] Integer
|
||||
# 4| 1: [TypeAccess] Integer
|
||||
# 4| 2: [TypeAccess] Unit
|
||||
# 23| 3: [Method] fn1
|
||||
#-----| 4: (Parameters)
|
||||
# 23| 0: [Parameter] i
|
||||
@@ -2458,6 +2463,9 @@ samConversion.kt:
|
||||
# 5| 1: [VarAccess] <fn>
|
||||
# 5| 1: [FieldDeclaration] Function2<Integer,Integer,Unit> <fn>;
|
||||
# 5| -1: [TypeAccess] Function2<Integer,Integer,Unit>
|
||||
# 5| 0: [TypeAccess] Integer
|
||||
# 5| 1: [TypeAccess] Integer
|
||||
# 5| 2: [TypeAccess] Unit
|
||||
# 23| 3: [Method] fn1
|
||||
#-----| 4: (Parameters)
|
||||
# 23| 0: [Parameter] i
|
||||
@@ -2505,6 +2513,9 @@ samConversion.kt:
|
||||
# 7| 1: [VarAccess] <fn>
|
||||
# 7| 1: [FieldDeclaration] Function2<String,Integer,Boolean> <fn>;
|
||||
# 7| -1: [TypeAccess] Function2<String,Integer,Boolean>
|
||||
# 7| 0: [TypeAccess] String
|
||||
# 7| 1: [TypeAccess] Integer
|
||||
# 7| 2: [TypeAccess] Boolean
|
||||
# 27| 3: [ExtensionMethod] ext
|
||||
#-----| 4: (Parameters)
|
||||
# 27| 0: [Parameter] <this>
|
||||
@@ -2552,6 +2563,8 @@ samConversion.kt:
|
||||
# 9| 1: [VarAccess] <fn>
|
||||
# 9| 1: [FieldDeclaration] Function1<Integer,Boolean> <fn>;
|
||||
# 9| -1: [TypeAccess] Function1<Integer,Boolean>
|
||||
# 9| 0: [TypeAccess] Integer
|
||||
# 9| 1: [TypeAccess] Boolean
|
||||
# 17| 3: [Method] accept
|
||||
#-----| 4: (Parameters)
|
||||
# 17| 0: [Parameter] i
|
||||
@@ -2845,6 +2858,7 @@ samConversion.kt:
|
||||
# 42| 1: [VarAccess] <fn>
|
||||
# 42| 2: [FieldDeclaration] FunctionN<Boolean> <fn>;
|
||||
# 42| -1: [TypeAccess] FunctionN<Boolean>
|
||||
# 42| 0: [TypeAccess] Boolean
|
||||
# 42| -3: [TypeAccess] BigArityPredicate
|
||||
# 42| 0: [VarAccess] a
|
||||
# 43| 2: [LocalVariableDeclStmt] var ...;
|
||||
@@ -2921,6 +2935,7 @@ samConversion.kt:
|
||||
# 43| 1: [VarAccess] <fn>
|
||||
# 43| 2: [FieldDeclaration] FunctionN<Boolean> <fn>;
|
||||
# 43| -1: [TypeAccess] FunctionN<Boolean>
|
||||
# 43| 0: [TypeAccess] Boolean
|
||||
# 43| -3: [TypeAccess] BigArityPredicate
|
||||
# 43| 0: [LambdaExpr] ...->...
|
||||
# 43| -4: [AnonymousClass] new FunctionN<Boolean>(...) { ... }
|
||||
@@ -3098,6 +3113,8 @@ samConversion.kt:
|
||||
# 46| 1: [VarAccess] <fn>
|
||||
# 46| 1: [FieldDeclaration] Function1<Integer,Boolean> <fn>;
|
||||
# 46| -1: [TypeAccess] Function1<Integer,Boolean>
|
||||
# 46| 0: [TypeAccess] Integer
|
||||
# 46| 1: [TypeAccess] Boolean
|
||||
# 50| 3: [Method] fn
|
||||
#-----| 4: (Parameters)
|
||||
# 50| 0: [Parameter] i
|
||||
|
||||
@@ -1429,9 +1429,11 @@
|
||||
| samConversion.kt:2:18:2:45 | ...=... | samConversion.kt:2:18:2:45 | | AssignExpr |
|
||||
| samConversion.kt:2:18:2:45 | <fn> | samConversion.kt:2:18:2:45 | | VarAccess |
|
||||
| samConversion.kt:2:18:2:45 | <fn> | samConversion.kt:17:5:17:31 | accept | VarAccess |
|
||||
| samConversion.kt:2:18:2:45 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:2:18:2:45 | Function1<Integer,Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:2:18:2:45 | IntPredicate | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:2:18:2:45 | IntPredicate | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:2:18:2:45 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:2:18:2:45 | i | samConversion.kt:17:5:17:31 | accept | VarAccess |
|
||||
| samConversion.kt:2:18:2:45 | invoke(...) | samConversion.kt:17:5:17:31 | accept | MethodAccess |
|
||||
| samConversion.kt:2:18:2:45 | new (...) | samConversion.kt:1:1:14:1 | main | ClassInstanceExpr |
|
||||
@@ -1452,8 +1454,11 @@
|
||||
| samConversion.kt:4:14:4:42 | <fn> | samConversion.kt:4:14:4:42 | | VarAccess |
|
||||
| samConversion.kt:4:14:4:42 | <fn> | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
| samConversion.kt:4:14:4:42 | Function2<Integer,Integer,Unit> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | InterfaceFn1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | InterfaceFn1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | Unit | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:4:14:4:42 | i | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
| samConversion.kt:4:14:4:42 | invoke(...) | samConversion.kt:23:5:23:27 | fn1 | MethodAccess |
|
||||
| samConversion.kt:4:14:4:42 | j | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
@@ -1472,8 +1477,11 @@
|
||||
| samConversion.kt:5:14:5:32 | <fn> | samConversion.kt:5:14:5:32 | | VarAccess |
|
||||
| samConversion.kt:5:14:5:32 | <fn> | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
| samConversion.kt:5:14:5:32 | Function2<Integer,Integer,Unit> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | InterfaceFn1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | InterfaceFn1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | Unit | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:5:14:5:32 | i | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
| samConversion.kt:5:14:5:32 | invoke(...) | samConversion.kt:23:5:23:27 | fn1 | MethodAccess |
|
||||
| samConversion.kt:5:14:5:32 | j | samConversion.kt:23:5:23:27 | fn1 | VarAccess |
|
||||
@@ -1494,9 +1502,12 @@
|
||||
| samConversion.kt:7:13:7:46 | <fn> | samConversion.kt:7:13:7:46 | | VarAccess |
|
||||
| samConversion.kt:7:13:7:46 | <fn> | samConversion.kt:27:5:27:35 | ext | VarAccess |
|
||||
| samConversion.kt:7:13:7:46 | <this> | samConversion.kt:27:5:27:35 | ext | VarAccess |
|
||||
| samConversion.kt:7:13:7:46 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | Function2<String,Integer,Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | InterfaceFnExt1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | InterfaceFnExt1 | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | String | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:7:13:7:46 | i | samConversion.kt:27:5:27:35 | ext | VarAccess |
|
||||
| samConversion.kt:7:13:7:46 | invoke(...) | samConversion.kt:27:5:27:35 | ext | MethodAccess |
|
||||
| samConversion.kt:7:13:7:46 | new (...) | samConversion.kt:1:1:14:1 | main | ClassInstanceExpr |
|
||||
@@ -1515,9 +1526,11 @@
|
||||
| samConversion.kt:9:13:13:6 | ...=... | samConversion.kt:9:13:13:6 | | AssignExpr |
|
||||
| samConversion.kt:9:13:13:6 | <fn> | samConversion.kt:9:13:13:6 | | VarAccess |
|
||||
| samConversion.kt:9:13:13:6 | <fn> | samConversion.kt:17:5:17:31 | accept | VarAccess |
|
||||
| samConversion.kt:9:13:13:6 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:9:13:13:6 | Function1<Integer,Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:9:13:13:6 | IntPredicate | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:9:13:13:6 | IntPredicate | samConversion.kt:1:1:14:1 | main | TypeAccess |
|
||||
| samConversion.kt:9:13:13:6 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:9:13:13:6 | i | samConversion.kt:17:5:17:31 | accept | VarAccess |
|
||||
| samConversion.kt:9:13:13:6 | invoke(...) | samConversion.kt:17:5:17:31 | accept | MethodAccess |
|
||||
| samConversion.kt:9:13:13:6 | new (...) | samConversion.kt:1:1:14:1 | main | ClassInstanceExpr |
|
||||
@@ -1673,6 +1686,7 @@
|
||||
| samConversion.kt:42:13:42:32 | <fn> | samConversion.kt:42:13:42:32 | | VarAccess |
|
||||
| samConversion.kt:42:13:42:32 | BigArityPredicate | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:42:13:42:32 | BigArityPredicate | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:42:13:42:32 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:42:13:42:32 | FunctionN<Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:42:13:42:32 | Object | samConversion.kt:31:5:33:53 | accept | TypeAccess |
|
||||
| samConversion.kt:42:13:42:32 | i0 | samConversion.kt:31:5:33:53 | accept | VarAccess |
|
||||
@@ -1713,6 +1727,7 @@
|
||||
| samConversion.kt:43:13:45:68 | <fn> | samConversion.kt:43:13:45:68 | | VarAccess |
|
||||
| samConversion.kt:43:13:45:68 | BigArityPredicate | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:43:13:45:68 | BigArityPredicate | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:43:13:45:68 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:43:13:45:68 | FunctionN<Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:43:13:45:68 | Object | samConversion.kt:31:5:33:53 | accept | TypeAccess |
|
||||
| samConversion.kt:43:13:45:68 | i0 | samConversion.kt:31:5:33:53 | accept | VarAccess |
|
||||
@@ -1870,7 +1885,9 @@
|
||||
| samConversion.kt:46:13:46:44 | ...=... | samConversion.kt:46:13:46:44 | | AssignExpr |
|
||||
| samConversion.kt:46:13:46:44 | <fn> | samConversion.kt:46:13:46:44 | | VarAccess |
|
||||
| samConversion.kt:46:13:46:44 | <fn> | samConversion.kt:50:5:50:25 | fn | VarAccess |
|
||||
| samConversion.kt:46:13:46:44 | Boolean | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:46:13:46:44 | Function1<Integer,Boolean> | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:46:13:46:44 | Integer | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| samConversion.kt:46:13:46:44 | Integer | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:46:13:46:44 | Integer | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
| samConversion.kt:46:13:46:44 | SomePredicate<Integer> | samConversion.kt:40:1:47:1 | fn | TypeAccess |
|
||||
|
||||
@@ -164,6 +164,8 @@ reflection.kt:
|
||||
# 12| 0: [VarAccess] a0
|
||||
# 12| 1: [FieldDeclaration] KProperty1<C,Integer> <dispatchReceiver>;
|
||||
# 12| -1: [TypeAccess] KProperty1<C,Integer>
|
||||
# 12| 0: [TypeAccess] C
|
||||
# 12| 1: [TypeAccess] Integer
|
||||
# 12| -3: [TypeAccess] Function1<C,Integer>
|
||||
# 12| 0: [TypeAccess] C
|
||||
# 12| 1: [TypeAccess] Integer
|
||||
@@ -262,6 +264,8 @@ reflection.kt:
|
||||
# 19| 1: [VarAccess] a1
|
||||
# 19| 1: [FieldDeclaration] KMutableProperty1<C,Integer> <dispatchReceiver>;
|
||||
# 19| -1: [TypeAccess] KMutableProperty1<C,Integer>
|
||||
# 19| 0: [TypeAccess] C
|
||||
# 19| 1: [TypeAccess] Integer
|
||||
# 19| -3: [TypeAccess] Function2<C,Integer,Unit>
|
||||
# 19| 0: [TypeAccess] C
|
||||
# 19| 1: [TypeAccess] Integer
|
||||
@@ -462,6 +466,7 @@ reflection.kt:
|
||||
# 59| 0: [VarAccess] a0
|
||||
# 59| 1: [FieldDeclaration] Generic<Integer> <dispatchReceiver>;
|
||||
# 59| -1: [TypeAccess] Generic<Integer>
|
||||
# 59| 0: [TypeAccess] Integer
|
||||
# 59| -3: [TypeAccess] Function1<Integer,String>
|
||||
# 59| 0: [TypeAccess] Integer
|
||||
# 59| 1: [TypeAccess] String
|
||||
@@ -512,6 +517,7 @@ reflection.kt:
|
||||
# 61| -1: [ThisAccess] this
|
||||
# 61| 1: [FieldDeclaration] Generic<Integer> <extensionReceiver>;
|
||||
# 61| -1: [TypeAccess] Generic<Integer>
|
||||
# 61| 0: [TypeAccess] Integer
|
||||
# 61| -3: [TypeAccess] Function0<String>
|
||||
# 61| 0: [TypeAccess] String
|
||||
# 61| 0: [ClassInstanceExpr] new Generic<Integer>(...)
|
||||
@@ -559,6 +565,7 @@ reflection.kt:
|
||||
# 63| -1: [ThisAccess] this
|
||||
# 63| 1: [FieldDeclaration] Generic<Integer> <extensionReceiver>;
|
||||
# 63| -1: [TypeAccess] Generic<Integer>
|
||||
# 63| 0: [TypeAccess] Integer
|
||||
# 63| -3: [TypeAccess] Function0<String>
|
||||
# 63| 0: [TypeAccess] String
|
||||
# 63| 0: [ClassInstanceExpr] new Generic<Integer>(...)
|
||||
@@ -609,6 +616,7 @@ reflection.kt:
|
||||
# 66| 1: [VarAccess] <dispatchReceiver>
|
||||
# 66| 1: [FieldDeclaration] Generic<Integer> <dispatchReceiver>;
|
||||
# 66| -1: [TypeAccess] Generic<Integer>
|
||||
# 66| 0: [TypeAccess] Integer
|
||||
# 66| 1: [Method] get
|
||||
# 66| 5: [BlockStmt] { ... }
|
||||
# 66| 0: [ReturnStmt] return ...
|
||||
|
||||
Reference in New Issue
Block a user