ghc-lib-parser-9.10.1.20250103: 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
Safe HaskellIgnore
LanguageGHC2021

GHC.StgToJS.Object

Description

 
Synopsis

Documentation

data ObjectKind #

Different kinds of object (.o) supported by the JS backend

Constructors

ObjJs

JavaScript source embedded in a .o

ObjHs

JS backend object for Haskell code

ObjCc

Wasm module object as produced by emcc

getObjectKind :: FilePath -> IO (Maybe ObjectKind) #

Get the kind of a file object, if any

getObjectKindBS :: ByteString -> Maybe ObjectKind #

Get the kind of an object stored in a bytestring, if any

JS object

data JSOptions #

Options obtained from pragmas in JS files

Constructors

JSOptions 

Fields

Instances

Instances details
Semigroup JSOptions # 
Instance details

Defined in GHC.StgToJS.Object

Binary JSOptions # 
Instance details

Defined in GHC.StgToJS.Object

Eq JSOptions # 
Instance details

Defined in GHC.StgToJS.Object

Ord JSOptions # 
Instance details

Defined in GHC.StgToJS.Object

getOptionsFromJsFile #

Arguments

:: FilePath

Input file

-> IO JSOptions

Parsed options.

Parse option pragma in JS file

writeJSObject :: JSOptions -> ByteString -> FilePath -> IO () #

Write a JS object (embed some handwritten JS code)

readJSObject :: FilePath -> IO (JSOptions, ByteString) #

Read a JS object from file

parseJSObject :: BinHandle -> IO (JSOptions, ByteString) #

Read a JS object from BinHandle

parseJSObjectBS :: ByteString -> IO (JSOptions, ByteString) #

Read a JS object from ByteString

HS object

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 successful 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

data Object #

A HS 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 #

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 Ident # 
Instance details

Methods

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

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

get :: BinHandle -> IO Ident #

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 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 JSRep # 
Instance details

Methods

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

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

get :: BinHandle -> IO JSRep #

Binary StaticArg # 
Instance details

Binary StaticInfo # 
Instance details

Binary StaticLit # 
Instance details

Binary StaticUnboxed # 
Instance details

Binary StaticVal # 
Instance details