JS: generate temporary names for function parameters. Remove tests for js() function that references parameters. Remove such usages of js() function from stdlib

This commit is contained in:
Alexey Andreev
2016-12-09 13:35:25 +03:00
parent b634c2cbe3
commit 39de1a7659
13 changed files with 51 additions and 55 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ public class Enum<T : Enum<T>> : Comparable<Enum<T>> {
override fun equals(other: Any?) = this === other
override fun hashCode(): Int = js("Kotlin.identityHashCode(this)")
override fun hashCode(): Int = js("Kotlin.identityHashCode")(this)
override fun toString() = name
+3 -3
View File
@@ -18,7 +18,7 @@
internal abstract class BaseOutput {
@JsName("println")
open fun println(a: Any?) {
if (js("typeof a") !== "undefined") {
if (jsTypeOf(a) != "undefined") {
print(a)
}
print("\n")
@@ -43,7 +43,7 @@ internal class OutputToConsoleLog : BaseOutput() {
}
override fun println(a: Any?) {
console.log(if (js("typeof a") !== "undefined") a else "")
console.log(if (jsTypeOf(a) != "undefined") a else "")
}
}
@@ -85,4 +85,4 @@ internal var `out` = {
if (isNode) NodeJsOutput(js("process.stdout")) else BufferedOutputToConsoleLog()
}()
private inline fun String(value: Any?): String = js("String(value)")
private inline fun String(value: Any?): String = js("String")(value)
+1 -1
View File
@@ -32,7 +32,7 @@ public external fun js(code: String): dynamic = noImpl
/**
* Function corresponding to JavaScript's `typeof` operator
*/
public inline fun jsTypeOf(a: Any?): String = js("typeof a")
public inline fun jsTypeOf(a: Any?): String = js("Kotlin").jsTypeOf(a)
@library
internal fun deleteProperty(`object`: Any, property: Any): Unit = noImpl
+1 -1
View File
@@ -30,7 +30,7 @@ public operator fun dynamic.iterator(): Iterator<dynamic> {
return when {
this["iterator"] != null ->
this["iterator"]()
js("Array.isArray(r)") ->
js("Array").isArray(r) ->
r.unsafeCast<Array<*>>().iterator()
else ->