From db1dcc68ff0574614d748d39a74937cbf54a0ad4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 3 Jul 2017 14:29:07 +0300 Subject: [PATCH] Minor: cleanup in ExpressionCodegen --- .../kotlin/codegen/ExpressionCodegen.java | 69 ------------------- 1 file changed, 69 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 5f9080ce526..d6ed3b4bcfd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2873,75 +2873,6 @@ public class ExpressionCodegen extends KtVisitor impleme assert deparenthesized != null : "For with empty range expression"; RangeValue rangeValue = RangeValuesKt.createRangeValueForExpression(this, deparenthesized); return rangeValue.createInExpressionGenerator(this, operationReference).generate(leftValue); - - //boolean isInverted = operationReference.getReferencedNameElementType() == KtTokens.NOT_IN; - //return StackValue.operation(Type.BOOLEAN_TYPE, v -> { - // if (RangeCodegenUtilKt.isPrimitiveRangeSpecializationOfType(leftValue.type, deparenthesized, bindingContext) || - // RangeCodegenUtilKt.isPrimitiveRangeToExtension(operationReference, bindingContext)) { - // generateInPrimitiveRange(leftValue, (KtBinaryExpression) deparenthesized, isInverted); - // } - // else { - // ResolvedCall resolvedCall = CallUtilKt - // .getResolvedCallWithAssert(operationReference, bindingContext); - // StackValue result = invokeFunction(resolvedCall.getCall(), resolvedCall, StackValue.none()); - // result.put(result.type, v); - // if (isInverted) { - // genInvertBoolean(v); - // } - // } - // return null; - //}); - } - - /* - * Translates x in a..b to a <= x && x <= b - * and x !in a..b to a > x || x > b for any primitive type - */ - private void generateInPrimitiveRange(StackValue argument, KtBinaryExpression rangeExpression, boolean isInverted) { - Type rangeType = argument.type; - int localVarIndex = myFrameMap.enterTemp(rangeType); - // Load left bound - gen(rangeExpression.getLeft(), rangeType); - // Load x into local variable to avoid StackValue#put side-effects - argument.put(rangeType, v); - v.store(localVarIndex, rangeType); - v.load(localVarIndex, rangeType); - - // If (x < left) goto L1 - Label l1 = new Label(); - emitGreaterThan(rangeType, l1); - - // If (x > right) goto L1 - v.load(localVarIndex, rangeType); - gen(rangeExpression.getRight(), rangeType); - emitGreaterThan(rangeType, l1); - - Label l2 = new Label(); - v.iconst(isInverted ? 0 : 1); - v.goTo(l2); - - v.mark(l1); - v.iconst(isInverted ? 1 : 0); - v.mark(l2); - myFrameMap.leaveTemp(rangeType); - } - - private void emitGreaterThan(Type type, Label label) { - if (AsmUtil.isIntPrimitive(type)) { - v.ificmpgt(label); - } - else if (type == Type.LONG_TYPE) { - v.lcmp(); - v.ifgt(label); - } - // '>' != 'compareTo' for NaN and +/- 0.0 - else if (type == Type.FLOAT_TYPE || type == Type.DOUBLE_TYPE) { - v.cmpg(type); - v.ifgt(label); - } - else { - throw new UnsupportedOperationException("Unexpected type: " + type); - } } private StackValue generateBooleanAnd(KtBinaryExpression expression) {