[project @ 1998-12-21 10:45:36 by simonpj]
authorsimonpj <unknown>
Mon, 21 Dec 1998 10:45:36 +0000 (10:45 +0000)
committersimonpj <unknown>
Mon, 21 Dec 1998 10:45:36 +0000 (10:45 +0000)
Add utils/Panic.lhs

ghc/compiler/utils/Panic.lhs [new file with mode: 0644]

diff --git a/ghc/compiler/utils/Panic.lhs b/ghc/compiler/utils/Panic.lhs
new file mode 100644 (file)
index 0000000..c3e4865
--- /dev/null
@@ -0,0 +1,35 @@
+%
+% (c) The GRASP Project, Glasgow University, 1992-1998
+%
+\section{Panic error messages}
+
+Defines basic funtions for printing error messages.
+
+It's hard to put these functions anywhere else without causing
+some unnecessary loops in the module dependency graph.
+
+\begin{code}
+module Panic ( panic, panic#, assertPanic, trace ) where
+
+import GlaExts( trace )
+
+#include "HsVersions.h"
+\end{code}
+
+\begin{code}
+panic :: String -> a
+panic x = error ("panic! (the `impossible' happened):\n\t"
+             ++ x ++ "\n\n"
+             ++ "Please report it as a compiler bug "
+             ++ "to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\n" )
+
+-- #-versions because panic can't return an unboxed int, and that's
+-- what TAG_ is with GHC at the moment.  Ugh. (Simon)
+-- No, man -- Too Beautiful! (Will)
+
+panic# :: String -> FAST_INT
+panic# s = case (panic s) of () -> ILIT(0)
+
+assertPanic :: String -> Int -> a
+assertPanic file line = panic ("ASSERT failed! file " ++ file ++ ", line " ++ show line)
+\end{code}