Add undefined handling in constant insertion
This commit is contained in:
parent
d657f40e3f
commit
46ac73d2c1
@ -40,9 +40,10 @@ internal class ESTreeBuilder<T>(val bodyCallback: ESTreeBuilder<T>.() -> BaseExp
|
|||||||
private val keys = mutableListOf<String>()
|
private val keys = mutableListOf<String>()
|
||||||
|
|
||||||
fun constant(value: Any?) = when {
|
fun constant(value: Any?) = when {
|
||||||
value == null || jsTypeOf(value) == "number" || jsTypeOf(value) == "string" || jsTypeOf(value) == "boolean" -> {
|
value == null || jsTypeOf(value) == "number" || jsTypeOf(value) == "string" || jsTypeOf(value) == "boolean" ->
|
||||||
SimpleLiteral(value)
|
SimpleLiteral(value)
|
||||||
}
|
|
||||||
|
jsType(value) == "undefined" -> Identifier("undefined")
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val idx = if (value in constants) constants.indexOf(value) else constants.also { it += value }.lastIndex
|
val idx = if (value in constants) constants.indexOf(value) else constants.also { it += value }.lastIndex
|
||||||
|
Loading…
Reference in New Issue
Block a user