From 8771a53bb3953fc1a23be097d2a681840e4ed1cd Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Mon, 23 Oct 2023 09:49:36 +0000 Subject: [PATCH] compiler: allow boxed JSVal as a foreign type This commit allows the boxed JSVal type to be used as a foreign argument/result type. --- compiler/GHC/Builtin/Names.hs | 8 +++++++- compiler/GHC/Tc/Gen/Foreign.hs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/GHC/Builtin/Names.hs b/compiler/GHC/Builtin/Names.hs index 3b91196d7afa..b45ae319cfce 100644 --- a/compiler/GHC/Builtin/Names.hs +++ b/compiler/GHC/Builtin/Names.hs @@ -358,6 +358,7 @@ basicKnownKeyNames stablePtrTyConName, ptrTyConName, funPtrTyConName, constPtrConName, int8TyConName, int16TyConName, int32TyConName, int64TyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName, + jsvalTyConName, -- Others otherwiseIdName, inlineIdName, @@ -1659,6 +1660,9 @@ constPtrConName :: Name constPtrConName = tcQual fOREIGN_C_CONSTPTR (fsLit "ConstPtr") constPtrTyConKey +jsvalTyConName :: Name +jsvalTyConName = tcQual (mkGhcInternalModule (fsLit "GHC.Wasm.Prim.Types")) (fsLit "JSVal") jsvalTyConKey + {- ************************************************************************ * * @@ -1863,7 +1867,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, compactPrimTyConKey, stackSnapshotPrimTyConKey, - promptTagPrimTyConKey, constPtrTyConKey :: Unique + promptTagPrimTyConKey, constPtrTyConKey, jsvalTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -2080,6 +2084,8 @@ typeCharToNatTyFamNameKey = mkPreludeTyConUnique 415 typeNatToCharTyFamNameKey = mkPreludeTyConUnique 416 constPtrTyConKey = mkPreludeTyConUnique 417 +jsvalTyConKey = mkPreludeTyConUnique 418 + {- ************************************************************************ * * diff --git a/compiler/GHC/Tc/Gen/Foreign.hs b/compiler/GHC/Tc/Gen/Foreign.hs index 84b48b4d2d7c..3d41a5af4592 100644 --- a/compiler/GHC/Tc/Gen/Foreign.hs +++ b/compiler/GHC/Tc/Gen/Foreign.hs @@ -753,6 +753,7 @@ boxedMarshalableTyCon tc , charTyConKey , stablePtrTyConKey , boolTyConKey + , jsvalTyConKey ] = IsValid @@ -794,4 +795,4 @@ In turn that means you can't write Reason: the back end falls over with panic "primRepHint:VoidRep"; and there is no compelling reason to permit it --} \ No newline at end of file +-} -- GitLab