tools/pas2c/Pas2C.hs
branchwebgl
changeset 9964 12b0ed9910cd
parent 9954 bf51bc7e2808
child 9982 24ea101fdc7f
equal deleted inserted replaced
9962:97ed501accc5 9964:12b0ed9910cd
   649 								return $ text s
   649 								return $ text s
   650 initExpr2C' (InitFloat s) = return $ text s
   650 initExpr2C' (InitFloat s) = return $ text s
   651 initExpr2C' (InitHexNumber s) = return $ text "0x" <> (text . map toLower $ s)
   651 initExpr2C' (InitHexNumber s) = return $ text "0x" <> (text . map toLower $ s)
   652 initExpr2C' (InitString [a]) = return . quotes $ text [a]
   652 initExpr2C' (InitString [a]) = return . quotes $ text [a]
   653 initExpr2C' (InitString s) = return $ strInit s
   653 initExpr2C' (InitString s) = return $ strInit s
   654 initExpr2C' (InitChar a) = return $ quotes $ text "\\x" <> text (showHex (read a) "")
   654 initExpr2C' (InitChar a) = return $ text "0x" <> text (showHex (read a) "")
   655 initExpr2C' (InitReference i) = id2C IOLookup i
   655 initExpr2C' (InitReference i) = id2C IOLookup i
   656 initExpr2C' (InitRecord fields) = do
   656 initExpr2C' (InitRecord fields) = do
   657     (fs :: [Doc]) <- mapM (\(Identifier a _, b) -> liftM (text "." <> text a <+> equals <+>) $ initExpr2C b) fields
   657     (fs :: [Doc]) <- mapM (\(Identifier a _, b) -> liftM (text "." <> text a <+> equals <+>) $ initExpr2C b) fields
   658     return $ lbrace $+$ (nest 4 . vcat . punctuate comma $ fs) $+$ rbrace
   658     return $ lbrace $+$ (nest 4 . vcat . punctuate comma $ fs) $+$ rbrace
   659 --initExpr2C' (InitArray [InitRecord fields]) = do
   659 --initExpr2C' (InitArray [InitRecord fields]) = do
   996             return $ o <> parens e
   996             return $ o <> parens e
   997         _ -> return $ text (op2C op) <> parens e
   997         _ -> return $ text (op2C op) <> parens e
   998 expr2C Null = return $ text "NULL"
   998 expr2C Null = return $ text "NULL"
   999 expr2C (CharCode a) = do
   999 expr2C (CharCode a) = do
  1000     modify(\s -> s{lastType = BTChar})
  1000     modify(\s -> s{lastType = BTChar})
  1001     return $ quotes $ text "\\x" <> text (showHex (read a) "")
  1001     return $ text "0x" <> text (showHex (read a) "")
  1002 expr2C (HexCharCode a) = if length a <= 2 then return $ quotes $ text "\\x" <> text (map toLower a) else expr2C $ HexNumber a
  1002 expr2C (HexCharCode a) = if length a <= 2 then return $ quotes $ text "\\x" <> text (map toLower a) else expr2C $ HexNumber a
  1003 expr2C (SetExpression ids) = mapM (id2C IOLookup) ids >>= return . parens . hcat . punctuate (text " | ")
  1003 expr2C (SetExpression ids) = mapM (id2C IOLookup) ids >>= return . parens . hcat . punctuate (text " | ")
  1004 
  1004 
  1005 expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "low" _))) = do
  1005 expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "low" _))) = do
  1006     e' <- liftM (map toLower . render) $ expr2C e
  1006     e' <- liftM (map toLower . render) $ expr2C e