From 206149f17917149b8dba9478ccf0b6225f6b1965 Mon Sep 17 00:00:00 2001 From: David Terei Date: Mon, 5 Jul 2010 16:13:08 +0000 Subject: [PATCH] LLVM: Add a literal NULL value to binding Patch from Erik de Castro Lopo . --- compiler/llvmGen/Llvm/Types.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs index af2ae9e..d37feab 100644 --- a/compiler/llvmGen/Llvm/Types.hs +++ b/compiler/llvmGen/Llvm/Types.hs @@ -99,6 +99,8 @@ data LlvmLit = LMIntLit Integer LlvmType -- | Floating point literal | LMFloatLit Double LlvmType + -- | Literal NULL, only applicable to pointer types + | LMNullLit LlvmType deriving (Eq) instance Show LlvmLit where @@ -205,6 +207,7 @@ getLit (LMIntLit i _) = show ((fromInteger i)::Int) getLit (LMFloatLit r LMFloat ) = fToStr $ realToFrac r getLit (LMFloatLit r LMDouble) = dToStr r getLit f@(LMFloatLit _ _) = error $ "Can't print this float literal!" ++ show f +getLit (LMNullLit _) = "null" -- | Return the 'LlvmType' of the 'LlvmVar' getVarType :: LlvmVar -> LlvmType @@ -217,6 +220,7 @@ getVarType (LMLitVar l ) = getLitType l getLitType :: LlvmLit -> LlvmType getLitType (LMIntLit _ t) = t getLitType (LMFloatLit _ t) = t +getLitType (LMNullLit t) = t -- | Return the 'LlvmType' of the 'LlvmStatic' getStatType :: LlvmStatic -> LlvmType -- 1.7.10.4