Provide dynamic operations currying for Algebra<T> instead of eager calls and add JS code generation support #162

Merged
CommanderTvis merged 44 commits from feature/dynamic-ops-currying into dev 2021-01-05 16:36:51 +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