tools/pas2c/Pas2C.hs
changeset 10127 7f29a65aa1e4
parent 10124 aabd1b75d5a3
child 10129 cd2a64a1f4aa
equal deleted inserted replaced
10126:2fa3bb7785ee 10127:7f29a65aa1e4
  1138                      BTChar -> modify (\st -> st{lastType = BTChar})
  1138                      BTChar -> modify (\st -> st{lastType = BTChar})
  1139                      a -> error $ "Getting element of " ++ show a ++ "\nReference: " ++ show ae
  1139                      a -> error $ "Getting element of " ++ show a ++ "\nReference: " ++ show ae
  1140          a -> error $ "Getting element of " ++ show a ++ "\nReference: " ++ show ae
  1140          a -> error $ "Getting element of " ++ show a ++ "\nReference: " ++ show ae
  1141     case t of
  1141     case t of
  1142          BTString ->  return $ r <> text ".s" <> brackets e
  1142          BTString ->  return $ r <> text ".s" <> brackets e
       
  1143          BTAString ->  return $ r <> text ".s" <> brackets e
  1143          _ -> return $ r <> brackets e
  1144          _ -> return $ r <> brackets e
  1144 ref2C (SimpleReference name) = id2C IOLookup name
  1145 ref2C (SimpleReference name) = id2C IOLookup name
  1145 ref2C rf@(RecordField (Dereference ref1) ref2) = do
  1146 ref2C rf@(RecordField (Dereference ref1) ref2) = do
  1146     r1 <- ref2C ref1
  1147     r1 <- ref2C ref1
  1147     t <- fromPointer (show ref1) =<< gets lastType
  1148     t <- fromPointer (show ref1) =<< gets lastType
  1200     case (map toLower i, lt) of
  1201     case (map toLower i, lt) of
  1201         ("pchar", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pchar" $ BTPointerTo BTChar))
  1202         ("pchar", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pchar" $ BTPointerTo BTChar))
  1202         ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar))
  1203         ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar))
  1203         ("shortstring", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "astr2str" $ BTString))
  1204         ("shortstring", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "astr2str" $ BTString))
  1204         ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString))
  1205         ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString))
       
  1206         ("ansistring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2astr" $ BTAString))
  1205         ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString))
  1207         ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString))
  1206         (a, _) -> do
  1208         (a, _) -> do
  1207             e <- expr2C expr
  1209             e <- expr2C expr
  1208             t <- id2C IOLookup t'
  1210             t <- id2C IOLookup t'
  1209             return . parens $ parens t <> e
  1211             return . parens $ parens t <> e