on master help sign in
Print failed pattern match error messages to stderr
commitc614366f83a2821409f731572b755fb548a61556 authorBenjamin Saunders <besaunde@sfu.ca> dateTue 8 Oct 2013, 15:54 (13 years ago) parent7a43e68
2 files changed+8−4
llvm/defs.c+4 src/IRTS/CodegenLLVM.hs+4−4
llvm/defs.c+4
@@ -11,6 +11,10 @@ void putStr(const char *str) {
1111 fputs(str, stdout);
1212}
1313
14+void putErr(const char *str) {
15+ fputs(str, stderr);
16+}
17+
1418void mpz_init_set_ull(mpz_t n, unsigned long long ull)
1519{
1620 mpz_init_set_ui(n, (unsigned int)(ull >> 32)); /* n = (unsigned int)(ull >> 32) */
src/IRTS/CodegenLLVM.hs+4−4
@@ -193,7 +193,7 @@ initDefs tgt =
193193 , exfun "__idris_gmpFree" VoidType [ptrI8, intPtr] False
194194 , exfun "__idris_strRev" ptrI8 [ptrI8] False
195195 , exfun "strtoll" (IntegerType 64) [ptrI8, PointerType ptrI8 (AddrSpace 0), IntegerType 32] False
196− , exfun "putStr" VoidType [ptrI8] False
196+ , exfun "putErr" VoidType [ptrI8] False
197197 , exVar (stdinName tgt) ptrI8
198198 , exVar (stdoutName tgt) ptrI8
199199 , exVar (stderrName tgt) ptrI8
@@ -245,7 +245,7 @@ getStdErr = ConstantOperand . C.GlobalReference . Name . stderrName <$> asks tar
245245codegen :: Target -> [SDecl] -> Module
246246codegen tgt defs = Module "idris" (Just . dataLayout $ tgt) (Just . triple $ tgt) (initDefs tgt ++ globals ++ gendefs)
247247 where
248− (gendefs, _, globals) = runRWS (mapM cgDef defs) tgt 0
248+ (gendefs, _, globals) = runRWS (mapM cgDef defs) tgt initialMGS
249249
250250valueType :: Type
251251valueType = NamedTypeReference (Name "valTy")
@@ -538,7 +538,7 @@ cgExpr SNothing = return . Just . ConstantOperand $ nullValue
538538cgExpr (SError msg) = do
539539 str <- addGlobal' (ArrayType (2 + fromIntegral (length msg)) (IntegerType 8))
540540 (cgConst' (TT.Str (msg ++ "\n")))
541− inst' $ simpleCall "putStr" [ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0
541+ inst' $ simpleCall "putErr" [ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0
542542 , C.Int 32 0]]
543543 inst' Call { isTailCall = True
544544 , callingConvention = CC.C
@@ -810,7 +810,7 @@ addGlobal' ty val = do
810810ensureCDecl :: String -> FType -> [FType] -> Codegen Operand
811811ensureCDecl name rty argtys = do
812812 syms <- gets foreignSyms
813− unless (S.member name syms) $
813+ unless (S.member name syms) $ -- TODO: Perform a runtime check of declared type consistency here
814814 do addGlobal (ffunDecl name rty argtys)
815815 modify $ \s -> s { foreignSyms = S.insert name (foreignSyms s) }
816816 return $ ConstantOperand (C.GlobalReference (Name name))