JS: fix tests that don't fail due to lack of support of strict mode (multiValInIntFor, multiValInIntRangeFor).
This commit is contained in:
+5
-16
@@ -102,12 +102,12 @@ fun translateForExpression(expression: KtForExpression, context: TranslationCont
|
|||||||
val destructuringParameter: KtDestructuringDeclaration? = expression.destructuringParameter
|
val destructuringParameter: KtDestructuringDeclaration? = expression.destructuringParameter
|
||||||
|
|
||||||
val loopParameter = getLoopParameter(expression)
|
val loopParameter = getLoopParameter(expression)
|
||||||
val (parameterName, parameterIsTemporary) = if (loopParameter != null) {
|
val parameterName = if (loopParameter != null) {
|
||||||
Pair(context.getNameForElement(loopParameter), false)
|
context.getNameForElement(loopParameter)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(destructuringParameter != null) { "If loopParameter is null, multi parameter must be not null ${expression.text}" }
|
assert(destructuringParameter != null) { "If loopParameter is null, multi parameter must be not null ${expression.text}" }
|
||||||
Pair(context.scope().declareTemporary(), true)
|
context.scope().declareTemporary()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun translateBody(itemValue: JsExpression?): JsStatement? {
|
fun translateBody(itemValue: JsExpression?): JsStatement? {
|
||||||
@@ -149,12 +149,7 @@ fun translateForExpression(expression: KtForExpression, context: TranslationCont
|
|||||||
val conditionExpression = lessThanEq(parameterName.makeRef(), rangeEnd)
|
val conditionExpression = lessThanEq(parameterName.makeRef(), rangeEnd)
|
||||||
val incrementExpression = JsPostfixOperation(JsUnaryOperator.INC, parameterName.makeRef())
|
val incrementExpression = JsPostfixOperation(JsUnaryOperator.INC, parameterName.makeRef())
|
||||||
|
|
||||||
return if (parameterIsTemporary) {
|
return JsFor(newVar(parameterName, rangeStart), conditionExpression, incrementExpression, body)
|
||||||
JsFor(assignment(parameterName.makeRef(), rangeStart), conditionExpression, incrementExpression, body)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JsFor(newVar(parameterName, rangeStart), conditionExpression, incrementExpression, body)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun translateForOverRange(): JsStatement {
|
fun translateForOverRange(): JsStatement {
|
||||||
@@ -171,13 +166,7 @@ fun translateForExpression(expression: KtForExpression, context: TranslationCont
|
|||||||
val conditionExpression = lessThanEq(parameterName.makeRef(), end)
|
val conditionExpression = lessThanEq(parameterName.makeRef(), end)
|
||||||
val incrementExpression = addAssign(parameterName.makeRef(), increment)
|
val incrementExpression = addAssign(parameterName.makeRef(), increment)
|
||||||
|
|
||||||
|
return JsFor(newVar(parameterName, start), conditionExpression, incrementExpression, body)
|
||||||
return if (parameterIsTemporary) {
|
|
||||||
JsFor(assignment(parameterName.makeRef(), start), conditionExpression, incrementExpression, body)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
JsFor(newVar(parameterName, start), conditionExpression, incrementExpression, body)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun translateForOverArray(): JsStatement {
|
fun translateForOverArray(): JsStatement {
|
||||||
|
|||||||
Reference in New Issue
Block a user