equal
deleted
inserted
replaced
268 checkParam _ = False |
268 checkParam _ = False |
269 id2C IODeferred (Identifier i t) = do |
269 id2C IODeferred (Identifier i t) = do |
270 let i' = map toLower i |
270 let i' = map toLower i |
271 v <- gets $ Map.lookup i' . currentScope |
271 v <- gets $ Map.lookup i' . currentScope |
272 if (isNothing v) then |
272 if (isNothing v) then |
273 return $ text i |
273 modify (\s -> s{lastType = BTUnknown, lastIdentifier = i}) >> return (text i) |
274 else |
274 else |
275 return . text . fst . head . fromJust $ v |
275 let vv = head $ fromJust v in modify (\s -> s{lastType = snd vv, lastIdentifier = fst vv}) >> (return . text . fst $ vv) |
276 |
276 |
277 id2CTyped :: TypeDecl -> Identifier -> State RenderState Doc |
277 id2CTyped :: TypeDecl -> Identifier -> State RenderState Doc |
278 id2CTyped t (Identifier i _) = do |
278 id2CTyped t (Identifier i _) = do |
279 tb <- resolveType t |
279 tb <- resolveType t |
280 case tb of |
280 case tb of |
515 modify (\st -> st{lastType = rt}) |
515 modify (\st -> st{lastType = rt}) |
516 return r |
516 return r |
517 where |
517 where |
518 type2C' VoidType = return (text "void" <+>) |
518 type2C' VoidType = return (text "void" <+>) |
519 type2C' (String l) = return (text "string255" <+>)--return (text ("string" ++ show l) <+>) |
519 type2C' (String l) = return (text "string255" <+>)--return (text ("string" ++ show l) <+>) |
520 type2C' (PointerTo (SimpleType i)) = liftM (\i a -> text "struct __" <> i <+> text "*" <+> a) $ id2C IODeferred i |
520 type2C' (PointerTo (SimpleType i)) = do |
|
521 i' <- id2C IODeferred i |
|
522 lt <- gets lastType |
|
523 case lt of |
|
524 BTRecord _ -> return $ \a -> text "struct __" <> i' <+> text "*" <+> a |
|
525 BTUnknown -> return $ \a -> text "struct __" <> i' <+> text "*" <+> a |
|
526 _ -> return $ \a -> i' <+> text "*" <+> a |
521 type2C' (PointerTo t) = liftM (\t a -> t (parens $ text "*" <> a)) $ type2C t |
527 type2C' (PointerTo t) = liftM (\t a -> t (parens $ text "*" <> a)) $ type2C t |
522 type2C' (RecordType tvs union) = do |
528 type2C' (RecordType tvs union) = do |
523 t <- withState' id $ mapM (tvar2C False) tvs |
529 t <- withState' id $ mapM (tvar2C False) tvs |
524 u <- unions |
530 u <- unions |
525 return $ \i -> text "struct __" <> i <+> lbrace $+$ nest 4 ((vcat . map (<> semi) . concat $ t) $$ u) $+$ rbrace <+> i |
531 return $ \i -> text "struct __" <> i <+> lbrace $+$ nest 4 ((vcat . map (<> semi) . concat $ t) $$ u) $+$ rbrace <+> i |