diff options
author | Austin Seipp <aseipp@pobox.com> | 2013-09-06 13:18:11 -0500 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2013-09-06 13:18:11 -0500 |
commit | b372e8eadcbb6abe00d7a7b1198b656a29dcb1ce (patch) | |
tree | fef67897d8e6ab0aa9370c96b871ba6b91ecadf1 /compiler/parser | |
parent | df614779c356ea6aef29367a8dd1ca819b03a1d1 (diff) | |
download | haskell-b372e8eadcbb6abe00d7a7b1198b656a29dcb1ce.tar.gz |
Add basic support for GHCJS
This patch encompasses most of the basic infrastructure for GHCJS. It
includes:
* A new extension, -XJavaScriptFFI
* A new architecture, ArchJavaScript
* Parser and lexer support for 'foreign import javascript', only
available under -XJavaScriptFFI, using ArchJavaScript.
* As a knock-on, there is also a new 'WayCustom' constructor in
DynFlags, so clients of the GHC API can add custom 'tags' to their
built files. This should be useful for other users as well.
The remaining changes are really just the resulting fallout, making sure
all the cases are handled appropriately for DynFlags and Platform.
Authored-by: Luite Stegeman <stegeman@gmail.com>
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/Lexer.x | 2 | ||||
-rw-r--r-- | compiler/parser/Parser.y.pp | 3 | ||||
-rw-r--r-- | compiler/parser/RdrHsSyn.lhs | 5 |
3 files changed, 9 insertions, 1 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 95880946bb..12389e7f17 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -472,6 +472,7 @@ data Token | ITccallconv | ITcapiconv | ITprimcallconv + | ITjavascriptcallconv | ITmdo | ITfamily | ITgroup @@ -668,6 +669,7 @@ reservedWordsFM = listToUFM $ ( "ccall", ITccallconv, bit ffiBit), ( "capi", ITcapiconv, bit cApiFfiBit), ( "prim", ITprimcallconv, bit ffiBit), + ( "javascript", ITjavascriptcallconv, bit ffiBit), ( "rec", ITrec, bit arrowsBit .|. bit recursiveDoBit), diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 634d3c76f0..b18d0d35c6 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -251,6 +251,7 @@ incorrect. 'ccall' { L _ ITccallconv } 'capi' { L _ ITcapiconv } 'prim' { L _ ITprimcallconv } + 'javascript' { L _ ITjavascriptcallconv } 'proc' { L _ ITproc } -- for arrow notation extension 'rec' { L _ ITrec } -- for arrow notation extension 'group' { L _ ITgroup } -- for list transform extension @@ -977,6 +978,7 @@ callconv :: { CCallConv } | 'ccall' { CCallConv } | 'capi' { CApiConv } | 'prim' { PrimCallConv} + | 'javascript' { JavaScriptCallConv } safety :: { Safety } : 'unsafe' { PlayRisky } @@ -2047,6 +2049,7 @@ special_id | 'ccall' { L1 (fsLit "ccall") } | 'capi' { L1 (fsLit "capi") } | 'prim' { L1 (fsLit "prim") } + | 'javascript' { L1 (fsLit "javascript") } | 'group' { L1 (fsLit "group") } special_sym :: { Located FastString } diff --git a/compiler/parser/RdrHsSyn.lhs b/compiler/parser/RdrHsSyn.lhs index ea4c65357d..fb5f43f5e9 100644 --- a/compiler/parser/RdrHsSyn.lhs +++ b/compiler/parser/RdrHsSyn.lhs @@ -972,7 +972,10 @@ mkImport cconv safety (L loc entity, v, ty) let funcTarget = CFunction (StaticTarget entity Nothing True) importSpec = CImport PrimCallConv safety Nothing funcTarget return (ForD (ForeignImport v ty noForeignImportCoercionYet importSpec)) - + | cconv == JavaScriptCallConv = do + let funcTarget = CFunction (StaticTarget entity Nothing True) + importSpec = CImport JavaScriptCallConv safety Nothing funcTarget + return (ForD (ForeignImport v ty noForeignImportCoercionYet importSpec)) | otherwise = do case parseCImport cconv safety (mkExtName (unLoc v)) (unpackFS entity) of Nothing -> parseErrorSDoc loc (text "Malformed entity string") |