translator: rewrites hashcodes for classes

This commit is contained in:
Alexey Stepanov
2016-08-12 11:03:51 +03:00
parent 7fce334875
commit 143985a887
13 changed files with 53 additions and 49 deletions
@@ -63,10 +63,7 @@ class LLVMBooleanType() : LLVMType() {
override fun isPrimitive() = true
override val typename = "i1"
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -33,10 +33,7 @@ class LLVMByteType() : LLVMType() {
override val typename = "i8"
override val defaultValue = "0"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -33,10 +33,7 @@ class LLVMCharType() : LLVMType() {
override val typename = "i8"
override val defaultValue = "0"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -53,10 +53,7 @@ class LLVMDoubleType() : LLVMType() {
override val typename = "double"
override val defaultValue = "0.0"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -53,10 +53,7 @@ class LLVMFloatType() : LLVMType() {
override val typename = "float"
override val defaultValue = "0.0"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
typename.hashCode()
}
@@ -29,4 +29,12 @@ class LLVMFunctionType(type: KotlinType) : LLVMType() {
"${returnType.type} (${arguments.map { it.getType() }.joinToString()})"
override val typename = "FunctionType"
override fun hashCode() =
mangle().hashCode()
override fun equals(other: Any?): Boolean {
return (other is LLVMFunctionType) && (mangle() == other.mangle())
}
}
@@ -81,10 +81,7 @@ class LLVMIntType() : LLVMType() {
override val typename = "i32"
override fun isPrimitive() = true
override fun hashCode(): Int{
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -76,10 +76,7 @@ class LLVMLongType() : LLVMType() {
override fun mangle() = "Long"
override val typename = "i64"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -8,4 +8,12 @@ class LLVMNullType() : LLVMType() {
override fun mangle() = ""
override val typename = ""
override fun equals(other: Any?): Boolean {
return other is LLVMNullType
}
override fun hashCode() =
"null".hashCode()
}
@@ -31,4 +31,11 @@ class LLVMReferenceType(val type: String, var prefix: String = "", override val
override fun operatorNeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "icmp ne ${firstOp.getType()} $firstOp, ${if (secondOp.type is LLVMNullType) "null" else "$secondOp"}")
override fun equals(other: Any?): Boolean {
return (other is LLVMReferenceType) and (typename.equals((other as LLVMReferenceType).typename))
}
override fun hashCode() =
typename.hashCode()
}
@@ -33,10 +33,7 @@ class LLVMShortType() : LLVMType() {
override fun mangle() = "Short"
override val typename = "i16"
override fun isPrimitive() = true
override fun hashCode(): Int {
var result = size
result = 31 * result + align
result = 31 * result + defaultValue.hashCode()
return result
}
override fun hashCode() =
mangle().hashCode()
}
@@ -18,6 +18,7 @@ class LLVMStringType(override val length: Int) : LLVMArray, LLVMType() {
override val typename = "i8*"
override fun fullType() = "[${length + 1} x i8]"
override fun hashCode(): Int {
return length
return length * 31 +
mangle().hashCode()
}
}
@@ -8,4 +8,8 @@ class LLVMVoidType() : LLVMType() {
override fun mangle() = ""
override val typename = "void"
override fun hashCode() =
typename.hashCode()
}