ghc-9.8.1: 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
LanguageHaskell2010

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

data ClosureInfo Source #

Information relevenat to code generation for closures.

Constructors

ClosureInfo 

Fields

Instances

Instances details
Show ClosureInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary ClosureInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

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

Defined in GHC.StgToJS.Types

Binary CIRegs Source # 
Instance details

Defined in GHC.StgToJS.Object

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

Defined in GHC.StgToJS.Types

Binary CILayout Source # 
Instance details

Defined in GHC.StgToJS.Object

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

Defined in GHC.StgToJS.Types

Binary CIType Source # 
Instance details

Defined in GHC.StgToJS.Object

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

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

Eq CIStatic Source # 
Instance details

Defined in GHC.StgToJS.Types

data VarType Source #

Free variable types

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

Defined in GHC.StgToJS.Types

Enum VarType Source # 
Instance details

Defined in GHC.StgToJS.Types

Show VarType Source # 
Instance details

Defined in GHC.StgToJS.Types

ToJExpr VarType Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary VarType Source # 
Instance details

Defined in GHC.StgToJS.Object

Eq VarType Source # 
Instance details

Defined in GHC.StgToJS.Types

Methods

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

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

Ord VarType Source # 
Instance details

Defined in GHC.StgToJS.Types

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$baseZCGHCziMaybeziJust_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$baseZCGHCziMaybeziJust_e() { var h$$baseZCGHCziMaybezieta_8KXnScrCjF5 = h$r2; h$r1 = h$c1(h$baseZCGHCziMaybeziJust_con_e, h$$baseZCGHCziMaybezieta_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 !Int !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
Show StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Object

Eq StaticInfo Source # 
Instance details

Defined in GHC.StgToJS.Types

data StaticVal Source #

Constructors

StaticFun !FastString [StaticArg]

heap object for function

StaticThunk !(Maybe (FastString, [StaticArg]))

heap object for CAF (field is Nothing when thunk is initialized in an alternative way, like string thunks through h$str)

StaticUnboxed !StaticUnboxed

unboxed constructor (Bool, Int, Double etc)

StaticData !FastString [StaticArg]

regular datacon app

StaticList [StaticArg] (Maybe FastString)

list initializer (with optional tail)

Instances

Instances details
Show StaticVal Source # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticVal Source # 
Instance details

Defined in GHC.StgToJS.Object

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

Defined in GHC.StgToJS.Types

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 #

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

Defined in GHC.StgToJS.Types

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 #

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

Defined in GHC.StgToJS.Types

Binary ExpFun Source # 
Instance details

Defined in GHC.StgToJS.Object

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 

Fields

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 JStat

primop is inline, result is assigned directly

PRPrimCall JStat

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

data ExprResult Source #

Constructors

ExprCont 
ExprInline (Maybe [JExpr]) 

Instances

Instances details
Eq ExprResult Source # 
Instance details

Defined in GHC.StgToJS.Types

newtype ExprValData Source #

Constructors

ExprValData [JExpr] 

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

Defined in GHC.StgToJS.Types

Enum ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

Show ClosureType Source # 
Instance details

Defined in GHC.StgToJS.Types

ToJExpr 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

Instances

Instances details
Bounded ThreadStatus Source # 
Instance details

Defined in GHC.StgToJS.Types

Enum ThreadStatus Source # 
Instance details

Defined in GHC.StgToJS.Types

Show ThreadStatus Source # 
Instance details

Defined in GHC.StgToJS.Types

Eq ThreadStatus Source # 
Instance details

Defined in GHC.StgToJS.Types

Ord ThreadStatus Source # 
Instance details

Defined in GHC.StgToJS.Types

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