JS: removed comma expression decomposition from InlineMetadata

There are used to be two inline tags (corresponding to start, end of inline function).
An expression like "startTag, function, endTag" was parsed into comma expression, then decomposed.
Now, it's just one tag at start, and parser can read function, then stop.
Thus, there is no need to decompose comma expressions.
This commit is contained in:
Alexey Tsvetkov
2015-03-13 15:48:49 +03:00
parent c7e8f52faf
commit 8be3628074
@@ -38,7 +38,6 @@ public class InlineMetadata(val tag: JsStringLiteral, val function: JsFunction)
platformStatic
fun decompose(expression: JsExpression?): InlineMetadata? =
when (expression) {
is JsBinaryOperation -> decomposeCommaExpression(expression)
is JsInvocation -> decomposeCreateFunctionCall(expression)
else -> null
}
@@ -46,33 +45,11 @@ public class InlineMetadata(val tag: JsStringLiteral, val function: JsFunction)
private fun decomposeCreateFunctionCall(call: JsInvocation): InlineMetadata? {
if (Namer.CREATE_INLINE_FUNCTION != call.getQualifier()) return null
return decomposePropertiesList(call.getArguments())
}
val arguments = call.getArguments()
if (arguments.size() != METADATA_PROPERTIES_COUNT) return null
private fun decomposeCommaExpression(expression: JsExpression): InlineMetadata? {
val properties = arrayListOf<JsExpression>()
var decomposable: JsExpression? = expression
while (decomposable is JsExpression) {
val binOp = decomposable as? JsBinaryOperation
if (JsBinaryOperator.COMMA == binOp?.getOperator()) {
properties.add(binOp?.getArg2())
decomposable = binOp?.getArg1()
} else {
properties.add(decomposable)
break
}
}
return decomposePropertiesList(properties.reverse())
}
private fun decomposePropertiesList(properties: List<JsExpression>): InlineMetadata? {
if (properties.size() != METADATA_PROPERTIES_COUNT) return null
val tag = properties[0] as? JsStringLiteral
val function = properties[1] as? JsFunction
val tag = arguments[0] as? JsStringLiteral
val function = arguments[1] as? JsFunction
if (tag == null || function == null) return null
return InlineMetadata(tag, function)