Remove import of StackValue.* to better see use sites

This commit is contained in:
pyos
2019-03-29 12:10:21 +01:00
committed by max-kammerer
parent a9bece9baa
commit c5f6be4282
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.AsmUtil.* import org.jetbrains.kotlin.codegen.AsmUtil.*
import org.jetbrains.kotlin.codegen.ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameter import org.jetbrains.kotlin.codegen.ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameter
import org.jetbrains.kotlin.codegen.StackValue.*
import org.jetbrains.kotlin.codegen.inline.* import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner.OperationKind.AS import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner.OperationKind.AS
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner.OperationKind.SAFE_AS import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner.OperationKind.SAFE_AS
@@ -150,7 +149,7 @@ class ExpressionCodegen(
// idempotent and must always be done before generating other values or emitting raw bytecode. // idempotent and must always be done before generating other values or emitting raw bytecode.
internal fun StackValue.materialize(): StackValue { internal fun StackValue.materialize(): StackValue {
put(type, kotlinType, mv) put(type, kotlinType, mv)
return onStack(type, kotlinType) return StackValue.onStack(type, kotlinType)
} }
// Same as above, but if the type is Unit, do not materialize the actual push of a constant value. // Same as above, but if the type is Unit, do not materialize the actual push of a constant value.
@@ -294,7 +293,7 @@ class ExpressionCodegen(
} }
private fun visitStatementContainer(container: IrStatementContainer, data: BlockInfo): StackValue = private fun visitStatementContainer(container: IrStatementContainer, data: BlockInfo): StackValue =
container.statements.fold(none()) { prev, exp -> container.statements.fold(StackValue.none()) { prev, exp ->
prev.discard() prev.discard()
exp.accept(this, data).also { (exp as? IrExpression)?.markEndOfStatementIfNeeded() } exp.accept(this, data).also { (exp as? IrExpression)?.markEndOfStatementIfNeeded() }
} }
@@ -428,10 +427,10 @@ class ExpressionCodegen(
mv.athrow() mv.athrow()
return expression.onStack return expression.onStack
} else if (expression.descriptor is ConstructorDescriptor) { } else if (expression.descriptor is ConstructorDescriptor) {
return none() return StackValue.none()
} }
return onStack(callable.returnType, returnType).coerce(expression.type) return StackValue.onStack(callable.returnType, returnType).coerce(expression.type)
} }
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: BlockInfo): StackValue { override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: BlockInfo): StackValue {
@@ -452,7 +451,7 @@ class ExpressionCodegen(
} }
data.variables.add(VariableInfo(declaration, index, varType, markNewLabel())) data.variables.add(VariableInfo(declaration, index, varType, markNewLabel()))
return none() return StackValue.none()
} }
override fun visitGetValue(expression: IrGetValue, data: BlockInfo): StackValue { override fun visitGetValue(expression: IrGetValue, data: BlockInfo): StackValue {
@@ -495,7 +494,7 @@ class ExpressionCodegen(
expression.markLineNumber(startOffset = true) expression.markLineNumber(startOffset = true)
generateFieldValue(expression, data, true).store(expressionValue.accept(this, data), mv) generateFieldValue(expression, data, true).store(expressionValue.accept(this, data), mv)
} }
return none().coerce(expression.type) return StackValue.none().coerce(expression.type)
} }
/** /**
@@ -530,7 +529,7 @@ class ExpressionCodegen(
expression.value.markLineNumber(startOffset = true) expression.value.markLineNumber(startOffset = true)
val value = expression.value.accept(this, data) val value = expression.value.accept(this, data)
StackValue.local(findLocalIndex(expression.symbol), expression.descriptor.asmType).store(value, mv) StackValue.local(findLocalIndex(expression.symbol), expression.descriptor.asmType).store(value, mv)
return none().coerce(expression.type) return StackValue.none().coerce(expression.type)
} }
override fun <T> visitConst(expression: IrConst<T>, data: BlockInfo): StackValue { override fun <T> visitConst(expression: IrConst<T>, data: BlockInfo): StackValue {
@@ -552,7 +551,7 @@ class ExpressionCodegen(
// TODO maybe remove? // TODO maybe remove?
override fun visitClass(declaration: IrClass, data: BlockInfo): StackValue { override fun visitClass(declaration: IrClass, data: BlockInfo): StackValue {
classCodegen.generateLocalClass(declaration) classCodegen.generateLocalClass(declaration)
return none() return StackValue.none()
} }
override fun visitVararg(expression: IrVararg, data: BlockInfo): StackValue { override fun visitVararg(expression: IrVararg, data: BlockInfo): StackValue {
@@ -666,7 +665,7 @@ class ExpressionCodegen(
mv, "java/lang/UnsupportedOperationException", mv, "java/lang/UnsupportedOperationException",
"Non-local returns are not allowed with inlining disabled" "Non-local returns are not allowed with inlining disabled"
) )
return none() return StackValue.none()
} }
val returnType = typeMapper.mapReturnType(owner.descriptor) val returnType = typeMapper.mapReturnType(owner.descriptor)
@@ -680,7 +679,7 @@ class ExpressionCodegen(
mv.areturn(returnType) mv.areturn(returnType)
mv.mark(afterReturnLabel) mv.mark(afterReturnLabel)
mv.nop()/*TODO check RESTORE_STACK_IN_TRY_CATCH processor*/ mv.nop()/*TODO check RESTORE_STACK_IN_TRY_CATCH processor*/
return expression.onStack return StackValue.none()
} }
override fun visitWhen(expression: IrWhen, data: BlockInfo): StackValue { override fun visitWhen(expression: IrWhen, data: BlockInfo): StackValue {
@@ -713,7 +712,7 @@ class ExpressionCodegen(
} }
// Produce the default value for the type. Doesn't really matter right now, as non-exhaustive // Produce the default value for the type. Doesn't really matter right now, as non-exhaustive
// conditionals cannot be used as expressions. // conditionals cannot be used as expressions.
val result = none().coerce(expression.type).materializeNonUnit() val result = StackValue.none().coerce(expression.type).materializeNonUnit()
mv.mark(endLabel) mv.mark(endLabel)
return result return result
} }
@@ -747,7 +746,7 @@ class ExpressionCodegen(
state.languageVersionSettings.isReleaseCoroutines() state.languageVersionSettings.isReleaseCoroutines()
) )
} }
onStack(boxedType).coerce(expression.type) StackValue.onStack(boxedType).coerce(expression.type)
} }
IrTypeOperator.INSTANCEOF, IrTypeOperator.NOT_INSTANCEOF -> { IrTypeOperator.INSTANCEOF, IrTypeOperator.NOT_INSTANCEOF -> {
@@ -876,7 +875,7 @@ class ExpressionCodegen(
?: throw AssertionError("Target label for break/continue not found") ?: throw AssertionError("Target label for break/continue not found")
mv.fixStackAndJump(if (jump is IrBreak) stackElement.breakLabel else stackElement.continueLabel) mv.fixStackAndJump(if (jump is IrBreak) stackElement.breakLabel else stackElement.continueLabel)
mv.mark(endLabel) mv.mark(endLabel)
return none() return StackValue.none()
} }
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: BlockInfo): StackValue { override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: BlockInfo): StackValue {
@@ -911,9 +910,9 @@ class ExpressionCodegen(
mv.nop() mv.nop()
val tryResult = aTry.tryResult.accept(this, data) val tryResult = aTry.tryResult.accept(this, data)
val isExpression = true //TODO: more wise check is required val isExpression = true //TODO: more wise check is required
var savedValue: Local? = null var savedValue: StackValue.Local? = null
if (isExpression) { if (isExpression) {
savedValue = local(frame.enterTemp(aTry.asmType), aTry.asmType) savedValue = StackValue.local(frame.enterTemp(aTry.asmType), aTry.asmType)
savedValue.store(tryResult.coerce(aTry.type), mv) savedValue.store(tryResult.coerce(aTry.type), mv)
} else { } else {
tryResult.discard() tryResult.discard()
@@ -989,9 +988,9 @@ class ExpressionCodegen(
if (savedValue != null) { if (savedValue != null) {
savedValue.put(mv) savedValue.put(mv)
frame.leaveTemp(aTry.asmType) frame.leaveTemp(aTry.asmType)
return onStack(aTry.asmType) return StackValue.onStack(aTry.asmType)
} }
return none() return StackValue.none()
} }
private fun genTryCatchCover(catchStart: Label, tryStart: Label, tryEnd: Label, tryGaps: List<Pair<Label, Label>>, type: String?) { private fun genTryCatchCover(catchStart: Label, tryStart: Label, tryEnd: Label, tryGaps: List<Pair<Label, Label>>, type: String?) {
@@ -1039,7 +1038,7 @@ class ExpressionCodegen(
expression.markLineNumber(startOffset = true) expression.markLineNumber(startOffset = true)
expression.value.accept(this, data).coerce(AsmTypes.JAVA_THROWABLE_TYPE).materialize() expression.value.accept(this, data).coerce(AsmTypes.JAVA_THROWABLE_TYPE).materialize()
mv.athrow() mv.athrow()
return none() return StackValue.none()
} }
override fun visitGetClass(expression: IrGetClass, data: BlockInfo): StackValue { override fun visitGetClass(expression: IrGetClass, data: BlockInfo): StackValue {