translator: hashcode functions, cleanup

This commit is contained in:
e5l
2016-08-10 13:34:35 +03:00
parent dd5c884deb
commit 3c8bdb61cb
11 changed files with 50 additions and 5 deletions
-1
View File
@@ -10,7 +10,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="translator_main" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: com.github.jshmrsn:karg:a636b3e" level="project" />
@@ -529,7 +529,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
private fun evaluatePrefixExpression(expr: KtPrefixExpression, scopeDepth: Int): LLVMSingleValue? {
val operator = expr.operationToken
val left = evaluateExpression(expr.baseExpression, scopeDepth) ?: throw UnsupportedOperationException("Wrong binary exception")
return executePrefixExpression(operator, expr.operationReference, left as LLVMSingleValue)
return executePrefixExpression(operator, expr.operationReference, left)
}
private fun executePostfixExpression(operator: IElementType?, operationReference: KtSimpleNameExpression, left: LLVMVariable): LLVMSingleValue?
@@ -1,7 +1,6 @@
package org.kotlinnative.translator.llvm.types
import org.kotlinnative.translator.llvm.LLVMExpression
import org.kotlinnative.translator.llvm.LLVMNode
import org.kotlinnative.translator.llvm.LLVMSingleValue
@@ -64,4 +63,10 @@ class LLVMBooleanType() : LLVMType() {
override fun isPrimitive() = true
override fun toString() = "i1"
override fun hashCode(): Int{
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
}
@@ -33,4 +33,10 @@ class LLVMByteType() : LLVMType() {
override fun toString(): String = "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
}
}
@@ -33,4 +33,10 @@ class LLVMCharType() : LLVMType() {
override fun toString(): String = "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
}
}
@@ -29,4 +29,10 @@ class LLVMDoubleType() : LLVMType() {
override fun toString() = "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
}
}
@@ -29,4 +29,10 @@ class LLVMFloatType() : LLVMType() {
override fun toString() = "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
}
}
@@ -3,7 +3,6 @@ package org.kotlinnative.translator.llvm.types
import org.kotlinnative.translator.exceptions.UnimplementedException
import org.kotlinnative.translator.llvm.LLVMExpression
import org.kotlinnative.translator.llvm.LLVMSingleValue
import org.kotlinnative.translator.llvm.LLVMVariable
class LLVMIntType() : LLVMType() {
@@ -82,4 +81,10 @@ class LLVMIntType() : LLVMType() {
override fun toString() = "i32"
override fun isPrimitive() = true
override fun hashCode(): Int{
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
}
@@ -76,4 +76,10 @@ class LLVMLongType() : LLVMType() {
override fun mangle() = "Long"
override fun toString() = "i64"
override fun isPrimitive() = true
override fun hashCode(): Int{
var result = align
result = 31 * result + size
result = 31 * result + defaultValue.hashCode()
return result
}
}
@@ -33,4 +33,10 @@ class LLVMShortType() : LLVMType() {
override fun mangle() = "Short"
override fun toString(): String = "i16"
override fun isPrimitive() = true
override fun hashCode(): Int{
var result = size
result = 31 * result + align
result = 31 * result + defaultValue.hashCode()
return result
}
}
@@ -1,4 +1,4 @@
fun reassigment_0(x: Int): Int {
var b = x + 1
val b = x + 1
return b
}