diff options
author | doyougnu <jeffrey.young@iohk.io> | 2022-03-19 19:59:20 -0400 |
---|---|---|
committer | doyougnu <jeffrey.young@iohk.io> | 2022-06-13 13:42:38 -0400 |
commit | 5fa834b3db4619346d9205ad38f9c5837945a08c (patch) | |
tree | 0a75dcbe090552e1e837e4e804703d33b8800db1 /compiler/GHC/JS/Syntax.hs | |
parent | 14fb7ba21d47c53c52f2d66c072dd18b228216d5 (diff) | |
download | haskell-5fa834b3db4619346d9205ad38f9c5837945a08c.tar.gz |
JS.Backend: Add JS specific Linker
JS: initialize Linker, DynamicLinking
JS.Printer: adapted to GHC Head
JS.Printer: some cleanup and init Printer
StgToJS.Printer: Compiles
JS.Linker: Add types, expose JS keywords
JS.Syntax: add Binary instance on Ident's
JS.Linker: Migrate more Types to Data.Binary
JS.Linker.Types: compiles and adapted to GHC Head
JS.Linker.Types: compiles
JS.Linker.Types: add UseBase type
JS.Linker: Comments and Cleanup
JS.Linker.Types: add TH types, Env type, DepsLoc
JS.Linker: more FIXMEs numerous Linker fixes
JS.Linker: removed Text references
JS.UnitUtils: add package related helper functions
JS.Linker: more DynFlags removal
JS.Linker: Time for semantic errors
JS.Linker: DynFlags finally removed
JS.Linker: 107 compile errors to go
JS.Linker.Utils: initialized, adapted to GHC Head
JS.Linker.Utils: initialize Utils module
JS.Linker.Utils: more utils
JS.Rts: move rtsText to Rts
JS.Linker: linkerStats implemented
JS.Compactor: compiles, adapted to GHC Head
JS.Compactor: have to retrofit compact for linker
JS.Linker.Compactor: unwinding lenses
JS.Linker.Compactor: comments over addItem
JS.Linker.Compactor: Lenses removed
JS.Linker.Compactor: SHA256 removed
JS.Linker.Compactor: only missing instances left
JS.Linker.Compactor: compiles
JS.Linker: compiles, adapted to ghc Head
JS.Linker: More progress
JS.Linker: link in memory compiles
JS.Linker: just shims left
JS.Linker.DynamicLinking compiles: adapted to head
JS.Linker.DynamicLinking: initialization
JS.Linker.DynamicLinking: compiles up to Variants
JS.Variants: initialize
JS.Linker: numerous and various fixes
JS.Linker.DynamicLinking: only small errors left
JS.Linker.Archive: compiles, adapted to GHC Head
JS.Linker: initialize Archive compat module
JS.Linker.Archive: minor fixes
JS.Linker.DynamicLinking: compiles
JS.Linker: cleanup, remove Variants, add comments
fixup: more cleanup
JS.Linker: more cleanup and comments
Diffstat (limited to 'compiler/GHC/JS/Syntax.hs')
-rw-r--r-- | compiler/GHC/JS/Syntax.hs | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/compiler/GHC/JS/Syntax.hs b/compiler/GHC/JS/Syntax.hs index 37104d8d9f..d70e06d801 100644 --- a/compiler/GHC/JS/Syntax.hs +++ b/compiler/GHC/JS/Syntax.hs @@ -48,6 +48,8 @@ module GHC.JS.Syntax , pseudoSaturate -- * Utility , SaneDouble(..) + -- * Keywords + , isJsKeyword ) where import GHC.Prelude @@ -56,16 +58,18 @@ import Control.DeepSeq import Data.Function import qualified Data.Map as M +import qualified Data.Set as Set import Data.Data import Data.Word import qualified Data.Semigroup as Semigroup import GHC.Generics +import Data.Binary import GHC.Utils.Outputable (Outputable (..)) import qualified GHC.Utils.Outputable as O import qualified GHC.Data.ShortText as ST -import GHC.Data.ShortText (ShortText) +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 @@ -319,9 +323,35 @@ instance Show SaneDouble where -------------------------------------------------------------------------------- -- Identifiers -------------------------------------------------------------------------------- --- We use ShortText for identifier in JS backend +-- We use ShortText for identifiers in JS backend -- | Identifiers newtype Ident = TxtI { itxt:: ShortText} - deriving (Show, Typeable, Ord, Eq, Generic, NFData) + deriving stock (Show, Typeable, Ord, Eq, Generic) + deriving newtype (Binary, NFData) -- FIXME: Jeff (2022,03): ShortText uses Data.Binary + -- rather than GHC.Utils.Binary. What is the + -- difference? See related FIXME in StgToJS.Object + +-------------------------------------------------------------------------------- +-- JS Keywords +-------------------------------------------------------------------------------- +-- | The set of Javascript keywords +jsKeywords :: Set.Set Ident +jsKeywords = Set.fromList $ TxtI <$> + [ "break", "case", "catch", "continue", "debugger" + , "default", "delete", "do", "else", "finally", "for" + , "function", "if", "in", "instanceof", "new", "return" + , "switch", "this", "throw", "try", "typeof", "var", "void" + , "while", "with" + , "class", "enum", "export", "extends", "import", "super" + , "const" + , "implements", "interface", "let", "package", "private" + , "protected" + , "public", "static", "yield" + , "null", "true", "false" + ] + +-- | Check if provided Ident is a JS keyword +isJsKeyword :: Ident -> Bool +isJsKeyword = flip Set.member jsKeywords |