[project @ 1998-11-16 11:56:09 by sof]
authorsof <unknown>
Mon, 16 Nov 1998 11:56:13 +0000 (11:56 +0000)
committersof <unknown>
Mon, 16 Nov 1998 11:56:13 +0000 (11:56 +0000)
Cleaned up the handling of the default calling conventions for 'foreign' decls

ghc/compiler/absCSyn/CallConv.lhs
ghc/compiler/parser/hsparser.y
ghc/compiler/parser/utils.h
ghc/compiler/reader/ReadPrefix.lhs

index d09d063..97a92bb 100644 (file)
@@ -11,6 +11,7 @@ module CallConv
 
        , stdCallConv
        , cCallConv
+       , defaultCallConv
        , callConvAttribute
        , decorateExtName
        ) where
@@ -33,6 +34,9 @@ stdCallConv = 0
 
 cCallConv  :: CallConv
 cCallConv = 1
+
+defaultCallConv :: CallConv
+defaultCallConv = cCallConv
 \end{code}
 
 Generate the gcc attribute corresponding to the given
index 30bfa6f..d4befff 100644 (file)
@@ -555,8 +555,8 @@ callconv: STDCALL   { $$ = CALLCONV_STDCALL;  }
        | C_CALL        { $$ = CALLCONV_CCALL;    }
        | PASCAL        { $$ = CALLCONV_PASCAL;   }
        | FASTCALL      { $$ = CALLCONV_FASTCALL; }
-/* If you leave out the specification of a calling convention, you'll get C's. */
-        | /*empty*/     { $$ = CALLCONV_CCALL;    }
+/* If you leave out the specification of a calling convention, you'll (probably) get C's. */
+        | /*empty*/     { $$ = CALLCONV_NONE;    }
        ;
 
 ext_name: STRING       { $$ = mkjust(lsing($1)); }
index 4ebf921..76d0d0e 100644 (file)
@@ -115,6 +115,7 @@ void        checkprec PROTO((tree, qid, BOOLEAN));
 */
 
 /* FFI predefines */
+#define CALLCONV_NONE     (-1)
 #define CALLCONV_STDCALL  0
 #define CALLCONV_CCALL    1
 #define CALLCONV_PASCAL   2
index 8024e08..44e8e62 100644 (file)
@@ -962,7 +962,12 @@ wlkExtName (U_just pt)
       [mod,nm] -> returnUgn (ExtName nm (Just mod))
 
 rdCallConv :: Int -> UgnM CallConv
-rdCallConv x = returnUgn x
+rdCallConv x = 
+   -- this tracks the #defines in parser/utils.h
+  case x of
+    (-1) -> -- no calling convention specified, use default.
+          returnUgn defaultCallConv
+    _    -> returnUgn x
 
 rdForKind :: Int -> Bool -> UgnM ForKind
 rdForKind 0 isUnsafe = -- foreign import