Simon's big boxy-type commit
[ghc-hetmet.git] / ghc / compiler / typecheck / TcForeign.lhs
index bcf08e4..4be039b 100644 (file)
@@ -17,21 +17,20 @@ module TcForeign
         , tcForeignExports
        ) where
 
-#include "../includes/ghcconfig.h"
 #include "HsVersions.h"
 
 import HsSyn
 
 import TcRnMonad
 import TcHsType                ( tcHsSigType, UserTypeCtxt(..) )
-import TcExpr          ( tcCheckSigma )                        
+import TcExpr          ( tcPolyExpr )                  
 
 import ForeignCall     ( CCallConv(..) )
 import ErrUtils                ( Message )
 import Id              ( Id, mkLocalId, mkExportedLocalId )
 #if alpha_TARGET_ARCH
-import PrimRep         ( getPrimRepSize, isFloatingRep )
 import Type            ( typePrimRep )
+import SMRep           ( argMachRep, primRepToCgRep, primRepHint )
 #endif
 import OccName         ( mkForeignExportOcc )
 import Name            ( Name, NamedThing(..), mkExternalName )
@@ -47,13 +46,13 @@ import ForeignCall  ( CExportSpec(..), CCallTarget(..),
                          CLabelString, isCLabelString,
                          isDynamicTarget, withDNTypes, DNKind(..), DNCallSpec(..) ) 
 import PrelNames       ( hasKey, ioTyConKey )
-import CmdLineOpts     ( dopt_HscLang, HscLang(..) )
+import DynFlags                ( DynFlags(..), HscTarget(..) )
 import Outputable
 import SrcLoc          ( Located(..), srcSpanStart )
 import Bag             ( consBag )
 
 #if alpha_TARGET_ARCH
-import MachOp          ( machRepByteWidth )
+import MachOp          ( machRepByteWidth, MachHint(FloatHint) )
 #endif
 \end{code}
 
@@ -186,10 +185,10 @@ The check is needed for both via-C and native-code routes
 checkFEDArgs arg_tys
   = check (integral_args <= 32) err
   where
-    integral_args = sum [ machRepByteWidth rep
-                       | (rep,hint) <- map typeMachRepRep arg_tys,
-                         hint /= FloatHint ]
-    err = ptext SLIT("On Alpha, I can only handle 4 non-floating-point arguments to foreign export dynamic")
+    integral_args = sum [ (machRepByteWidth . argMachRep . primRepToCgRep) prim_rep
+                       | prim_rep <- map typePrimRep arg_tys,
+                         primRepHint prim_rep /= FloatHint ]
+    err = ptext SLIT("On Alpha, I can only handle 32 bytes of non-floating-point arguments to foreign export dynamic")
 #else
 checkFEDArgs arg_tys = returnM ()
 #endif
@@ -217,7 +216,7 @@ tcFExport fo@(ForeignExport (L loc nm) hs_ty spec isDeprec) =
    addErrCtxt (foreignDeclCtxt fo)     $
 
    tcHsSigType (ForSigCtxt nm) hs_ty   `thenM` \ sig_ty ->
-   tcCheckSigma (nlHsVar nm) sig_ty    `thenM` \ rhs ->
+   tcPolyExpr (nlHsVar nm) sig_ty      `thenM` \ rhs ->
 
    tcCheckFEType sig_ty spec           `thenM_`
 
@@ -316,11 +315,11 @@ checkCOrAsmOrDotNetOrInterp other
 
 checkCg check
  = getDOpts            `thenM` \ dflags ->
-   let hscLang = dopt_HscLang dflags in
-   case hscLang of
+   let target = hscTarget dflags in
+   case target of
      HscNothing -> returnM ()
      otherwise  ->
-       case check hscLang of
+       case check target of
         Nothing  -> returnM ()
         Just err -> addErrTc (text "Illegal foreign declaration:" <+> err)
 \end{code}