on master help sign in
String manipulation
commit6d776ddb500e6b6b476b60898fbd87b4e812ff74 authorBenjamin Saunders <besaunde@sfu.ca> dateWed 26 Jun 2013, 20:48 (13 years ago) parente61506f
1 file changed+14−2
src/IRTS/CodegenLLVM.hs+14−2
src/IRTS/CodegenLLVM.hs+14−2
@@ -142,7 +142,7 @@ initDefs tgt =
142142 , exfun "mpz_get_ull" (IntegerType 64) [pmpz] False
143143 , exfun "mpz_init_set_ull" VoidType [pmpz, IntegerType 64] False
144144 , exfun "mpz_init_set_sll" VoidType [pmpz, IntegerType 64] False
145− , exfun "__idris_strCons" (IntegerType 8) [IntegerType 8, PointerType (IntegerType 8) (AddrSpace 0)] False
145+ , exfun "__idris_strCons" ptrI8 [IntegerType 8, ptrI8] False
146146 , GlobalDefinition mainDef
147147 ] ++ map mpzBinFun ["add", "sub", "mul", "fdiv_q", "fdiv_r", "and", "ior", "xor"]
148148 where
@@ -814,9 +814,21 @@ cgOp LStrConcat [x,y] = cgStrCat x y
814814cgOp LStrCons [c,s] = do
815815 nc <- unbox FChar c
816816 ns <- unbox FString s
817− r <- inst $ simpleCall "__idris_strCons" [nc, ns]
817+ nc' <- inst $ Trunc nc (IntegerType 8) []
818+ r <- inst $ simpleCall "__idris_strCons" [nc', ns]
818819 box FString r
819820
821+cgOp LStrHead [c] = do
822+ s <- unbox FString c
823+ c <- inst $ Load False s Nothing 0 []
824+ c' <- inst $ ZExt c (IntegerType 32) []
825+ box FChar c'
826+
827+cgOp LStrTail [c] = do
828+ s <- unbox FString c
829+ c <- inst $ GetElementPtr True s [ConstantOperand $ C.Int 32 1] []
830+ box FString c
831+
820832cgOp prim args = ierror $ "Unimplemented primitive: [" ++ show prim ++ "]("
821833 ++ intersperse ',' (take (length args) ['a'..]) ++ ")"
822834