tools/pas2c/Pas2C.hs
branchwebgl
changeset 8446 c18ba8726f5a
parent 8444 75db7bb8dce8
child 9954 bf51bc7e2808
equal deleted inserted replaced
8444:75db7bb8dce8 8446:c18ba8726f5a
   784     return $
   784     return $
   785         text "if" <> parens e $+$ p1 $+$ el
   785         text "if" <> parens e $+$ p1 $+$ el
   786     where
   786     where
   787     elsePart | isNothing mphrase2 = return $ empty
   787     elsePart | isNothing mphrase2 = return $ empty
   788              | otherwise = liftM (text "else" $$) $ (phrase2C . wrapPhrase) (fromJust mphrase2)
   788              | otherwise = liftM (text "else" $$) $ (phrase2C . wrapPhrase) (fromJust mphrase2)
   789 phrase2C (Assignment ref expr) = do
   789 phrase2C asgn@(Assignment ref expr) = do
   790     r <- ref2C ref
   790     r <- ref2C ref
   791     t <- gets lastType
   791     t <- gets lastType
   792     case (t, expr) of
   792     case (t, expr) of
   793         (BTFunction {}, (Reference r')) -> do
   793         (BTFunction {}, (Reference r')) -> do
   794             e <- ref2C r'
   794             e <- ref2C r'
   802                     e <- expr2C $ Reference $ FunCall [Reference $ RefExpression expr] (SimpleReference (Identifier "pchar2str" BTUnknown))
   802                     e <- expr2C $ Reference $ FunCall [Reference $ RefExpression expr] (SimpleReference (Identifier "pchar2str" BTUnknown))
   803                     return $ r <+> text "=" <+> e <> semi
   803                     return $ r <+> text "=" <+> e <> semi
   804                 BTString -> do
   804                 BTString -> do
   805                     e <- expr2C expr
   805                     e <- expr2C expr
   806                     return $ r <+> text "=" <+> e <> semi
   806                     return $ r <+> text "=" <+> e <> semi
   807                 _ -> error $ "Assignment to string from " ++ show lt
   807                 _ -> error $ "Assignment to string from " ++ show asgn
   808         (BTArray _ _ _, _) -> do
   808         (BTArray _ _ _, _) -> do
   809             case expr of
   809             case expr of
   810                 Reference er -> do
   810                 Reference er -> do
   811                     exprRef <- ref2C er
   811                     exprRef <- ref2C er
   812                     exprT <- gets lastType
   812                     exprT <- gets lastType