import RdrHsSyn -- oodles of synonyms
import HsTypes ( mkHsForAllTy, mkHsUsForAllTy )
import HsCore
-import Const ( Literal(..), mkMachInt_safe )
+import Literal ( Literal(..), mkMachInt, mkMachInt64, mkMachWord, mkMachWord64 )
import BasicTypes ( Fixity(..), FixityDirection(..),
NewOrData(..), Version
)
import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
+import CallConv ( cCallConv )
import HsPragmas ( noDataPragmas, noClassPragmas )
import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind, UsageAnn(..) )
import IdInfo ( ArityInfo, exactArity, CprInfo(..), InlinePragInfo(..) )
+import PrimOp ( CCall(..), CCallTarget(..) )
import Lex
import RnMonad ( ImportVersion, LocalVersion, ParsedIface(..), WhatsImported(..),
- RdrNamePragma, ExportItem, RdrAvailInfo, GenAvailInfo(..), WhetherHasOrphans
+ RdrNamePragma, ExportItem, RdrAvailInfo, GenAvailInfo(..),
+ WhetherHasOrphans, IsBootInterface
)
import Bag ( emptyBag, unitBag, snocBag )
import FiniteMap ( emptyFM, unitFM, addToFM, plusFM, bagToFM, FiniteMap )
-import RdrName ( RdrName, mkRdrUnqual, mkSysQual, mkSysUnqual )
+import RdrName ( RdrName, mkRdrUnqual, mkSysQual, mkSysUnqual, mkRdrNameWkr )
import Name ( OccName, Provenance )
import OccName ( mkSysOccFS,
tcName, varName, ipName, dataName, clsName, tvName, uvName,
EncodedFS
)
import Module ( ModuleName, mkSysModuleFS )
-import PrelMods ( mkTupNameStr, mkUbxTupNameStr )
import PrelInfo ( mkTupConRdrName, mkUbxTupConRdrName )
import SrcLoc ( SrcLoc )
import Maybes
import Outputable
import GlaExts
+import FastString ( tailFS )
#if __HASKELL1__ > 4
import Ratio ( (%) )
'__bot' { ITbottom }
'__integer' { ITinteger_lit }
'__float' { ITfloat_lit }
+ '__word' { ITword_lit }
+ '__int64' { ITint64_lit }
+ '__word64' { ITword64_lit }
'__rational' { ITrational_lit }
'__addr' { ITaddr_lit }
'__litlit' { ITlit_lit }
'__U' { ITunfold $$ }
'__S' { ITstrict $$ }
'__R' { ITrules }
+ '__M' { ITcprinfo }
'__D' { ITdeprecated }
- '__M' { ITcprinfo $$ }
'..' { ITdotdot } -- reserved symbols
'::' { ITdcolon }
| import_part import_decl { $2 : $1 }
import_decl :: { ImportVersion OccName }
-import_decl : 'import' mod_fs INTEGER orphans whats_imported ';'
- { (mkSysModuleFS $2, fromInteger $3, $4, $5) }
+import_decl : 'import' mod_fs INTEGER orphans is_boot whats_imported ';'
+ { (mkSysModuleFS $2, fromInteger $3, $4, $5, $6) }
-- import Foo 3 :: a 1 b 3 c 7 ; means import a,b,c from Foo
-- import Foo 3 ; means import all of Foo
- -- import Foo 3 ! :: ...stuff... ; the ! means that Foo contains orphans
+ -- import Foo 3 ! @ :: ...stuff... ; the ! means that Foo contains orphans
+ -- and @ that Foo is a boot interface
orphans :: { WhetherHasOrphans }
orphans : { False }
| '!' { True }
+is_boot :: { IsBootInterface }
+is_boot : { False }
+ | '@' { True }
+
whats_imported :: { WhatsImported OccName }
whats_imported : { Everything }
| '::' name_version_pairs { Specifically $2 }
| deprecs deprec ';' { $2 : $1 }
deprec :: { RdrNameDeprecation }
-deprec : STRING { DeprecMod $1 }
- | deprec_name STRING { DeprecName $1 $2 }
+deprec : STRING { Deprecation (IEModuleContents undefined) $1 }
+ | deprec_name STRING { Deprecation $1 $2 }
-deprec_name :: { RdrName }
- : var_name { $1 }
- | tc_name { $1 }
+-- SUP: TEMPORARY HACK
+deprec_name :: { RdrNameIE }
+ : var_name { IEVar $1 }
+ | data_name { IEThingAbs $1 }
-----------------------------------------------------------------------------
| constr '|' constrs1 { $1 : $3 }
constr :: { RdrNameConDecl }
-constr : src_loc ex_stuff data_name batypes { mkConDecl $3 $2 (VanillaCon $4) $1 }
- | src_loc ex_stuff data_name '{' fields1 '}' { mkConDecl $3 $2 (RecCon $5) $1 }
+constr : src_loc ex_stuff data_name batypes { mk_con_decl $3 $2 (VanillaCon $4) $1 }
+ | src_loc ex_stuff data_name '{' fields1 '}' { mk_con_decl $3 $2 (RecCon $5) $1 }
-- We use "data_fs" so as to include ()
newtype_constr :: { [RdrNameConDecl] {- Empty if handwritten abstract -} }
newtype_constr : { [] }
- | src_loc '=' ex_stuff data_name atype { [mkConDecl $4 $3 (NewCon $5 Nothing) $1] }
+ | src_loc '=' ex_stuff data_name atype { [mk_con_decl $4 $3 (NewCon $5 Nothing) $1] }
| src_loc '=' ex_stuff data_name '{' var_name '::' atype '}'
- { [mkConDecl $4 $3 (NewCon $8 (Just $6)) $1] }
+ { [mk_con_decl $4 $3 (NewCon $8 (Just $6)) $1] }
ex_stuff :: { ([HsTyVar RdrName], RdrNameContext) }
ex_stuff : { ([],[]) }
class :: { HsPred RdrName }
class : qcls_name atypes { (HsPClass $1 $2) }
- | IPVARID '::' type { (HsPIParam (mkSysUnqual ipName $1) $3) }
+ | ipvar_name '::' type { (HsPIParam $1 $3) }
types0 :: { [RdrNameHsType] {- Zero or more -} }
types0 : {- empty -} { [ ] }
| '(#' types0 '#)' { MonoTupleTy $2 False{-unboxed-} }
| '[' type ']' { MonoListTy $2 }
| '{' qcls_name atypes '}' { MonoDictTy $2 $3 }
- | '{' IPVARID '::' type '}' { MonoIParamTy (mkSysUnqual ipName $2) $4 }
+ | '{' ipvar_name '::' type '}' { MonoIParamTy $2 $4 }
| '(' type ')' { $2 }
-- This one is dealt with via qtc_name
qvar_name : var_name { $1 }
| qvar_fs { mkSysQual varName $1 }
+ipvar_name :: { RdrName }
+ : IPVARID { mkSysUnqual ipName (tailFS $1) }
+
var_names :: { [RdrName] }
var_names : { [] }
| var_name var_names { $1 : $2 }
id_info_item :: { HsIdInfo RdrName }
: '__A' INTEGER { HsArity (exactArity (fromInteger $2)) }
| '__U' inline_prag core_expr { HsUnfold $2 $3 }
- | '__M' { HsCprInfo $1 }
+ | '__M' { HsCprInfo }
| '__S' { HsStrictness (HsStrictnessInfo $1) }
| '__C' { HsNoCafRefs }
| '__P' qvar_name { HsWorker $2 }
| '__letrec' '{' rec_binds '}'
'in' core_expr { UfLet (UfRec $3) $6 }
- | con_or_primop '{' core_args '}' { UfCon $1 $3 }
- | '__litlit' STRING atype { UfCon (UfLitLitCon $2 $3) [] }
+ | '__litlit' STRING atype { UfLitLit $2 $3 }
| '__inline_me' core_expr { UfNote UfInlineMe $2 }
| '__inline_call' core_expr { UfNote UfInlineCall $2 }
core_aexpr :: { UfExpr RdrName } -- Atomic expressions
core_aexpr : qvar_name { UfVar $1 }
-
| qdata_name { UfVar $1 }
-- This one means that e.g. "True" will parse as
-- (UfVar True_Id) rather than (UfCon True_Con []).
-- If you want to get a UfCon, then use the
-- curly-bracket notation (True {}).
- | core_lit { UfCon (UfLitCon $1) [] }
- | '(' core_expr ')' { $2 }
- | '(' comma_exprs2 ')' { UfTuple (mkTupConRdrName (length $2)) $2 }
- | '(#' comma_exprs0 '#)' { UfTuple (mkUbxTupConRdrName (length $2)) $2 }
-
-- This one is dealt with by qdata_name: see above comments
-- | '(' ')' { UfTuple (mkTupConRdrName 0) [] }
+ | core_lit { UfLit $1 }
+ | '(' core_expr ')' { $2 }
+
+ -- Tuple construtors are for the *worker* of the tuple
+ -- Going direct saves needless messing about
+ | '(' comma_exprs2 ')' { UfTuple (mkRdrNameWkr (mkTupConRdrName (length $2))) $2 }
+ | '(#' comma_exprs0 '#)' { UfTuple (mkRdrNameWkr (mkUbxTupConRdrName (length $2))) $2 }
+
+ | '{' '__ccall' ccall_string type '}'
+ { let
+ (is_dyn, is_casm, may_gc) = $2
+
+ target | is_dyn = DynamicTarget (error "CCall dyn target bogus unique")
+ | otherwise = StaticTarget $3
+
+ ccall = CCall target is_casm may_gc cCallConv
+ in
+ UfCCall ccall $4
+ }
+
+
comma_exprs0 :: { [UfExpr RdrName] } -- Zero or more
comma_exprs0 : {- empty -} { [ ] }
| core_expr { [ $1 ] }
comma_exprs2 : core_expr ',' core_expr { [$1,$3] }
| core_expr ',' comma_exprs2 { $1 : $3 }
-con_or_primop :: { UfCon RdrName }
-con_or_primop : qdata_name { UfDataCon $1 }
- | qvar_name { UfPrimOp $1 }
- | '__ccall' ccall_string { let
- (is_dyn, is_casm, may_gc) = $1
- in
- UfCCallOp $2 is_dyn is_casm may_gc
- }
-
rec_binds :: { [(UfBinder RdrName, UfExpr RdrName)] }
: { [] }
| core_val_bndr '=' core_expr ';' rec_binds { ($1,$3) : $5 }
core_alt :: { UfAlt RdrName }
core_alt : core_pat '->' core_expr { (fst $1, snd $1, $3) }
-core_pat :: { (UfCon RdrName, [RdrName]) }
-core_pat : core_lit { (UfLitCon $1, []) }
- | '__litlit' STRING atype { (UfLitLitCon $2 $3, []) }
- | qdata_name core_pat_names { (UfDataCon $1, $2) }
- | '(' comma_var_names1 ')' { (UfDataCon (mkTupConRdrName (length $2)), $2) }
- | '(#' comma_var_names1 '#)' { (UfDataCon (mkUbxTupConRdrName (length $2)), $2) }
+core_pat :: { (UfConAlt RdrName, [RdrName]) }
+core_pat : core_lit { (UfLitAlt $1, []) }
+ | '__litlit' STRING atype { (UfLitLitAlt $2 $3, []) }
+ | qdata_name core_pat_names { (UfDataAlt $1, $2) }
+ | '(' comma_var_names1 ')' { (UfDataAlt (mkTupConRdrName (length $2)), $2) }
+ | '(#' comma_var_names1 '#)' { (UfDataAlt (mkUbxTupConRdrName (length $2)), $2) }
| '__DEFAULT' { (UfDefault, []) }
| '(' core_pat ')' { $2 }
| var_name ',' comma_var_names1 { $1 : $3 }
core_lit :: { Literal }
-core_lit : integer { mkMachInt_safe $1 }
+core_lit : integer { mkMachInt $1 }
| CHAR { MachChar $1 }
| STRING { MachStr $1 }
- | '__string' STRING { NoRepStr $2 (panic "NoRepStr type") }
| rational { MachDouble $1 }
+ | '__word' integer { mkMachWord $2 }
+ | '__word64' integer { mkMachWord64 $2 }
+ | '__int64' integer { mkMachInt64 $2 }
| '__float' rational { MachFloat $2 }
-
- | '__integer' integer { NoRepInteger $2 (panic "NoRepInteger type")
- -- The type checker will add the types
- }
-
- | '__rational' integer integer { NoRepRational ($2 % $3)
- (panic "NoRepRational type")
- -- The type checker will add the type
- }
-
| '__addr' integer { MachAddr $2 }
integer :: { Integer }
------------------------------------------------------------------------
scc :: { CostCentre }
- : '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
- | '__scc' '{' cc_name mod_name STRING cc_dup cc_caf '}'
- { NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
- cc_is_dupd = $6, cc_is_caf = $7 } }
+ : '__sccC' '{' mod_name '}' { AllCafsCC $3 }
+ | '__scc' '{' cc_name mod_name cc_dup cc_caf '}'
+ { NormalCC { cc_name = $3, cc_mod = $4,
+ cc_is_dupd = $5, cc_is_caf = $6 } }
cc_name :: { EncodedFS }
: CONID { $1 }
| PRules [RdrNameRuleDecl]
| PDeprecs [RdrNameDeprecation]
-mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc
+mk_con_decl name (ex_tvs, ex_ctxt) details loc = mkConDecl name ex_tvs ex_ctxt details loc
}