ghc-lib-parser-9.8.1.20231009: The GHC API, decoupled from GHC versions
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file LICENSE)
MaintainerSylvain Henry <sylvain.henry@iohk.io> Jeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stabilityexperimental Serialization/deserialization of binary .o files for the JavaScript backend The .o files contain dependency information and generated code. All strings are mapped to a central string table, which helps reduce file size and gives us efficient hash consing on read Binary intermediate JavaScript object files: serialized [Text] -> ([ClosureInfo], JStat) blocks file layout: - magic "GHCJSOBJ" - compiler version tag - module name - offsets of string table - dependencies - offset of the index - unit infos - index - string table
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.StgToJS.Object

Description

 
Synopsis

Documentation

putObject #

Arguments

:: BinHandle 
-> ModuleName

module

-> BlockInfo

block infos

-> [ObjBlock]

linkable units and their symbols

-> IO () 

Given a handle to a Binary payload, add the module, mod_name, its dependencies, deps, and its linkable units to the payload.

getObjectHeader :: BinHandle -> IO (Either String ModuleName) #

Parse object header

getObjectBody :: BinHandle -> ModuleName -> IO Object #

Parse object body. Must be called after a sucessful getObjectHeader

getObject :: BinHandle -> IO (Maybe Object) #

Parse object

readObject :: FilePath -> IO (Maybe Object) #

Read object from file

The object is still in memory after this (see objHandle).

getObjectBlocks :: Object -> BlockIds -> IO [ObjBlock] #

Get blocks in the object file, using the given filtering function

readObjectBlocks :: FilePath -> BlockIds -> IO [ObjBlock] #

Read blocks in the object file, using the given filtering function

readObjectBlockInfo :: FilePath -> IO (Maybe BlockInfo) #

Reads only the part necessary to get the block info

isGlobalBlock :: BlockId -> Bool #

we use the convention that the first block (0) is a module-global block that's always included when something from the module is loaded. everything in a module implicitly depends on the global block. The global block itself can't have dependencies

isJsObjectFile :: FilePath -> IO Bool #

Test if the object file is a JS object

data Object #

An object file

Constructors

Object 

Fields

data IndexEntry #

Constructors

IndexEntry 

Fields

Instances

Instances details
Binary IndexEntry # 
Instance details

Defined in GHC.StgToJS.Object

data LocatedBlockInfo #

Constructors

LocatedBlockInfo 

Fields

data BlockInfo #

Information about blocks (linkable units)

Constructors

BlockInfo 

Fields

Instances

Instances details
Binary BlockInfo # 
Instance details

Defined in GHC.StgToJS.Object

Outputable BlockInfo # 
Instance details

Defined in GHC.StgToJS.Object

Methods

ppr :: BlockInfo -> SDoc #

data BlockDeps #

Constructors

BlockDeps 

Fields

Instances

Instances details
Binary BlockDeps # 
Instance details

Defined in GHC.StgToJS.Object

data BlockLocation #

Where are the blocks

Constructors

ObjectFile FilePath

In an object file at path

ArchiveFile FilePath

In a Ar file at path

InMemory String Object

In memory

Instances

Instances details
Outputable BlockLocation # 
Instance details

Defined in GHC.StgToJS.Object

Methods

ppr :: BlockLocation -> SDoc #

type BlockId = Int #

type BlockIds = IntSet #

data BlockRef #

A BlockRef is a pair of a module and the index of the block in the object file

Constructors

BlockRef 

Fields

Instances

Instances details
Eq BlockRef # 
Instance details

Defined in GHC.StgToJS.Object

Ord BlockRef # 
Instance details

Defined in GHC.StgToJS.Object

data ExportedFun #

Exported Functions

Constructors

ExportedFun 

Fields

Orphan instances

Binary AOp # 
Instance details

Methods

put_ :: BinHandle -> AOp -> IO () #

put :: BinHandle -> AOp -> IO (Bin AOp) #

get :: BinHandle -> IO AOp #

Binary JExpr # 
Instance details

Methods

put_ :: BinHandle -> JExpr -> IO () #

put :: BinHandle -> JExpr -> IO (Bin JExpr) #

get :: BinHandle -> IO JExpr #

Binary JStat # 
Instance details

Methods

put_ :: BinHandle -> JStat -> IO () #

put :: BinHandle -> JStat -> IO (Bin JStat) #

get :: BinHandle -> IO JStat #

Binary JVal # 
Instance details

Methods

put_ :: BinHandle -> JVal -> IO () #

put :: BinHandle -> JVal -> IO (Bin JVal) #

get :: BinHandle -> IO JVal #

Binary Op # 
Instance details

Methods

put_ :: BinHandle -> Op -> IO () #

put :: BinHandle -> Op -> IO (Bin Op) #

get :: BinHandle -> IO Op #

Binary UOp # 
Instance details

Methods

put_ :: BinHandle -> UOp -> IO () #

put :: BinHandle -> UOp -> IO (Bin UOp) #

get :: BinHandle -> IO UOp #

Binary Ident # 
Instance details

Methods

put_ :: BinHandle -> Ident -> IO () #

put :: BinHandle -> Ident -> IO (Bin Ident) #

get :: BinHandle -> IO Ident #

Binary CILayout # 
Instance details

Binary CIRegs # 
Instance details

Methods

put_ :: BinHandle -> CIRegs -> IO () #

put :: BinHandle -> CIRegs -> IO (Bin CIRegs) #

get :: BinHandle -> IO CIRegs #

Binary CIStatic # 
Instance details

Binary CIType # 
Instance details

Methods

put_ :: BinHandle -> CIType -> IO () #

put :: BinHandle -> CIType -> IO (Bin CIType) #

get :: BinHandle -> IO CIType #

Binary ClosureInfo # 
Instance details

Binary ExpFun # 
Instance details

Methods

put_ :: BinHandle -> ExpFun -> IO () #

put :: BinHandle -> ExpFun -> IO (Bin ExpFun) #

get :: BinHandle -> IO ExpFun #

Binary ForeignJSRef # 
Instance details

Binary JSFFIType # 
Instance details

Binary StaticArg # 
Instance details

Binary StaticInfo # 
Instance details

Binary StaticLit # 
Instance details

Binary StaticUnboxed # 
Instance details

Binary StaticVal # 
Instance details

Binary VarType # 
Instance details