diff options
author | doyougnu <jeffrey.young@iohk.io> | 2022-03-04 10:32:56 -0500 |
---|---|---|
committer | doyougnu <jeffrey.young@iohk.io> | 2022-06-13 13:42:36 -0400 |
commit | e5cb7c869cfde63a1b3fc49b458e0a48e2a20b6c (patch) | |
tree | 40becf2c33bbf75b04897143630f53c6ce88465e /compiler/GHC/JS/Syntax.hs | |
parent | c785dd78159dd3f1d25a8f86079cb6e06f48a707 (diff) | |
download | haskell-e5cb7c869cfde63a1b3fc49b458e0a48e2a20b6c.tar.gz |
Add JS.Rts
JS.Rts: compiles
reword: progress on RtsTypes
StgToJS.Config: add SDoc Context
JSRts: move ppr, workaround def type
JSRts.Types: compiles
JS.Rts: closer to compiling
JS.Rts: move jsIdIdent' to StgToJS.Monad
JS.Rts: remove unused predicates
JS: cleanup, comment sections, math funcs to Make
JS.Rts.Types: compiles
StgToJS.Expr: fix compilation errors
StgToJS.DataCon: move initClosure
JS.Rts: remove Alloc module
JS.Rts: initalize Rts module, remove redundant fs
JS: init Rts.Alloc move initClosure
JS.Apply: unwinding combinators in progress
JS: add helpers and fixmes
JS.Rts.Apply: no more e's, add closure, reg helper
StgToJS: add ToStat instance ClosureInfo
JS.Rts.Apply: closer to compiling
JS.Rts.Apply: more removal of #
JS.Rts.Apply: (#) removed
JS.Rts.Apply: compiles
JS.Rts.Rts: just pretty printing left
JS.Rts: Add Notes
JS.Rts: add file headers and notes
JS.Rts.Rts: fixing stringy issues
JS.Rts.Rts: compiles
JS.Rts.Rts: fix non-exhaustive patterns warnings
Diffstat (limited to 'compiler/GHC/JS/Syntax.hs')
-rw-r--r-- | compiler/GHC/JS/Syntax.hs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/compiler/GHC/JS/Syntax.hs b/compiler/GHC/JS/Syntax.hs index 79f53f39ee..ec7e1feb35 100644 --- a/compiler/GHC/JS/Syntax.hs +++ b/compiler/GHC/JS/Syntax.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} @@ -9,7 +8,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DerivingVia #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE PatternSynonyms #-} @@ -70,6 +68,12 @@ import qualified GHC.Data.ShortText as ST import GHC.Data.ShortText (ShortText) import GHC.Utils.Monad.State.Strict +-- FIXME: Jeff (2022,03): This state monad is strict, but uses a lazy list as +-- the state, since the strict state monad evaluates to WHNF, this state monad +-- will only evaluate to the first cons cell, i.e., we will be spine strict but +-- store possible huge thunks. This isn't a problem as long as we use this list +-- as a stack, but if we don't then any kind of Functor or Traverse operation +-- over this state will become yield a lot of thunks. newtype IdentSupply a = IS {runIdentSupply :: State [Ident] a} deriving Typeable @@ -100,7 +104,11 @@ instance Show a => Show (IdentSupply a) where show x = "(" ++ show (pseudoSaturate x) ++ ")" --- | Statements +-------------------------------------------------------------------------------- +-- Statements +-------------------------------------------------------------------------------- +-- FIXME (Jeff, 2022/03): statements according to what version of the standard? +-- | JavaScript statements data JStat = DeclStat Ident | ReturnStat JExpr @@ -141,7 +149,13 @@ appendJStat mx my = case (mx,my) of --- TODO: annotate expressions with type +-------------------------------------------------------------------------------- +-- Expressions +-------------------------------------------------------------------------------- +-- FIXME (Jeff, 2022/03): Expressions according to what version of the standard? +-- FIXME: annotate expressions with type. This is an EDSL of JS ASTs in Haskell. +-- There are many approaches to leveraging the GHCs type system for correctness +-- guarentees in EDSLs and we should use them -- | Expressions data JExpr = ValExpr JVal @@ -213,6 +227,9 @@ pattern Int x = ValExpr (JInt x) pattern String :: ShortText -> JExpr pattern String x = ValExpr (JStr x) +-------------------------------------------------------------------------------- +-- Values +-------------------------------------------------------------------------------- -- | Values data JVal = JVar Ident @@ -231,6 +248,9 @@ instance Outputable JVal where instance NFData JVal +-------------------------------------------------------------------------------- +-- Operators +-------------------------------------------------------------------------------- data JOp = EqOp -- == | StrictEqOp -- === @@ -294,6 +314,12 @@ instance Ord SaneDouble where instance Show SaneDouble where show (SaneDouble x) = show x +-------------------------------------------------------------------------------- +-- Identifiers +-------------------------------------------------------------------------------- +-- We use ShortText for identifier in JS backend + -- | Identifiers newtype Ident = TxtI { itxt:: ShortText} deriving (Show, Typeable, Ord, Eq, Generic, NFData) + |