ghc-9.13: 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
Safe HaskellNone
LanguageGHC2021

GHC.StgToJS.Types

Description

Module that holds the Types required for the StgToJS pass

Synopsis

Documentation

type G = StateT GenState IO Source #

A State monad over IO holding the generator state.

data GenState Source #

The JS code generator state

Constructors

GenState 

Fields

data GenGroupState Source #

The JS code generator state relevant for the current binding group

Constructors

GenGroupState 

Fields

data StgToJSConfig Source #

The Configuration record for the StgToJS pass

Constructors

StgToJSConfig 

data ClosureInfo Source #

Closure info table

Constructors

ClosureInfo 

Fields

Instances

Instances details
Binary ClosureInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

Show ClosureInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq ClosureInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

data CIRegs Source #

Closure information, ClosureInfo, registers

Constructors

CIRegsUnknown

A value witnessing a state of unknown registers

CIRegs 

Fields

Instances

Instances details
Binary CIRegs Source # 
Instance details

Defined in GHC.StgToJS.Object

Show CIRegs Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq CIRegs Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: CIRegs -> CIRegs -> Bool #

(/=) :: CIRegs -> CIRegs -> Bool #

Ord CIRegs Source # 
Instance details

Defined in GHC.StgToJS.Types

data CILayout Source #

Closure Information, ClosureInfo, layout

Constructors

CILayoutVariable

layout stored in object itself, first position from the start

CILayoutUnknown

fixed size, but content unknown (for example stack apply frame)

Fields

  • layoutSize :: !Int

    closure size in array positions, including entry

CILayoutFixed

whole layout known

Fields

Instances

Instances details
Binary CILayout Source # 
Instance details

Defined in GHC.StgToJS.Object

Show CILayout Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq CILayout Source # 
Instance details

Defined in GHC.StgToJS.Types

Ord CILayout Source # 
Instance details

Defined in GHC.StgToJS.Types

data CIType Source #

The type of ClosureInfo

Constructors

CIFun 

Fields

CIThunk

The closure is a THUNK

CICon

The closure is a Constructor

Fields

CIPap

The closure is a Partial Application

CIBlackhole

The closure is a black hole

CIStackFrame

The closure is a stack frame

Instances

Instances details
Binary CIType Source # 
Instance details

Defined in GHC.StgToJS.Object

Show CIType Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq CIType Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: CIType -> CIType -> Bool #

(/=) :: CIType -> CIType -> Bool #

Ord CIType Source # 
Instance details

Defined in GHC.StgToJS.Types

newtype CIStatic Source #

Static references that must be kept alive

Constructors

CIStaticRefs 

Fields

Instances

Instances details
ToJExpr CIStatic Source #

static refs: array = references, null = nothing to report note: only works after all top-level objects have been created

Instance details

Defined in GHC.StgToJS.Types

Binary CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Object

Monoid CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Types

Semigroup CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Types

Show CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Types

data JSRep Source #

JS primitive representations

Constructors

PtrV

pointer = reference to heap object (closure object), lifted or not. Can also be some RTS object (e.g. TVar#, MVar#, MutVar#, Weak#)

VoidV

no fields

DoubleV

A Double: one field

IntV

An Int (32bit because JS): one field

LongV

A Long: two fields one for the upper 32bits, one for the lower (NB: JS is little endian)

AddrV

a pointer not to the heap: two fields, array + index

ObjV

some JS object, user supplied, be careful around these, can be anything

ArrV

boxed array

Instances

Instances details
ToJExpr JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary JSRep Source # 
Instance details

Defined in GHC.StgToJS.Object

Bounded JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Enum JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Show JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

showsPrec :: Int -> JSRep -> ShowS #

show :: JSRep -> String #

showList :: [JSRep] -> ShowS #

Eq JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: JSRep -> JSRep -> Bool #

(/=) :: JSRep -> JSRep -> Bool #

Ord JSRep Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

compare :: JSRep -> JSRep -> Ordering #

(<) :: JSRep -> JSRep -> Bool #

(<=) :: JSRep -> JSRep -> Bool #

(>) :: JSRep -> JSRep -> Bool #

(>=) :: JSRep -> JSRep -> Bool #

max :: JSRep -> JSRep -> JSRep #

min :: JSRep -> JSRep -> JSRep #

data IdType Source #

The type of identifiers. These determine the suffix of generated functions in JS Land. For example, the entry function for the Just constructor is a IdConEntry which compiles to: function h$ghczminternalZCGHCziInternalziMaybeziJust_con_e() { return h$rs() }; which just returns whatever the stack point is pointing to. Whereas the entry function to Just is an IdEntry and does the work. It compiles to: function h$ghczminternalZCGHCziInternalziMaybeziJust_e() { var h$$baseZCGHCziMaybezieta_8KXnScrCjF5 = h$r2; h$r1 = h$c1(h$ghczminternalZCGHCziInternalziMaybeziJust_con_e, h$$ghczminternalZCGHCziInternalziMaybezieta_8KXnScrCjF5); return h$rs(); }; Which loads some payload from register 2, and applies the Constructor Entry function for the Just to the payload, returns the result in register 1 and returns whatever is on top of the stack

Constructors

IdPlain

A plain identifier for values, no suffix added

IdEntry

An entry function, suffix = "_e" in makeIdentForId

IdConEntry

A Constructor entry function, suffix = "_con_e" in makeIdentForId

Instances

Instances details
Enum IdType Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq IdType Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: IdType -> IdType -> Bool #

(/=) :: IdType -> IdType -> Bool #

Ord IdType Source # 
Instance details

Defined in GHC.StgToJS.Types

data IdKey Source #

Keys to differentiate Ident's in the ID Cache

Constructors

IdKey !Word64 !Int !IdType 

Instances

Instances details
Eq IdKey Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: IdKey -> IdKey -> Bool #

(/=) :: IdKey -> IdKey -> Bool #

Ord IdKey Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

compare :: IdKey -> IdKey -> Ordering #

(<) :: IdKey -> IdKey -> Bool #

(<=) :: IdKey -> IdKey -> Bool #

(>) :: IdKey -> IdKey -> Bool #

(>=) :: IdKey -> IdKey -> Bool #

max :: IdKey -> IdKey -> IdKey #

min :: IdKey -> IdKey -> IdKey #

data OtherSymb Source #

Some other symbol

Constructors

OtherSymb !Module !FastString 

Instances

Instances details
Eq OtherSymb Source # 
Instance details

Defined in GHC.StgToJS.Types

Ord OtherSymb Source # 
Instance details

Defined in GHC.StgToJS.Types

newtype IdCache Source #

The identifier cache indexed on IdKey local to a module

Constructors

IdCache (Map IdKey Ident) 

newtype GlobalIdCache Source #

The global Identifier Cache

Constructors

GlobalIdCache (UniqFM Ident (IdKey, Id)) 

data StackSlot Source #

A Stack Slot is either known or unknown. We avoid maybe here for more strictness.

Constructors

SlotId !Id !Int 
SlotUnknown 

Instances

Instances details
Eq StackSlot Source # 
Instance details

Defined in GHC.StgToJS.Types

Ord StackSlot Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticInfo Source #

Constructors

StaticInfo 

Fields

Instances

Instances details
Binary StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

Show StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticAppKind Source #

Constructors

SAKFun

heap object for function

SAKThunk

heap object for CAF

SAKData

regular datacon app

Instances

Instances details
Show StaticAppKind Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq StaticAppKind Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticVal Source #

Constructors

StaticUnboxed !StaticUnboxed

unboxed constructor (Bool, Int, Double etc)

StaticList [StaticArg] (Maybe FastString)

list initializer (with optional tail)

StaticApp StaticAppKind !FastString [StaticArg]

static application of static args. Can be a CAF, a FUN, or a CON app.

Instances

Instances details
Binary StaticVal Source # 
Instance details

Defined in GHC.StgToJS.Object

Show StaticVal Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq StaticVal Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticArg Source #

Static Arguments. Static Arguments are things that are statically allocated, i.e., they exist at program startup. These are static heap objects or literals or things that have been floated to the top level binding by ghc.

Constructors

StaticObjArg !FastString

reference to a heap object

StaticLitArg !StaticLit

literal

StaticConArg !FastString [StaticArg]

unfloated constructor

Instances

Instances details
Binary StaticArg Source # 
Instance details

Defined in GHC.StgToJS.Object

Outputable StaticArg Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: StaticArg -> SDoc Source #

Show StaticArg Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq StaticArg Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticLit Source #

A Static literal value

Constructors

BoolLit !Bool 
IntLit !Integer 
NullLit 
DoubleLit !SaneDouble 
StringLit !FastString 
BinLit !ByteString 
LabelLit !Bool !FastString

is function pointer, label (also used for string / binary init)

Instances

Instances details
ToJExpr StaticLit Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticLit Source # 
Instance details

Defined in GHC.StgToJS.Object

Outputable StaticLit Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: StaticLit -> SDoc Source #

Show StaticLit Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq StaticLit Source # 
Instance details

Defined in GHC.StgToJS.Types

data LinkableUnit Source #

data used to generate one ObjBlock in our object file

Constructors

LinkableUnit 

Fields

data ObjBlock Source #

one toplevel block in the object file

Constructors

ObjBlock 

Fields

data ExpFun Source #

Constructors

ExpFun 

Fields

Instances

Instances details
Binary ExpFun Source # 
Instance details

Defined in GHC.StgToJS.Object

Show ExpFun Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq ExpFun Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: ExpFun -> ExpFun -> Bool #

(/=) :: ExpFun -> ExpFun -> Bool #

Ord ExpFun Source # 
Instance details

Defined in GHC.StgToJS.Types

data JSFFIType Source #

Types of FFI values

data TypedExpr Source #

Typed expression

Constructors

TypedExpr 

Instances

Instances details
Outputable TypedExpr Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: TypedExpr -> SDoc Source #

data PrimRes Source #

A Primop result is either an inlining of some JS payload, or a primitive call to a JS function defined in Shim files in base.

Constructors

PrimInline JStgStat

primop is inline, result is assigned directly

PRPrimCall JStgStat

primop is async call, primop returns the next function to run. result returned to stack top in registers

data ExprResult Source #

Constructors

ExprCont 
ExprInline 

Instances

Instances details
Eq ExprResult Source # 
Instance details

Defined in GHC.StgToJS.Types

newtype ExprValData Source #

Constructors

ExprValData [JStgExpr] 

Instances

Instances details
Eq ExprValData Source # 
Instance details

Defined in GHC.StgToJS.Types

data ClosureType Source #

A Closure is one of six types

Constructors

Thunk

The closure is a THUNK

Fun

The closure is a Function

Pap

The closure is a Partial Application

Con

The closure is a Constructor

Blackhole

The closure is a Blackhole

StackFrame

The closure is a stack frame

Instances

Instances details
ToJExpr ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Bounded ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Enum ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Ix ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Show ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Ord ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

ctNum :: ClosureType -> Int Source #

Convert ClosureType to an Int

ctJsName :: ClosureType -> String Source #

Convert ClosureType to a String

data ThreadStatus Source #

A thread is in one of 4 states

Constructors

Running

The thread is running

Blocked

The thread is blocked

Finished

The thread is done

Died

The thread has died

threadStatusNum :: ThreadStatus -> Int Source #

Convert the status of a thread in JS land to an Int

threadStatusJsName :: ThreadStatus -> String Source #

convert the status of a thread in JS land to a string