[JS IR] Implement shared box intrinsics translator
This commit is contained in:
+17
@@ -218,6 +218,23 @@ class JsIntrinsicTransformers(backendContext: JsIrBackendContext) {
|
||||
add(intrinsics.unreachable) { _, _ ->
|
||||
JsInvocation(JsNameRef(Namer.UNREACHABLE_NAME))
|
||||
}
|
||||
|
||||
add(intrinsics.createSharedBox) { call, context: JsGenerationContext ->
|
||||
val arg = translateCallArguments(call, context).single()
|
||||
JsObjectLiteral(listOf(JsPropertyInitializer(JsNameRef(Namer.SHARED_BOX_V), arg)))
|
||||
}
|
||||
|
||||
add(intrinsics.readSharedBox) { call, context: JsGenerationContext ->
|
||||
val box = translateCallArguments(call, context).single()
|
||||
JsNameRef(Namer.SHARED_BOX_V, box)
|
||||
}
|
||||
|
||||
add(intrinsics.writeSharedBox) { call, context: JsGenerationContext ->
|
||||
val args = translateCallArguments(call, context)
|
||||
val box = args[0]
|
||||
val value = args[1]
|
||||
jsAssignment(JsNameRef(Namer.SHARED_BOX_V, box), value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.utils
|
||||
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsNameRef
|
||||
|
||||
object Namer {
|
||||
@@ -43,4 +42,6 @@ object Namer {
|
||||
val KPROPERTY_SET = "set"
|
||||
val KCALLABLE_CACHE_SUFFIX = "\$cache"
|
||||
const val KCALLABLE_ARITY = "\$arity"
|
||||
|
||||
const val SHARED_BOX_V = "_v"
|
||||
}
|
||||
Reference in New Issue
Block a user