DFG: Added return type to function declaration
This commit is contained in:
+2
@@ -483,9 +483,11 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
|
|||||||
val parameterTypes = (allParameters.map { it.type } + (if (descriptor.isSuspend) listOf(continuationType) else emptyList()))
|
val parameterTypes = (allParameters.map { it.type } + (if (descriptor.isSuspend) listOf(continuationType) else emptyList()))
|
||||||
.map { symbolTable.mapClass(choosePrimary(it.erasure())) }
|
.map { symbolTable.mapClass(choosePrimary(it.erasure())) }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
|
val returnType = if (descriptor.isSuspend) context.builtIns.anyType else (descriptor.returnType ?: context.builtIns.unitType)
|
||||||
return DataFlowIR.Function(
|
return DataFlowIR.Function(
|
||||||
symbol = symbolTable.mapFunction(descriptor),
|
symbol = symbolTable.mapFunction(descriptor),
|
||||||
parameterTypes = parameterTypes,
|
parameterTypes = parameterTypes,
|
||||||
|
returnType = symbolTable.mapType(returnType),
|
||||||
body = DataFlowIR.FunctionBody(allNodes.distinct().toList(), returnsNode, throwsNode)
|
body = DataFlowIR.FunctionBody(allNodes.distinct().toList(), returnsNode, throwsNode)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -665,13 +665,14 @@ internal object DFGSerializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Function(val symbol: Int, val parameterTypes: IntArray, val body: FunctionBody) {
|
class Function(val symbol: Int, val parameterTypes: IntArray, val returnType: Int, val body: FunctionBody) {
|
||||||
|
|
||||||
constructor(data: ArraySlice) : this(data.readInt(), data.readIntArray(), FunctionBody(data))
|
constructor(data: ArraySlice) : this(data.readInt(), data.readIntArray(), data.readInt(), FunctionBody(data))
|
||||||
|
|
||||||
fun write(result: ArraySlice) {
|
fun write(result: ArraySlice) {
|
||||||
result.writeInt(symbol)
|
result.writeInt(symbol)
|
||||||
result.writeIntArray(parameterTypes)
|
result.writeIntArray(parameterTypes)
|
||||||
|
result.writeInt(returnType)
|
||||||
body.write(result)
|
body.write(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -820,6 +821,7 @@ internal object DFGSerializer {
|
|||||||
Function(
|
Function(
|
||||||
functionSymbolMap[function.symbol]!!,
|
functionSymbolMap[function.symbol]!!,
|
||||||
function.parameterTypes.map { typeMap[it]!! }.toIntArray(),
|
function.parameterTypes.map { typeMap[it]!! }.toIntArray(),
|
||||||
|
typeMap[function.returnType]!!,
|
||||||
FunctionBody(nodes, nodeMap[body.returns]!!, nodeMap[body.throws]!!)
|
FunctionBody(nodes, nodeMap[body.returns]!!, nodeMap[body.throws]!!)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1115,6 +1117,7 @@ internal object DFGSerializer {
|
|||||||
val function = DataFlowIR.Function(
|
val function = DataFlowIR.Function(
|
||||||
symbol = symbol,
|
symbol = symbol,
|
||||||
parameterTypes = it.parameterTypes.map { types[it] }.toTypedArray(),
|
parameterTypes = it.parameterTypes.map { types[it] }.toTypedArray(),
|
||||||
|
returnType = types[it.returnType],
|
||||||
body = deserializeBody(it.body)
|
body = deserializeBody(it.body)
|
||||||
)
|
)
|
||||||
functions.put(symbol, function)
|
functions.put(symbol, function)
|
||||||
|
|||||||
+1
@@ -245,6 +245,7 @@ internal object DataFlowIR {
|
|||||||
|
|
||||||
class Function(val symbol: FunctionSymbol,
|
class Function(val symbol: FunctionSymbol,
|
||||||
val parameterTypes: Array<Type>,
|
val parameterTypes: Array<Type>,
|
||||||
|
val returnType: Type,
|
||||||
val body: FunctionBody) {
|
val body: FunctionBody) {
|
||||||
|
|
||||||
fun debugOutput() {
|
fun debugOutput() {
|
||||||
|
|||||||
Reference in New Issue
Block a user