tools/pas2c.hs
changeset 7327 4e35c45d0853
parent 7323 8490a4f439a5
child 7329 92b6d8ae99e4
equal deleted inserted replaced
7325:a68eca3ad1fe 7327:4e35c45d0853
   462              return [text "enum" <> braces (i' <+> ie)]
   462              return [text "enum" <> braces (i' <+> ie)]
   463          (True, BTFloat, [i], Just e) -> do
   463          (True, BTFloat, [i], Just e) -> do
   464              i' <- id2CTyped t i
   464              i' <- id2CTyped t i
   465              ie <- initExpr2C e
   465              ie <- initExpr2C e
   466              return [text "#define" <+> i' <+> parens ie <> text "\n"]
   466              return [text "#define" <+> i' <+> parens ie <> text "\n"]
   467          (_, BTFunction{}, _, Nothing) -> liftM (map(\i -> t' $ text "*" <+> i)) $ mapM (id2CTyped t) ids
   467          (_, BTFunction{}, _, Nothing) -> liftM (map(\i -> t' i)) $ mapM (id2CTyped t) ids
   468          _ -> liftM (map(\i -> t' i <+> ie)) $ mapM (id2CTyped t) ids
   468          _ -> liftM (map(\i -> t' i <+> ie)) $ mapM (id2CTyped t) ids
   469     where
   469     where
   470     initExpr Nothing = return $ empty
   470     initExpr Nothing = return $ empty
   471     initExpr (Just e) = liftM (text "=" <+>) (initExpr2C e)
   471     initExpr (Just e) = liftM (text "=" <+>) (initExpr2C e)
   472 
   472 
   613         return $ \i -> ft i <> brackets r'
   613         return $ \i -> ft i <> brackets r'
   614     type2C' (Set t) = return (text "<<set>>" <+>)
   614     type2C' (Set t) = return (text "<<set>>" <+>)
   615     type2C' (FunctionType returnType params) = do
   615     type2C' (FunctionType returnType params) = do
   616         t <- type2C returnType
   616         t <- type2C returnType
   617         p <- withState' id $ functionParams2C params
   617         p <- withState' id $ functionParams2C params
   618         return (\i -> t empty <+> i <> parens p)
   618         return (\i -> (t empty <> (parens $ text "*" <> i) <> parens p))
   619     type2C' (DeriveType (InitBinOp _ _ i)) = type2C' (DeriveType i)
   619     type2C' (DeriveType (InitBinOp _ _ i)) = type2C' (DeriveType i)
   620     type2C' (DeriveType (InitPrefixOp _ i)) = type2C' (DeriveType i)
   620     type2C' (DeriveType (InitPrefixOp _ i)) = type2C' (DeriveType i)
   621     type2C' (DeriveType (InitNumber _)) = return (text "int" <+>)
   621     type2C' (DeriveType (InitNumber _)) = return (text "int" <+>)
   622     type2C' (DeriveType (InitHexNumber _)) = return (text "int" <+>)
   622     type2C' (DeriveType (InitHexNumber _)) = return (text "int" <+>)
   623     type2C' (DeriveType (InitFloat _)) = return (text "float" <+>)
   623     type2C' (DeriveType (InitFloat _)) = return (text "float" <+>)