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()))
|
||||
.map { symbolTable.mapClass(choosePrimary(it.erasure())) }
|
||||
.toTypedArray()
|
||||
val returnType = if (descriptor.isSuspend) context.builtIns.anyType else (descriptor.returnType ?: context.builtIns.unitType)
|
||||
return DataFlowIR.Function(
|
||||
symbol = symbolTable.mapFunction(descriptor),
|
||||
parameterTypes = parameterTypes,
|
||||
returnType = symbolTable.mapType(returnType),
|
||||
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) {
|
||||
result.writeInt(symbol)
|
||||
result.writeIntArray(parameterTypes)
|
||||
result.writeInt(returnType)
|
||||
body.write(result)
|
||||
}
|
||||
}
|
||||
@@ -820,6 +821,7 @@ internal object DFGSerializer {
|
||||
Function(
|
||||
functionSymbolMap[function.symbol]!!,
|
||||
function.parameterTypes.map { typeMap[it]!! }.toIntArray(),
|
||||
typeMap[function.returnType]!!,
|
||||
FunctionBody(nodes, nodeMap[body.returns]!!, nodeMap[body.throws]!!)
|
||||
)
|
||||
}
|
||||
@@ -1115,6 +1117,7 @@ internal object DFGSerializer {
|
||||
val function = DataFlowIR.Function(
|
||||
symbol = symbol,
|
||||
parameterTypes = it.parameterTypes.map { types[it] }.toTypedArray(),
|
||||
returnType = types[it.returnType],
|
||||
body = deserializeBody(it.body)
|
||||
)
|
||||
functions.put(symbol, function)
|
||||
|
||||
+1
@@ -245,6 +245,7 @@ internal object DataFlowIR {
|
||||
|
||||
class Function(val symbol: FunctionSymbol,
|
||||
val parameterTypes: Array<Type>,
|
||||
val returnType: Type,
|
||||
val body: FunctionBody) {
|
||||
|
||||
fun debugOutput() {
|
||||
|
||||
Reference in New Issue
Block a user