ghc-9.10.1: The GHC API
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 HaskellNone
LanguageGHC2021

GHC.StgToJS.Object

Description

 
Synopsis

Documentation

data ObjectKind Source #

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) Source #

Get the kind of a file object, if any

getObjectKindBS :: ByteString -> Maybe ObjectKind Source #

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

JS object

data JSOptions Source #

Options obtained from pragmas in JS files

Constructors

JSOptions 

Fields

getOptionsFromJsFile Source #

Arguments

:: FilePath

Input file

-> IO JSOptions

Parsed options.

Parse option pragma in JS file

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

Write a JS object (embed some handwritten JS code)

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

Read a JS object from file

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

Read a JS object from BinHandle

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

Read a JS object from ByteString

HS object

putObject Source #

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.

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

Parse object body. Must be called after a successful getObjectHeader

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

Parse object

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

Read object from file

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

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

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

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

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

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

Reads only the part necessary to get the block info

isGlobalBlock :: BlockId -> Bool Source #

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 Source #

A HS object file

Constructors

Object 

Fields

data IndexEntry Source #

Constructors

IndexEntry 

Fields

Instances

Instances details
Binary IndexEntry Source # 
Instance details

Defined in GHC.StgToJS.Object

data LocatedBlockInfo Source #

Constructors

LocatedBlockInfo 

Fields

data BlockInfo Source #

Information about blocks (linkable units)

Constructors

BlockInfo 

Fields

Instances

Instances details
Binary BlockInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

Outputable BlockInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

Methods

ppr :: BlockInfo -> SDoc Source #

data BlockDeps Source #

Constructors

BlockDeps 

Fields

Instances

Instances details
Binary BlockDeps Source # 
Instance details

Defined in GHC.StgToJS.Object

data BlockLocation Source #

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

Defined in GHC.StgToJS.Object

data BlockRef Source #

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

Defined in GHC.StgToJS.Object

Ord BlockRef Source # 
Instance details

Defined in GHC.StgToJS.Object

data ExportedFun Source #

Exported Functions

Constructors

ExportedFun 

Fields

Orphan instances

Binary Ident Source # 
Instance details

Binary AOp Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO AOp Source #

Binary JExpr Source # 
Instance details

Binary JStat Source # 
Instance details

Binary JVal Source # 
Instance details

Binary Op Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO Op Source #

Binary UOp Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO UOp Source #

Binary CILayout Source # 
Instance details

Binary CIRegs Source # 
Instance details

Binary CIStatic Source # 
Instance details

Binary CIType Source # 
Instance details

Binary ClosureInfo Source # 
Instance details

Binary ExpFun Source # 
Instance details

Binary ForeignJSRef Source # 
Instance details

Binary JSFFIType Source # 
Instance details

Binary JSRep Source # 
Instance details

Binary StaticArg Source # 
Instance details

Binary StaticInfo Source # 
Instance details

Binary StaticLit Source # 
Instance details

Binary StaticUnboxed Source # 
Instance details

Binary StaticVal Source # 
Instance details