tools/pas2c/Pas2C.hs
changeset 10124 aabd1b75d5a3
parent 10121 8b65699beb56
child 10127 7f29a65aa1e4
equal deleted inserted replaced
10123:64e72781d344 10124:aabd1b75d5a3
   941     e2 <- expr2C expr2
   941     e2 <- expr2C expr2
   942     t2 <- gets lastType
   942     t2 <- gets lastType
   943     case (op2C op, t1, t2) of
   943     case (op2C op, t1, t2) of
   944         ("+", BTAString, BTAString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strconcatA" (BTFunction False [(False, t1), (False, t2)] BTString))
   944         ("+", BTAString, BTAString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strconcatA" (BTFunction False [(False, t1), (False, t2)] BTString))
   945         ("+", BTAString, BTChar) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strappendA" (BTFunction False [(False, t1), (False, t2)] BTAString))
   945         ("+", BTAString, BTChar) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strappendA" (BTFunction False [(False, t1), (False, t2)] BTAString))
       
   946         ("!=", BTAString, BTAString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strncompareA" (BTFunction False [(False, t1), (False, t2)] BTBool))
   946         (_, BTAString, _) -> error $ "unhandled bin op with ansistring on the left side: " ++ show bop
   947         (_, BTAString, _) -> error $ "unhandled bin op with ansistring on the left side: " ++ show bop
   947         (_, _, BTAString) -> error $ "unhandled bin op with ansistring on the right side: " ++ show bop
   948         (_, _, BTAString) -> error $ "unhandled bin op with ansistring on the right side: " ++ show bop
   948         ("+", BTString, BTString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strconcat" (BTFunction False [(False, t1), (False, t2)] BTString))
   949         ("+", BTString, BTString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strconcat" (BTFunction False [(False, t1), (False, t2)] BTString))
   949         ("+", BTString, BTChar) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strappend" (BTFunction False [(False, t1), (False, t2)] BTString))
   950         ("+", BTString, BTChar) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strappend" (BTFunction False [(False, t1), (False, t2)] BTString))
   950         ("+", BTChar, BTString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strprepend" (BTFunction False [(False, t1), (False, t2)] BTString))
   951         ("+", BTChar, BTString) -> expr2C $ BuiltInFunCall [expr1, expr2] (SimpleReference $ Identifier "_strprepend" (BTFunction False [(False, t1), (False, t2)] BTString))
  1197 ref2C (TypeCast t'@(Identifier i _) expr) = do
  1198 ref2C (TypeCast t'@(Identifier i _) expr) = do
  1198     lt <- expr2C expr >> gets lastType
  1199     lt <- expr2C expr >> gets lastType
  1199     case (map toLower i, lt) of
  1200     case (map toLower i, lt) of
  1200         ("pchar", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pchar" $ BTPointerTo BTChar))
  1201         ("pchar", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pchar" $ BTPointerTo BTChar))
  1201         ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar))
  1202         ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar))
       
  1203         ("shortstring", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "astr2str" $ BTString))
  1202         ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString))
  1204         ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString))
  1203         ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString))
  1205         ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString))
  1204         (a, _) -> do
  1206         (a, _) -> do
  1205             e <- expr2C expr
  1207             e <- expr2C expr
  1206             t <- id2C IOLookup t'
  1208             t <- id2C IOLookup t'