Minor, add helper StackValue.constant(int)
This commit is contained in:
@@ -2937,7 +2937,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
v.dup();
|
||||
StackValue rightSide = gen(arguments.get(i).getArgumentExpression());
|
||||
StackValue
|
||||
.arrayElement(elementType, elementKotlinType, StackValue.onStack(type, outType), StackValue.constant(i, Type.INT_TYPE))
|
||||
.arrayElement(elementType, elementKotlinType, StackValue.onStack(type, outType), StackValue.constant(i))
|
||||
.store(rightSide, v);
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
|
||||
@@ -603,7 +603,7 @@ public class PropertyCodegen {
|
||||
StackValue.Field array = StackValue.field(
|
||||
Type.getType("[" + K_PROPERTY_TYPE), owner, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME, true, StackValue.none()
|
||||
);
|
||||
return StackValue.arrayElement(K_PROPERTY_TYPE, null, array, StackValue.constant(index, Type.INT_TYPE));
|
||||
return StackValue.arrayElement(K_PROPERTY_TYPE, null, array, StackValue.constant(index));
|
||||
}
|
||||
|
||||
private static class DelegatedPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {
|
||||
|
||||
@@ -213,6 +213,11 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue constant(int value) {
|
||||
return constant(value, Type.INT_TYPE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue constant(@Nullable Object value, @NotNull Type type) {
|
||||
return constant(value, type, null);
|
||||
|
||||
+1
-2
@@ -47,8 +47,7 @@ class ArrayWithIndexForLoopGenerator(
|
||||
v.arraylength()
|
||||
v.store(arrayLengthVar, Type.INT_TYPE)
|
||||
|
||||
StackValue.local(indexVar, indexType)
|
||||
.store(StackValue.constant(0, Type.INT_TYPE), v)
|
||||
StackValue.local(indexVar, indexType).store(StackValue.constant(0), v)
|
||||
}
|
||||
|
||||
override fun checkPreCondition(loopExit: Label) {
|
||||
|
||||
+1
-2
@@ -44,8 +44,7 @@ class CharSequenceWithIndexForLoopGenerator(
|
||||
indexVar = indexLoopComponent?.parameterVar ?: createLoopTempVariable(Type.INT_TYPE)
|
||||
indexType = indexLoopComponent?.parameterType ?: Type.INT_TYPE
|
||||
|
||||
StackValue.local(indexVar, indexType)
|
||||
.store(StackValue.constant(0, Type.INT_TYPE), v)
|
||||
StackValue.local(indexVar, indexType).store(StackValue.constant(0), v)
|
||||
}
|
||||
|
||||
private fun evalCharSeqLengthOnStack() {
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ class IteratorWithIndexForLoopGenerator(
|
||||
indexVar = indexLoopComponent?.parameterVar ?: createLoopTempVariable(Type.INT_TYPE)
|
||||
indexType = indexLoopComponent?.parameterType ?: Type.INT_TYPE
|
||||
|
||||
StackValue.local(indexVar, indexType)
|
||||
.store(StackValue.constant(0, Type.INT_TYPE), v)
|
||||
StackValue.local(indexVar, indexType).store(StackValue.constant(0), v)
|
||||
|
||||
iteratorVar = createLoopTempVariable(asmTypeForIterator)
|
||||
codegen.generateCallReceiver(rangeCall).put(iteratorOwnerType, v)
|
||||
|
||||
+1
-1
@@ -507,7 +507,7 @@ class ExpressionCodegen(
|
||||
val elementKotlinType = classCodegen.context.builtIns.getArrayElementType(outType.toKotlinType()!!)
|
||||
for ((i, element) in expression.elements.withIndex()) {
|
||||
mv.dup()
|
||||
StackValue.constant(i, Type.INT_TYPE).put(Type.INT_TYPE, mv)
|
||||
StackValue.constant(i).put(Type.INT_TYPE, mv)
|
||||
val rightSide = gen(element, elementType, data)
|
||||
StackValue
|
||||
.arrayElement(
|
||||
|
||||
Reference in New Issue
Block a user