437 structs <- mapM struct2C a |
437 structs <- mapM struct2C a |
438 return $ text "union" $+$ braces (nest 4 $ vcat structs) <> semi |
438 return $ text "union" $+$ braces (nest 4 $ vcat structs) <> semi |
439 struct2C tvs = do |
439 struct2C tvs = do |
440 t <- withState' id $ mapM (tvar2C False) tvs |
440 t <- withState' id $ mapM (tvar2C False) tvs |
441 return $ text "struct" $+$ braces (nest 4 (vcat . map (<> semi) . concat $ t)) <> semi |
441 return $ text "struct" $+$ braces (nest 4 (vcat . map (<> semi) . concat $ t)) <> semi |
442 type2C' (RangeType r) = return (text "<<range type>>" <+>) |
442 type2C' (RangeType r) = return (text "int" <+>) |
443 type2C' (Sequence ids) = do |
443 type2C' (Sequence ids) = do |
444 is <- mapM (id2C IOInsert . setBaseType bt) ids |
444 is <- mapM (id2C IOInsert . setBaseType bt) ids |
445 return (text "enum" <+> (braces . vcat . punctuate comma . map (\(a, b) -> a <+> equals <+> text "0x" <> text (showHex b "")) $ zip is [1..]) <+>) |
445 return (text "enum" <+> (braces . vcat . punctuate comma . map (\(a, b) -> a <+> equals <+> text "0x" <> text (showHex b "")) $ zip is [1..]) <+>) |
446 where |
446 where |
447 bt = BTEnum $ map (\(Identifier i _) -> map toLower i) ids |
447 bt = BTEnum $ map (\(Identifier i _) -> map toLower i) ids |
448 type2C' (ArrayDecl Nothing t) = do |
448 type2C' (ArrayDecl Nothing t) = type2C (PointerTo t) |
449 t' <- type2C t |
|
450 return $ \i -> t' i <> brackets empty |
|
451 type2C' (ArrayDecl (Just r) t) = do |
449 type2C' (ArrayDecl (Just r) t) = do |
452 t' <- type2C t |
450 t' <- type2C t |
453 r' <- initExpr2C (InitRange r) |
451 r' <- initExpr2C (InitRange r) |
454 return $ \i -> t' i <> brackets r' |
452 return $ \i -> t' i <> brackets r' |
455 type2C' (Set t) = return (text "<<set>>" <+>) |
453 type2C' (Set t) = return (text "<<set>>" <+>) |