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