translator: small cleanup

This commit is contained in:
e5l
2016-08-12 10:30:23 +03:00
parent 5a823a3c17
commit fc9cfb902f
2 changed files with 5 additions and 5 deletions
@@ -353,12 +353,9 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
private fun evaluateNameReferenceExpression(expr: KtNameReferenceExpression, classScope: StructCodegen): LLVMSingleValue? {
val fieldName = state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr)!!.name.toString()
val companionObject = (classScope as ClassCodegen).companionObjectCodegen ?: throw UnexpectedException(expr.text)
val field = companionObject.fieldsIndex[fieldName]
val field = companionObject.fieldsIndex[fieldName] ?: throw UnexpectedException(expr.text)
val receiver = variableManager[companionObject.fullName]!!
if (field == null) {
throw UnexpectedException("")
}
val result = codeBuilder.getNewVariable(field!!.type, pointer = 1)
val result = codeBuilder.getNewVariable(field.type, pointer = 1)
codeBuilder.loadClassField(result, receiver, field.offset)
return result
@@ -17,4 +17,7 @@ class LLVMStringType(override val length: Int) : LLVMArray, LLVMType() {
override fun basicType() = LLVMCharType()
override val typename = "i8*"
override fun fullType() = "[${length + 1} x i8]"
override fun hashCode(): Int {
return length
}
}