tools/pas2c/Pas2C.hs
changeset 10111 459bc720cea1
parent 10015 4feced261c68
child 10113 b26c2772e754
equal deleted inserted replaced
10110:a7aed2eea727 10111:459bc720cea1
   419 resolveType (DeriveType (InitBinOp {})) = return (BTInt True)
   419 resolveType (DeriveType (InitBinOp {})) = return (BTInt True)
   420 resolveType (DeriveType (InitPrefixOp _ e)) = initExpr2C e >> gets lastType
   420 resolveType (DeriveType (InitPrefixOp _ e)) = initExpr2C e >> gets lastType
   421 resolveType (DeriveType (BuiltInFunction{})) = return (BTInt True)
   421 resolveType (DeriveType (BuiltInFunction{})) = return (BTInt True)
   422 resolveType (DeriveType (InitReference (Identifier{}))) = return BTBool -- TODO: derive from actual type
   422 resolveType (DeriveType (InitReference (Identifier{}))) = return BTBool -- TODO: derive from actual type
   423 resolveType (DeriveType _) = return BTUnknown
   423 resolveType (DeriveType _) = return BTUnknown
   424 resolveType (String _) = return BTString
   424 resolveType String = return BTString
   425 resolveType VoidType = return BTVoid
   425 resolveType VoidType = return BTVoid
   426 resolveType (Sequence ids) = return $ BTEnum $ map (\(Identifier i _) -> map toLower i) ids
   426 resolveType (Sequence ids) = return $ BTEnum $ map (\(Identifier i _) -> map toLower i) ids
   427 resolveType (RangeType _) = return $ BTVoid
   427 resolveType (RangeType _) = return $ BTVoid
   428 resolveType (Set t) = liftM BTSet $ resolveType t
   428 resolveType (Set t) = liftM BTSet $ resolveType t
   429 resolveType (VarParamType t) = liftM BTVarParam $ resolveType t
   429 resolveType (VarParamType t) = liftM BTVarParam $ resolveType t
   711     rt <- resolveType t
   711     rt <- resolveType t
   712     modify (\st -> st{lastType = rt})
   712     modify (\st -> st{lastType = rt})
   713     return r
   713     return r
   714     where
   714     where
   715     type2C' VoidType = return (text "void" <+>)
   715     type2C' VoidType = return (text "void" <+>)
   716     type2C' (String l) = return (text "string255" <+>)--return (text ("string" ++ show l) <+>)
   716     type2C' String = return (text "string255" <+>)--return (text ("string" ++ show l) <+>)
   717     type2C' (PointerTo (SimpleType i)) = do
   717     type2C' (PointerTo (SimpleType i)) = do
   718         i' <- id2C IODeferred i
   718         i' <- id2C IODeferred i
   719         lt <- gets lastType
   719         lt <- gets lastType
   720         case lt of
   720         case lt of
   721              BTRecord _ _ -> return $ \a -> text "struct __" <> i' <+> text "*" <+> a
   721              BTRecord _ _ -> return $ \a -> text "struct __" <> i' <+> text "*" <+> a