ghc-9.8.0.20230929: The GHC API
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file LICENSE)
MaintainerJeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stabilityexperimental Module to deal with JS identifiers
Safe HaskellNone
LanguageHaskell2010

GHC.StgToJS.Ids

Description

 
Synopsis

Documentation

freshUnique :: G Int Source #

Get fresh unique number

freshIdent :: G Ident Source #

Get fresh local Ident of the form: h$$unit:module_uniq

makeIdentForId :: Id -> Maybe Int -> IdType -> Module -> Ident Source #

Generate unique Ident for the given ID (uncached!)

The ident has the following forms:

global Id: h$unit:module.name[_num][_type_suffix] local Id: h$$unit:module.name[_num][_type_suffix]_uniq

Note that the string is z-encoded except for "_" delimiters.

Optional "_type_suffix" can be: - "_e" for IdEntry - "_con_e" for IdConEntry

Optional "_num" is passed as an argument to this function. It is used for Haskell Ids that require several JS variables: e.g. 64-bit numbers (Word64#, Int64#), Addr#, StablePtr#, unboxed tuples, etc.

cachedIdentForId :: Id -> Maybe Int -> IdType -> G Ident Source #

Retrieve the cached Ident for the given Id if there is one. Otherwise make a new one with makeIdentForId and cache it.

Helpers for Idents

identForId :: Id -> G Ident Source #

Retrieve default Ident for the given Id

identForIdN :: Id -> Int -> G Ident Source #

Retrieve default Ident for the given Id with sub index

Some types, Word64, Addr#, unboxed tuple have more than one corresponding JS var, hence we use the sub index to identify each subpart / JS variable.

identsForId :: Id -> G [Ident] Source #

Retrieve all the idents for the given Id.

identForEntryId :: Id -> G Ident Source #

Retrieve entry Ident for the given Id

identForDataConEntryId :: Id -> G Ident Source #

Retrieve datacon entry Ident for the given Id

Different name than the datacon wrapper.

identForDataConWorker :: DataCon -> G Ident Source #

Retrieve datacon worker entry variable name for the given datacon

Helpers for variables

varForId :: Id -> G JExpr Source #

Retrieve default variable name for the given Id

varForIdN :: Id -> Int -> G JExpr Source #

Retrieve default variable name for the given Id with sub index

varsForId :: Id -> G [JExpr] Source #

Retrieve all the JS vars for the given Id

varForEntryId :: Id -> G JExpr Source #

Retrieve entry variable name for the given Id

varForDataConEntryId :: Id -> G JExpr Source #

Retrieve datacon entry variable name for the given Id

varForDataConWorker :: DataCon -> G JExpr Source #

Retrieve datacon worker entry variable name for the given datacon

declVarsForId :: Id -> G JStat Source #

Declare all js vars for the id