Special case for rendering type of two-dimensional arrays, since C is inconsistent in its syntax
authorunc0rr
Sun, 18 Nov 2018 20:18:32 +0100
changeset 14228 b01770d42517
parent 14227 1d678dee55d1
child 14229 e590fb0f2567
Special case for rendering type of two-dimensional arrays, since C is inconsistent in its syntax
tools/pas2c/Pas2C.hs
--- a/tools/pas2c/Pas2C.hs	Sun Nov 18 12:21:03 2018 -0500
+++ b/tools/pas2c/Pas2C.hs	Sun Nov 18 20:18:32 2018 +0100
@@ -774,6 +774,12 @@
         where
             bt = BTEnum $ map (\(Identifier i _) -> map toLower i) ids
     type2C' (ArrayDecl Nothing t) = type2C (PointerTo t)
+    type2C' (ArrayDecl (Just r1) (ArrayDecl (Just r2) t)) = do
+        t' <- type2C t
+        lt <- gets lastType
+        r1' <- initExpr2C (InitRange r1)
+        r2' <- initExpr2C (InitRange r2)
+        return $ \i -> t' i <> brackets r1' <> brackets r2'
     type2C' (ArrayDecl (Just r) t) = do
         t' <- type2C t
         lt <- gets lastType