Dev #194

Merged
altavir merged 266 commits from dev into master 2021-01-20 17:32:32 +03:00
Showing only changes of commit 46ac73d2c1 - Show all commits

View File

@ -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