Minor: cleanup in ExpressionCodegen
This commit is contained in:
@@ -2873,75 +2873,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<? extends CallableDescriptor> 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) {
|
||||
|
||||
Reference in New Issue
Block a user