backend: improve Nothing type handling
This commit is contained in:
committed by
SvyatoslavScherbina
parent
44f2036506
commit
61c28db886
+7
-7
@@ -272,16 +272,16 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
fun evaluateBreak(destination: IrBreak): LLVMValueRef? {
|
fun evaluateBreak(destination: IrBreak): LLVMValueRef {
|
||||||
currentCodeContext.genBreak(destination)
|
currentCodeContext.genBreak(destination)
|
||||||
return null
|
return codegen.kNothingFakeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
fun evaluateContinue(destination: IrContinue): LLVMValueRef? {
|
fun evaluateContinue(destination: IrContinue): LLVMValueRef {
|
||||||
currentCodeContext.genContinue(destination)
|
currentCodeContext.genContinue(destination)
|
||||||
return null
|
return codegen.kNothingFakeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
@@ -860,10 +860,10 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
private fun evaluateThrow(tmpVariableName: String, expression: IrThrow): LLVMValueRef? {
|
private fun evaluateThrow(tmpVariableName: String, expression: IrThrow): LLVMValueRef {
|
||||||
val exception = evaluateExpression(codegen.newVar(), expression.value)!!
|
val exception = evaluateExpression(codegen.newVar(), expression.value)!!
|
||||||
currentCodeContext.genThrow(exception)
|
currentCodeContext.genThrow(exception)
|
||||||
return null
|
return codegen.kNothingFakeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
@@ -1516,7 +1516,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentCodeContext.genReturn(expression.returnTarget, ret)
|
currentCodeContext.genReturn(expression.returnTarget, ret)
|
||||||
return null
|
return codegen.kNothingFakeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|||||||
+4
@@ -128,6 +128,10 @@ internal val kImmInt64One = Int64(1).llvm
|
|||||||
internal val ContextUtils.kNullObjHeaderPtr: LLVMValueRef
|
internal val ContextUtils.kNullObjHeaderPtr: LLVMValueRef
|
||||||
get() = LLVMConstNull(this.kObjHeaderPtr)!!
|
get() = LLVMConstNull(this.kObjHeaderPtr)!!
|
||||||
|
|
||||||
|
// Nothing type has no values, but we do generate unreachable code and thus need some fake value:
|
||||||
|
internal val ContextUtils.kNothingFakeValue: LLVMValueRef
|
||||||
|
get() = LLVMGetUndef(kObjHeaderPtr)!!
|
||||||
|
|
||||||
internal fun pointerType(pointeeType: LLVMTypeRef) = LLVMPointerType(pointeeType, 0)!!
|
internal fun pointerType(pointeeType: LLVMTypeRef) = LLVMPointerType(pointeeType, 0)!!
|
||||||
|
|
||||||
internal fun structType(vararg types: LLVMTypeRef): LLVMTypeRef = structType(types.toList())
|
internal fun structType(vararg types: LLVMTypeRef): LLVMTypeRef = structType(types.toList())
|
||||||
|
|||||||
Reference in New Issue
Block a user