Fix few compiler warnings. (#1158)
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ class MappingBridgeGeneratorImpl(
|
|||||||
): KotlinExpression {
|
): KotlinExpression {
|
||||||
val bridgeArguments = mutableListOf<BridgeTypedKotlinValue>()
|
val bridgeArguments = mutableListOf<BridgeTypedKotlinValue>()
|
||||||
|
|
||||||
kotlinValues.forEachIndexed { index, (type, value) ->
|
kotlinValues.forEach { (type, value) ->
|
||||||
if (type.unwrapTypedefs() is RecordType) {
|
if (type.unwrapTypedefs() is RecordType) {
|
||||||
builder.pushMemScoped()
|
builder.pushMemScoped()
|
||||||
val bridgeArgument = "$value.getPointer(memScope).rawValue"
|
val bridgeArgument = "$value.getPointer(memScope).rawValue"
|
||||||
|
|||||||
+1
-1
@@ -288,7 +288,7 @@ sealed class TypeInfo {
|
|||||||
): KotlinExpression {
|
): KotlinExpression {
|
||||||
val mappingBridgeGenerator = scope.mappingBridgeGenerator
|
val mappingBridgeGenerator = scope.mappingBridgeGenerator
|
||||||
|
|
||||||
val funParameters = type.parameterTypes.mapIndexed { index, it ->
|
val funParameters = type.parameterTypes.mapIndexed { index, _ ->
|
||||||
"p$index" to kotlinType.parameterTypes[index]
|
"p$index" to kotlinType.parameterTypes[index]
|
||||||
}.joinToString { "${it.first}: ${it.second.render(scope)}" }
|
}.joinToString { "${it.first}: ${it.second.render(scope)}" }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -391,7 +391,7 @@ private fun processLib(args: Map<String, List<String>>,
|
|||||||
def.manifestAddendProperties["includedHeaders"] = nativeIndex.includedHeaders.joinToString(" ") { it.value }
|
def.manifestAddendProperties["includedHeaders"] = nativeIndex.includedHeaders.joinToString(" ") { it.value }
|
||||||
|
|
||||||
def.manifestAddendProperties.putAndRunOnReplace("package", outKtPkg) {
|
def.manifestAddendProperties.putAndRunOnReplace("package", outKtPkg) {
|
||||||
key, oldValue, newValue ->
|
_, oldValue, newValue ->
|
||||||
warn("The package value `$oldValue` specified in .def file is overriden with explicit $newValue")
|
warn("The package value `$oldValue` specified in .def file is overriden with explicit $newValue")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codegen.CompilationErrorHandler
|
|
||||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
|
|
||||||
object NativeBackendFacade {
|
|
||||||
fun doGenerateFiles(files: Collection<KtFile>, state: GenerationState, errorHandler: CompilationErrorHandler) {
|
|
||||||
TODO()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-22
@@ -24,28 +24,6 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
fun ClassDescriptor?.getter2Descriptor(methodName: Name) = this?.let {
|
|
||||||
this.unsubstitutedMemberScope.getContributedDescriptors{true}
|
|
||||||
.firstOrNull {
|
|
||||||
it.name == methodName
|
|
||||||
} ?.let {
|
|
||||||
return@let (it as? PropertyDescriptor)?.getter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ClassDescriptor?.signature2Descriptor(methodName: Name, signature:Array<KotlinType> = emptyArray()) = this?.let {
|
|
||||||
this
|
|
||||||
.unsubstitutedMemberScope
|
|
||||||
.getContributedFunctions(methodName, NoLookupLocation.FROM_BACKEND)
|
|
||||||
.firstOrNull {
|
|
||||||
return@firstOrNull it.valueParameters.size == signature.size
|
|
||||||
&& (signature.isEmpty() || it.valueParameters.any {
|
|
||||||
p -> val index = it.valueParameters.indexOf(p)
|
|
||||||
return@any p.type == signature[index]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val DeserializedPropertyDescriptor.backingField: PropertyDescriptor?
|
val DeserializedPropertyDescriptor.backingField: PropertyDescriptor?
|
||||||
get() =
|
get() =
|
||||||
if (this.proto.getExtension(KonanLinkData.hasBackingField))
|
if (this.proto.getExtension(KonanLinkData.hasBackingField))
|
||||||
|
|||||||
+7
-10
@@ -514,7 +514,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
}
|
}
|
||||||
|
|
||||||
val local = functionGenerationContext.vars.createParameter(descriptor,
|
val local = functionGenerationContext.vars.createParameter(descriptor,
|
||||||
it.value, debugInfoIfNeeded(function, ir))
|
debugInfoIfNeeded(function, ir))
|
||||||
functionGenerationContext.mapParameterForDebug(local, it.value)
|
functionGenerationContext.mapParameterForDebug(local, it.value)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1127,7 +1127,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun debugInfoIfNeeded(function: IrFunction?, element: IrElement): VariableDebugLocation? {
|
private fun debugInfoIfNeeded(function: IrFunction?, element: IrElement): VariableDebugLocation? {
|
||||||
if (function == null || !context.shouldContainDebugInfo()) return null
|
if (function == null || !context.shouldContainDebugInfo()) return null
|
||||||
val functionScope = function?.scope()
|
val functionScope = function.scope()
|
||||||
if (functionScope == null || !element.needDebugInfo(context)) return null
|
if (functionScope == null || !element.needDebugInfo(context)) return null
|
||||||
val location = debugLocation(element)
|
val location = debugLocation(element)
|
||||||
val file = (currentCodeContext.fileScope() as FileScope).file.file()
|
val file = (currentCodeContext.fileScope() as FileScope).file.file()
|
||||||
@@ -1159,7 +1159,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
val value = variable.initializer?.let { evaluateExpression(it) }
|
val value = variable.initializer?.let { evaluateExpression(it) }
|
||||||
currentCodeContext.genDeclareVariable(
|
currentCodeContext.genDeclareVariable(
|
||||||
variable.descriptor, value, debugInfoIfNeeded(
|
variable.descriptor, value, debugInfoIfNeeded(
|
||||||
(currentCodeContext.functionScope() as FunctionScope)?.declaration, variable))
|
(currentCodeContext.functionScope() as FunctionScope).declaration, variable))
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
@@ -1421,7 +1421,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
IrConstKind.Short -> return LLVMConstInt(LLVMInt16Type(), (value.value as Short).toLong(), 1)!!
|
IrConstKind.Short -> return LLVMConstInt(LLVMInt16Type(), (value.value as Short).toLong(), 1)!!
|
||||||
IrConstKind.Int -> return LLVMConstInt(LLVMInt32Type(), (value.value as Int).toLong(), 1)!!
|
IrConstKind.Int -> return LLVMConstInt(LLVMInt32Type(), (value.value as Int).toLong(), 1)!!
|
||||||
IrConstKind.Long -> return LLVMConstInt(LLVMInt64Type(), value.value as Long, 1)!!
|
IrConstKind.Long -> return LLVMConstInt(LLVMInt64Type(), value.value as Long, 1)!!
|
||||||
IrConstKind.String -> return evaluateStringConst(value as IrConst<String>)
|
IrConstKind.String -> return evaluateStringConst(@Suppress("UNCHECKED_CAST") value as IrConst<String>)
|
||||||
IrConstKind.Float -> return LLVMConstRealOfString(LLVMFloatType(), (value.value as Float).toString())!!
|
IrConstKind.Float -> return LLVMConstRealOfString(LLVMFloatType(), (value.value as Float).toString())!!
|
||||||
IrConstKind.Double -> return LLVMConstRealOfString(LLVMDoubleType(), (value.value as Double).toString())!!
|
IrConstKind.Double -> return LLVMConstRealOfString(LLVMDoubleType(), (value.value as Double).toString())!!
|
||||||
}
|
}
|
||||||
@@ -1634,6 +1634,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.builtIns.immutableBinaryBlobOf -> {
|
context.builtIns.immutableBinaryBlobOf -> {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val arg = expression.getValueArgument(0) as IrConst<String>
|
val arg = expression.getValueArgument(0) as IrConst<String>
|
||||||
return context.llvm.staticData.createImmutableBinaryBlob(arg)
|
return context.llvm.staticData.createImmutableBinaryBlob(arg)
|
||||||
}
|
}
|
||||||
@@ -1666,12 +1667,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
value is IrDelegatingConstructorCall ->
|
value is IrDelegatingConstructorCall ->
|
||||||
return delegatingConstructorCall(value.descriptor, args)
|
return delegatingConstructorCall(value.descriptor, args)
|
||||||
|
|
||||||
value.descriptor is FunctionDescriptor ->
|
else ->
|
||||||
return evaluateFunctionCall(
|
return evaluateFunctionCall(value as IrCall, args, resultLifetime(value))
|
||||||
value as IrCall, args, resultLifetime(value))
|
|
||||||
else -> {
|
|
||||||
TODO(ir2string(value))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ internal class VariableManager(val functionGenerationContext: FunctionGeneration
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal var skip = 0
|
internal var skip = 0
|
||||||
internal fun createParameter(descriptor: ValueDescriptor, value: LLVMValueRef? = null, variableLocation: VariableDebugLocation?) : Int {
|
internal fun createParameter(descriptor: ValueDescriptor, variableLocation: VariableDebugLocation?) : Int {
|
||||||
assert(!contextVariablesToIndex.contains(descriptor))
|
assert(!contextVariablesToIndex.contains(descriptor))
|
||||||
val index = variables.size
|
val index = variables.size
|
||||||
val type = functionGenerationContext.getLLVMType(descriptor.type)
|
val type = functionGenerationContext.getLLVMType(descriptor.type)
|
||||||
|
|||||||
+2
-2
@@ -194,8 +194,8 @@ internal class BlockAdapterToFunctionGenerator(val objCExportCodeGenerator: ObjC
|
|||||||
val blockOnStackBase = structGep(blockOnStack, 0)
|
val blockOnStackBase = structGep(blockOnStack, 0)
|
||||||
val slot = structGep(blockOnStack, 1)
|
val slot = structGep(blockOnStack, 1)
|
||||||
|
|
||||||
listOf(bitcast(int8TypePtr, isa), flags, reserved, invoke, descriptor).forEachIndexed { index, it ->
|
listOf(bitcast(int8TypePtr, isa), flags, reserved, invoke, descriptor).forEachIndexed { index, value ->
|
||||||
storeAny(it, structGep(blockOnStackBase, index))
|
storeAny(value, structGep(blockOnStackBase, index))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: it is the slot in the block located on stack, so no need to manage it properly:
|
// Note: it is the slot in the block located on stack, so no need to manage it properly:
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ private class ForLoopsTransformer(val context: Context) : IrElementTransformerVo
|
|||||||
pkg: FqName,
|
pkg: FqName,
|
||||||
filter: (SimpleFunctionDescriptor) -> Boolean): Set<IrFunctionSymbol> =
|
filter: (SimpleFunctionDescriptor) -> Boolean): Set<IrFunctionSymbol> =
|
||||||
mutableSetOf<IrFunctionSymbol>().apply {
|
mutableSetOf<IrFunctionSymbol>().apply {
|
||||||
progressionElementClasses.flatMapTo(this) { receiver ->
|
progressionElementClasses.flatMapTo(this) { _ /* receiver */ ->
|
||||||
context.builtIns.builtInsModule.getPackage(pkg).memberScope
|
context.builtIns.builtInsModule.getPackage(pkg).memberScope
|
||||||
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND)
|
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND)
|
||||||
.filter(filter).map { symbols.symbolTable.referenceFunction(it) }
|
.filter(filter).map { symbols.symbolTable.referenceFunction(it) }
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
|
|||||||
//--- Helpers -------------------------------------------------------------//
|
//--- Helpers -------------------------------------------------------------//
|
||||||
|
|
||||||
private fun isLambdaCall(irCall: IrCall) : Boolean {
|
private fun isLambdaCall(irCall: IrCall) : Boolean {
|
||||||
if (!(irCall.descriptor as FunctionDescriptor).isFunctionInvoke) return false // Lambda mast be called by "invoke".
|
if (!irCall.descriptor.isFunctionInvoke) return false // Lambda mast be called by "invoke".
|
||||||
if (irCall.dispatchReceiver !is IrGetValue) return false // Dispatch receiver mast be IrGetValue.
|
if (irCall.dispatchReceiver !is IrGetValue) return false // Dispatch receiver mast be IrGetValue.
|
||||||
return true // It is lambda call.
|
return true // It is lambda call.
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1056,7 +1056,7 @@ internal class SuspendFunctionsLowering(val context: Context): DeclarationContai
|
|||||||
result = irBlock(startOffset, endOffset) {
|
result = irBlock(startOffset, endOffset) {
|
||||||
if (!calledSaveState)
|
if (!calledSaveState)
|
||||||
+irCall(saveStateSymbol)
|
+irCall(saveStateSymbol)
|
||||||
+irSetVar(suspendResult, suspendCall!!)
|
+irSetVar(suspendResult, suspendCall)
|
||||||
+irReturnIfSuspended(suspendResult)
|
+irReturnIfSuspended(suspendResult)
|
||||||
+irGet(suspendResult)
|
+irGet(suspendResult)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user