[JS IR] Style fixes
This commit is contained in:
committed by
Space Team
parent
9fd05632f0
commit
84b5af3c89
+4
-2
@@ -214,8 +214,10 @@ class IrElementToJsStatementTransformer : BaseIrElementToJsNodeTransformer<JsSta
|
||||
override fun visitWhileLoop(loop: IrWhileLoop, context: JsGenerationContext): JsStatement {
|
||||
//TODO what if body null?
|
||||
val label = context.getNameForLoop(loop)
|
||||
val loopStatement = JsWhile(loop.condition.accept(IrElementToJsExpressionTransformer(), context),
|
||||
loop.body?.accept(this, context) ?: JsEmpty)
|
||||
val loopStatement = JsWhile(
|
||||
loop.condition.accept(IrElementToJsExpressionTransformer(), context),
|
||||
loop.body?.accept(this, context) ?: JsEmpty
|
||||
)
|
||||
return label?.let { JsLabel(it, loopStatement) } ?: loopStatement
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ val IrFunctionAccessExpression.typeArguments: List<IrType?>
|
||||
|
||||
val IrFunctionAccessExpression.valueArguments: List<IrExpression?>
|
||||
get() = List(valueArgumentsCount) { getValueArgument(it) }
|
||||
|
||||
val IrClass.isInstantiableEnum: Boolean
|
||||
get() = isEnumClass && !isExpect && !isEffectivelyExternal()
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ internal class DoWhileGuardElimination(private val root: JsStatement) {
|
||||
|
||||
if (guard != null) {
|
||||
|
||||
// When do..while loop has no label and we encounter break guard from nested loop, we can't
|
||||
// When do..while loop has no label and we encounter `break guard` from nested loop, we can't
|
||||
// replace this break with continue. Example:
|
||||
//
|
||||
// do {
|
||||
|
||||
+8
-16
@@ -209,8 +209,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
try {
|
||||
localVars = mutableSetOf()
|
||||
return block()
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
currentScope -= localVars
|
||||
localVars = localVarsBackup
|
||||
}
|
||||
@@ -233,8 +232,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
if (assignment != null) {
|
||||
val (name, value) = assignment
|
||||
handleDefinition(name, value, x)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (handleExpression(expression)) {
|
||||
invalidateTemporaries()
|
||||
}
|
||||
@@ -256,8 +254,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
if (isTrivial(value)) {
|
||||
statementsToRemove += node
|
||||
namesToSubstitute += name
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lastAssignedVars += Pair(name, node)
|
||||
if (sideEffects) {
|
||||
namesWithSideEffects += name
|
||||
@@ -460,8 +457,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
substitutableVariableReferences += name
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.visitNameRef(nameRef)
|
||||
if (nameRef.sideEffects == SideEffectKind.AFFECTS_STATE) {
|
||||
sideEffectOccurred = true
|
||||
@@ -479,8 +475,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
if (qualifier != null) {
|
||||
accept(qualifier)
|
||||
}
|
||||
}
|
||||
else if (left is JsArrayAccess) {
|
||||
} else if (left is JsArrayAccess) {
|
||||
accept(left.arrayExpression)
|
||||
accept(left.indexExpression)
|
||||
}
|
||||
@@ -488,13 +483,11 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
|
||||
accept(right)
|
||||
sideEffectOccurred = true
|
||||
}
|
||||
else if (x.operator == JsBinaryOperator.AND || x.operator == JsBinaryOperator.OR) {
|
||||
} else if (x.operator == JsBinaryOperator.AND || x.operator == JsBinaryOperator.OR) {
|
||||
accept(x.arg1)
|
||||
sideEffectOccurred = true
|
||||
accept(x.arg2)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.visitBinaryExpression(x)
|
||||
}
|
||||
}
|
||||
@@ -518,8 +511,7 @@ internal class TemporaryVariableElimination(private val function: JsFunction) {
|
||||
for (initializer in initializers) {
|
||||
ctx.addPrevious(JsExpressionStatement(accept(initializer)).apply { synthetic = true })
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ctx.addPrevious(JsVars(*subList.toTypedArray()).apply { synthetic = true })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user