From 7c7f0e448497f2a4238507738f4fbdcac1aab216 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Thu, 11 Aug 2016 10:10:57 +0300 Subject: [PATCH] translator: fix square brackets operator for binary expressions --- .../org/kotlinnative/translator/BlockCodegen.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/translator/src/main/kotlin/org/kotlinnative/translator/BlockCodegen.kt b/translator/src/main/kotlin/org/kotlinnative/translator/BlockCodegen.kt index 6efaacaf34f..f6391305c5d 100644 --- a/translator/src/main/kotlin/org/kotlinnative/translator/BlockCodegen.kt +++ b/translator/src/main/kotlin/org/kotlinnative/translator/BlockCodegen.kt @@ -535,14 +535,18 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va return evaluateElvisOperator(expr, scopeDepth) } - val left = evaluateExpression(expr.firstChild, scopeDepth) - if (expr.firstChild is KtArrayAccessExpression) { - return null - } else { - left ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}") + val left = evaluateExpression(expr.left, scopeDepth) + if (expr.left is KtArrayAccessExpression) { + val callMaker = state.bindingContext.get(BindingContext.CALL, expr.left) + if (callMaker!!.callType == Call.CallType.ARRAY_SET_METHOD) { + return left as LLVMVariable? + } } - val right = evaluateExpression(expr.lastChild, scopeDepth) ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}") + left ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}") + + + val right = evaluateExpression(expr.right, scopeDepth) ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}") return executeBinaryExpression(operator, expr.operationReference, left, right) }