module GHC.Driver.Config.StgToJS
  ( initStgToJSConfig
  , initJSLinkConfig
  )
where

import GHC.StgToJS.Types
import GHC.StgToJS.Linker.Types

import GHC.Driver.DynFlags
import GHC.Driver.Config.Linker

import GHC.Platform.Ways
import GHC.Utils.Outputable

import GHC.Prelude

-- | Initialize StgToJS settings from DynFlags
initStgToJSConfig :: DynFlags -> StgToJSConfig
initStgToJSConfig :: DynFlags -> StgToJSConfig
initStgToJSConfig DynFlags
dflags = StgToJSConfig
  -- flags
  { csInlinePush :: Bool
csInlinePush      = Bool
False
  , csInlineBlackhole :: Bool
csInlineBlackhole = Bool
False
  , csInlineLoadRegs :: Bool
csInlineLoadRegs  = Bool
False
  , csInlineEnter :: Bool
csInlineEnter     = Bool
False
  , csInlineAlloc :: Bool
csInlineAlloc     = Bool
False
  , csPrettyRender :: Bool
csPrettyRender    = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_DisableJsMinifier DynFlags
dflags
  , csTraceRts :: Bool
csTraceRts        = Bool
False
  , csAssertRts :: Bool
csAssertRts       = Bool
False
  , csBoundsCheck :: Bool
csBoundsCheck     = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_DoBoundsChecking DynFlags
dflags
  , csDebugAlloc :: Bool
csDebugAlloc      = Bool
False
  , csTraceForeign :: Bool
csTraceForeign    = Bool
False
  , csProf :: Bool
csProf            = DynFlags -> Ways
ways DynFlags
dflags Ways -> Way -> Bool
`hasWay` Way
WayProf
  , csRuntimeAssert :: Bool
csRuntimeAssert   = Bool
False
  -- settings
  , csContext :: SDocContext
csContext         = DynFlags -> PprStyle -> SDocContext
initSDocContext DynFlags
dflags PprStyle
defaultDumpStyle
  , csLinkerConfig :: LinkerConfig
csLinkerConfig    = DynFlags -> LinkerConfig
initLinkerConfig DynFlags
dflags
  }

-- | Default linker configuration
initJSLinkConfig :: DynFlags -> JSLinkConfig
initJSLinkConfig :: DynFlags -> JSLinkConfig
initJSLinkConfig DynFlags
dflags = JSLinkConfig
  { lcNoJSExecutables :: Bool
lcNoJSExecutables = Bool
False
  , lcNoHsMain :: Bool
lcNoHsMain        = Bool
False
  , lcNoRts :: Bool
lcNoRts           = Bool
False
  , lcNoStats :: Bool
lcNoStats         = Bool
False
  , lcCombineAll :: Bool
lcCombineAll      = Bool
True
  , lcForeignRefs :: Bool
lcForeignRefs     = Bool
True
  , lcForceEmccRts :: Bool
lcForceEmccRts    = Bool
False
  , lcLinkCsources :: Bool
lcLinkCsources    = Bool -> Bool
not (GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_DisableJsCsources DynFlags
dflags)
  }