translator: fix class comparison in expressions, tests
This commit is contained in:
@@ -734,6 +734,14 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun receivePointedArgument(variable: LLVMSingleValue, pointer: Int): LLVMSingleValue {
|
||||||
|
var currentVariable = variable
|
||||||
|
while (currentVariable.pointer > pointer) {
|
||||||
|
currentVariable = codeBuilder.receiveNativeValue(variable)
|
||||||
|
}
|
||||||
|
return currentVariable
|
||||||
|
}
|
||||||
|
|
||||||
private fun addPrimitiveBinaryOperation(operator: IElementType, referenceName: KtSimpleNameExpression?, firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMVariable {
|
private fun addPrimitiveBinaryOperation(operator: IElementType, referenceName: KtSimpleNameExpression?, firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMVariable {
|
||||||
val firstNativeOp = codeBuilder.receiveNativeValue(firstOp)
|
val firstNativeOp = codeBuilder.receiveNativeValue(firstOp)
|
||||||
val secondNativeOp = codeBuilder.receiveNativeValue(secondOp)
|
val secondNativeOp = codeBuilder.receiveNativeValue(secondOp)
|
||||||
@@ -746,14 +754,36 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
KtTokens.LTEQ -> firstOp.type!!.operatorLeq(firstNativeOp, secondNativeOp)
|
KtTokens.LTEQ -> firstOp.type!!.operatorLeq(firstNativeOp, secondNativeOp)
|
||||||
KtTokens.GTEQ -> firstOp.type!!.operatorGeq(firstNativeOp, secondNativeOp)
|
KtTokens.GTEQ -> firstOp.type!!.operatorGeq(firstNativeOp, secondNativeOp)
|
||||||
KtTokens.EQEQ ->
|
KtTokens.EQEQ ->
|
||||||
if ((firstOp.type is LLVMReferenceType) && (secondOp.type !is LLVMReferenceType))
|
if (firstOp.type is LLVMReferenceType)
|
||||||
firstOp.type!!.operatorEq(firstNativeOp, secondOp)
|
if (secondOp.type is LLVMReferenceType) {
|
||||||
|
val firstPointedArgument = receivePointedArgument(firstOp, 1)
|
||||||
|
val secondPointedArgument = receivePointedArgument(secondOp, 1)
|
||||||
|
firstOp.type!!.operatorEq(firstPointedArgument, secondPointedArgument)
|
||||||
|
} else
|
||||||
|
firstOp.type!!.operatorEq(firstNativeOp, secondOp)
|
||||||
else
|
else
|
||||||
firstOp.type!!.operatorEq(firstNativeOp, secondNativeOp)
|
firstOp.type!!.operatorEq(firstNativeOp, secondNativeOp)
|
||||||
KtTokens.EQEQEQ ->
|
KtTokens.EQEQEQ -> {
|
||||||
firstOp.type!!.operatorEq(firstNativeOp, secondNativeOp)
|
val firstPointedArgument = receivePointedArgument(firstOp, 1)
|
||||||
KtTokens.EXCLEQ -> firstOp.type!!.operatorNeq(firstNativeOp, secondNativeOp)
|
val secondPointedArgument = receivePointedArgument(secondOp, 1)
|
||||||
KtTokens.EXCLEQEQEQ -> firstOp.type!!.operatorNeq(firstNativeOp, secondNativeOp)
|
firstOp.type!!.operatorEq(firstPointedArgument, secondPointedArgument)
|
||||||
|
}
|
||||||
|
KtTokens.EXCLEQ -> {
|
||||||
|
if (firstOp.type is LLVMReferenceType)
|
||||||
|
if (secondOp.type is LLVMReferenceType) {
|
||||||
|
val firstPointedArgument = receivePointedArgument(firstOp, 1)
|
||||||
|
val secondPointedArgument = receivePointedArgument(secondOp, 1)
|
||||||
|
firstOp.type!!.operatorNeq(firstPointedArgument, secondPointedArgument)
|
||||||
|
} else
|
||||||
|
firstOp.type!!.operatorNeq(firstNativeOp, secondOp)
|
||||||
|
else
|
||||||
|
firstOp.type!!.operatorNeq(firstNativeOp, secondNativeOp)
|
||||||
|
}
|
||||||
|
KtTokens.EXCLEQEQEQ -> {
|
||||||
|
val firstPointedArgument = receivePointedArgument(firstOp, 1)
|
||||||
|
val secondPointedArgument = receivePointedArgument(secondOp, 1)
|
||||||
|
firstOp.type!!.operatorNeq(firstPointedArgument, secondPointedArgument)
|
||||||
|
}
|
||||||
KtTokens.EQ -> {
|
KtTokens.EQ -> {
|
||||||
if (secondOp.type is LLVMNullType) {
|
if (secondOp.type is LLVMNullType) {
|
||||||
val result = codeBuilder.getNewVariable(firstOp.type!!, firstOp.pointer)
|
val result = codeBuilder.getNewVariable(firstOp.type!!, firstOp.pointer)
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class LLVMVoidType() : LLVMType() {
|
|||||||
override fun mangle() = ""
|
override fun mangle() = ""
|
||||||
override val typename = "void"
|
override val typename = "void"
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
return other is LLVMVoidType
|
||||||
|
}
|
||||||
|
|
||||||
override fun hashCode() =
|
override fun hashCode() =
|
||||||
typename.hashCode()
|
typename.hashCode()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
referential_equality_2_EQ_master() == 1
|
||||||
|
referential_equality_2_NEQ_master() == 1
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
class referential_equality_2_A
|
||||||
|
|
||||||
|
fun referential_equality_2_build(): referential_equality_2_A {
|
||||||
|
return referential_equality_2_A()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun referential_equality_2_EQ_slave(second_msg: referential_equality_2_A): Int {
|
||||||
|
if (second_msg == referential_equality_2_build()) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun referential_equality_2_NEQ_slave(second_msg: referential_equality_2_A): Int {
|
||||||
|
if (second_msg != referential_equality_2_build()) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun referential_equality_2_EQ_master(): Int {
|
||||||
|
return referential_equality_2_EQ_slave(referential_equality_2_build())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun referential_equality_2_NEQ_master(): Int {
|
||||||
|
return referential_equality_2_NEQ_slave(referential_equality_2_build())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user