Convert "unit.function()" properly
authorunc0rr
Fri, 11 May 2012 22:09:34 +0400
changeset 7055 4c495c8f02da
parent 7054 7e8fb07ef91c
child 7056 2884c7be6691
Convert "unit.function()" properly
tools/pas2c.hs
--- a/tools/pas2c.hs	Fri May 11 21:10:58 2012 +0400
+++ b/tools/pas2c.hs	Fri May 11 22:09:34 2012 +0400
@@ -756,6 +756,12 @@
     case t of
          BTFunction {} -> return $ i <> parens empty
          _ -> return $ i
+ref2CF r@(RecordField (SimpleReference _) (SimpleReference _)) = do
+    i <- ref2C r
+    t <- gets lastType
+    case t of
+         BTFunction {} -> return $ i <> parens empty
+         _ -> return $ i
 ref2CF r = ref2C r
 
 ref2C :: Reference -> State RenderState Doc
@@ -790,7 +796,7 @@
     t <- fromPointer (show ref1) =<< gets lastType
     r2 <- case t of
         BTRecord _ rs -> withRecordNamespace "" rs $ ref2C ref2
-        BTUnit -> withLastIdNamespace $ ref2CF ref2
+        BTUnit -> error "What??"
         a -> error $ "dereferencing from " ++ show a ++ "\n" ++ show rf
     return $ 
         r1 <> text "->" <> r2
@@ -801,7 +807,7 @@
         BTRecord _ rs -> do
             r2 <- withRecordNamespace "" rs $ ref2C ref2
             return $ r1 <> text "." <> r2
-        BTUnit -> withLastIdNamespace $ ref2CF ref2        
+        BTUnit -> withLastIdNamespace $ ref2C ref2
         a -> error $ "dereferencing from " ++ show a ++ "\n" ++ show rf
 ref2C d@(Dereference ref) = do
     r <- ref2C ref