[commit: ghc] master: Small refactoring in StgCmmExtCode (dbd9645)

Ian Lynagh igloo at earth.li
Wed Apr 24 04:00:32 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/dbd964513941f1247ff6cbf28ad3154b229ecb00

>---------------------------------------------------------------

commit dbd964513941f1247ff6cbf28ad3154b229ecb00
Author: Ian Lynagh <ian at well-typed.com>
Date:   Mon Apr 22 20:07:28 2013 +0100

    Small refactoring in StgCmmExtCode

>---------------------------------------------------------------

 compiler/codeGen/StgCmmExtCode.hs | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/compiler/codeGen/StgCmmExtCode.hs b/compiler/codeGen/StgCmmExtCode.hs
index 2c36442..5057f1c 100644
--- a/compiler/codeGen/StgCmmExtCode.hs
+++ b/compiler/codeGen/StgCmmExtCode.hs
@@ -103,16 +103,18 @@ getEnv :: CmmParse Env
 getEnv  = EC $ \e s -> return (s, e)
 
 
+addDecl :: FastString -> Named -> ExtCode
+addDecl name named = EC $ \_ s -> return ((name, named) : s, ())
+
+
 -- | Add a new variable to the list of local declarations. 
 --      The CmmExpr says where the value is stored. 
 addVarDecl :: FastString -> CmmExpr -> ExtCode
-addVarDecl var expr 
-        = EC $ \_ s -> return ((var, VarN expr):s, ())
+addVarDecl var expr = addDecl var (VarN expr)
 
 -- | Add a new label to the list of local declarations.
 addLabel :: FastString -> BlockId -> ExtCode
-addLabel name block_id 
-        = EC $ \_ s -> return ((name, LabelN block_id):s, ())
+addLabel name block_id = addDecl name (LabelN block_id)
 
 
 -- | Create a fresh local variable of a given type.
@@ -144,8 +146,7 @@ newFunctionName
         -> PackageId    -- ^ package of the current module
         -> ExtCode
         
-newFunctionName name pkg
-        = EC $ \_ s -> return ((name, FunN pkg):s, ())
+newFunctionName name pkg = addDecl name (FunN pkg)
         
         
 -- | Add an imported foreign label to the list of local declarations.





More information about the ghc-commits mailing list