diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-04-22 20:07:28 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-04-23 20:24:10 +0100 |
commit | dbd964513941f1247ff6cbf28ad3154b229ecb00 (patch) | |
tree | 5dc1809630edb83216b59f06b59f6f404d7a4253 /compiler | |
parent | b49307f5b69a3ee9c7d1bcaf9d0dec3c9b3c2440 (diff) | |
download | haskell-dbd964513941f1247ff6cbf28ad3154b229ecb00.tar.gz |
Small refactoring in StgCmmExtCode
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/codeGen/StgCmmExtCode.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/codeGen/StgCmmExtCode.hs b/compiler/codeGen/StgCmmExtCode.hs index 2c36442639..5057f1c8c4 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. |