tools/pas2c.hs
changeset 7062 7efe16575779
parent 7060 861d6897917f
child 7066 12cc2bd84b0b
--- a/tools/pas2c.hs	Fri May 11 23:22:01 2012 +0400
+++ b/tools/pas2c.hs	Fri May 11 23:34:35 2012 +0400
@@ -747,6 +747,13 @@
 expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "ord" _))) = liftM parens $ expr2C e
 expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "succ" _))) = liftM (<> text " + 1") $ expr2C e
 expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "pred" _))) = liftM (<> text " - 1") $ expr2C e
+expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "length" _))) = do
+    e' <- expr2C e
+    lt <- gets lastType
+    case lt of
+         BTString -> return $ text "length" <> parens e'
+         BTArray {} -> return $ text "length_ar" <> parens e'
+         _ -> error $ "length() called on " ++ show lt
 expr2C (BuiltInFunCall params ref) = do
     r <- ref2C ref 
     t <- gets lastType