Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io> |
Stability | experimental Module to deal with JS identifiers |
Safe Haskell | None |
Language | GHC2021 |
Synopsis
- freshUnique :: G Int
- freshIdent :: G Ident
- makeIdentForId :: Id -> Maybe Int -> IdType -> Module -> Ident
- cachedIdentForId :: Id -> Maybe Int -> IdType -> G Ident
- identForId :: Id -> G Ident
- identForIdN :: Id -> Int -> G Ident
- identsForId :: Id -> G [Ident]
- identForEntryId :: Id -> G Ident
- identForDataConEntryId :: Id -> G Ident
- identForDataConWorker :: DataCon -> G Ident
- varForId :: Id -> G JStgExpr
- varForIdN :: Id -> Int -> G JStgExpr
- varsForId :: Id -> G [JStgExpr]
- varForEntryId :: Id -> G JStgExpr
- varForDataConEntryId :: Id -> G JStgExpr
- varForDataConWorker :: DataCon -> G JStgExpr
- declVarsForId :: Id -> G JStgStat
Documentation
freshUnique :: G Int Source #
Get fresh unique number
freshIdent :: G Ident Source #
Get fresh module-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
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.
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
varForIdN :: Id -> Int -> G JStgExpr Source #
Retrieve default variable name for the given Id with sub index
varForDataConEntryId :: Id -> G JStgExpr Source #
Retrieve datacon entry variable name for the given Id