[JS IR BE] Add compiler instrinsic to express undefined value in BE
This commit is contained in:
@@ -308,6 +308,8 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
val readSharedBox = defineReadSharedBox()
|
val readSharedBox = defineReadSharedBox()
|
||||||
val writeSharedBox = defineWriteSharedBox()
|
val writeSharedBox = defineWriteSharedBox()
|
||||||
|
|
||||||
|
val jsUndefined = defineJsUndefinedIntrinsic()
|
||||||
|
|
||||||
// Helpers:
|
// Helpers:
|
||||||
|
|
||||||
private fun getInternalFunction(name: String) =
|
private fun getInternalFunction(name: String) =
|
||||||
@@ -401,6 +403,14 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun defineJsUndefinedIntrinsic(): IrSimpleFunction {
|
||||||
|
return irFactory.addFunction(externalPackageFragment) {
|
||||||
|
name = Name.identifier("\$undefined")
|
||||||
|
}.apply {
|
||||||
|
returnType = context.irBuiltIns.nothingNType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun defineEs6DefaultTypeIntrinsic(): IrSimpleFunction {
|
private fun defineEs6DefaultTypeIntrinsic(): IrSimpleFunction {
|
||||||
return irFactory.addFunction(externalPackageFragment) {
|
return irFactory.addFunction(externalPackageFragment) {
|
||||||
name = Name.identifier("DefaultType")
|
name = Name.identifier("DefaultType")
|
||||||
|
|||||||
+3
@@ -235,6 +235,9 @@ class JsIntrinsicTransformers(backendContext: JsIrBackendContext) {
|
|||||||
val value = args[1]
|
val value = args[1]
|
||||||
jsAssignment(JsNameRef(Namer.SHARED_BOX_V, box), value)
|
jsAssignment(JsNameRef(Namer.SHARED_BOX_V, box), value)
|
||||||
}
|
}
|
||||||
|
add(intrinsics.jsUndefined) { call: IrCall, context: JsGenerationContext ->
|
||||||
|
JsPrefixOperation(JsUnaryOperator.VOID, JsIntLiteral(1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user