summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorSylvain Henry <hsyl20@gmail.com>2018-11-22 11:31:16 -0500
committerBen Gamari <ben@smart-cactus.org>2018-11-22 12:11:15 -0500
commit13bb4bf44e6e690133be334bbf0c63fcae5db34a (patch)
treeee7a9a9f60ca936b16cc15a46c758d4dc51abfd7 /compiler/ghci
parentf5fbecc85967218fd8ba6512f10eea2daf2812ac (diff)
downloadhaskell-13bb4bf44e6e690133be334bbf0c63fcae5db34a.tar.gz
Rename literal constructors
In a previous patch we replaced some built-in literal constructors (MachInt, MachWord, etc.) with a single LitNumber constructor. In this patch we replace the `Mach` prefix of the remaining constructors with `Lit` for consistency (e.g., LitChar, LitLabel, etc.). Sadly the name `LitString` was already taken for a kind of FastString and it would become misleading to have both `LitStr` (literal constructor renamed after `MachStr`) and `LitString` (FastString variant). Hence this patch renames the FastString variant `PtrString` (which is more accurate) and the literal string constructor now uses the least surprising `LitString` name. Both `Literal` and `LitString/PtrString` have recently seen breaking changes so doing this kind of renaming now shouldn't harm much. Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27, tdammers Subscribers: tdammers, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4881
Diffstat (limited to 'compiler/ghci')
-rw-r--r--compiler/ghci/ByteCodeAsm.hs20
-rw-r--r--compiler/ghci/ByteCodeGen.hs42
2 files changed, 31 insertions, 31 deletions
diff --git a/compiler/ghci/ByteCodeAsm.hs b/compiler/ghci/ByteCodeAsm.hs
index 4473a9e9b2..0776e406d6 100644
--- a/compiler/ghci/ByteCodeAsm.hs
+++ b/compiler/ghci/ByteCodeAsm.hs
@@ -441,18 +441,18 @@ assembleI dflags i = case i of
Op q, Op np]
where
- literal (MachLabel fs (Just sz) _)
+ literal (LitLabel fs (Just sz) _)
| platformOS (targetPlatform dflags) == OSMinGW32
= litlabel (appendFS fs (mkFastString ('@':show sz)))
-- On Windows, stdcall labels have a suffix indicating the no. of
-- arg words, e.g. foo@8. testcase: ffi012(ghci)
- literal (MachLabel fs _ _) = litlabel fs
- literal MachNullAddr = int 0
- literal (MachFloat r) = float (fromRational r)
- literal (MachDouble r) = double (fromRational r)
- literal (MachChar c) = int (ord c)
- literal (MachStr bs) = lit [BCONPtrStr bs]
- -- MachStr requires a zero-terminator when emitted
+ literal (LitLabel fs _ _) = litlabel fs
+ literal LitNullAddr = int 0
+ literal (LitFloat r) = float (fromRational r)
+ literal (LitDouble r) = double (fromRational r)
+ literal (LitChar c) = int (ord c)
+ literal (LitString bs) = lit [BCONPtrStr bs]
+ -- LitString requires a zero-terminator when emitted
literal (LitNumber nt i _) = case nt of
LitNumInt -> int (fromIntegral i)
LitNumWord -> int (fromIntegral i)
@@ -460,10 +460,10 @@ assembleI dflags i = case i of
LitNumWord64 -> int64 (fromIntegral i)
LitNumInteger -> panic "ByteCodeAsm.literal: LitNumInteger"
LitNumNatural -> panic "ByteCodeAsm.literal: LitNumNatural"
- -- We can lower 'RubbishLit' to an arbitrary constant, but @NULL@ is most
+ -- We can lower 'LitRubbish' to an arbitrary constant, but @NULL@ is most
-- likely to elicit a crash (rather than corrupt memory) in case absence
-- analysis messed up.
- literal RubbishLit = int 0
+ literal LitRubbish = int 0
litlabel fs = lit [BCONPtrLbl fs]
addr (RemotePtr a) = words [fromIntegral a]
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
index e723258910..113690780b 100644
--- a/compiler/ghci/ByteCodeGen.hs
+++ b/compiler/ghci/ByteCodeGen.hs
@@ -998,9 +998,9 @@ doCase d s p (_,scrut) bndr alts is_unboxed_tuple
my_discr (LitAlt l, _, _)
= case l of LitNumber LitNumInt i _ -> DiscrI (fromInteger i)
LitNumber LitNumWord w _ -> DiscrW (fromInteger w)
- MachFloat r -> DiscrF (fromRational r)
- MachDouble r -> DiscrD (fromRational r)
- MachChar i -> DiscrI (ord i)
+ LitFloat r -> DiscrF (fromRational r)
+ LitDouble r -> DiscrD (fromRational r)
+ LitChar i -> DiscrI (ord i)
_ -> pprPanic "schemeE(AnnCase).my_discr" (ppr l)
maybe_ncons
@@ -1200,7 +1200,7 @@ generateCCall d0 s p (CCallSpec target cconv safety) fn args_r_to_l
StaticTarget _ _ _ False ->
panic "generateCCall: unexpected FFI value import"
StaticTarget _ target _ True ->
- Just (MachLabel target mb_size IsFunction)
+ Just (LitLabel target mb_size IsFunction)
where
mb_size
| OSMinGW32 <- platformOS (targetPlatform dflags)
@@ -1300,13 +1300,13 @@ primRepToFFIType dflags r
mkDummyLiteral :: DynFlags -> PrimRep -> Literal
mkDummyLiteral dflags pr
= case pr of
- IntRep -> mkMachInt dflags 0
- WordRep -> mkMachWord dflags 0
- Int64Rep -> mkMachInt64 0
- Word64Rep -> mkMachWord64 0
- AddrRep -> MachNullAddr
- DoubleRep -> MachDouble 0
- FloatRep -> MachFloat 0
+ IntRep -> mkLitInt dflags 0
+ WordRep -> mkLitWord dflags 0
+ Int64Rep -> mkLitInt64 0
+ Word64Rep -> mkLitWord64 0
+ AddrRep -> LitNullAddr
+ DoubleRep -> LitDouble 0
+ FloatRep -> LitFloat 0
_ -> pprPanic "mkDummyLiteral" (ppr pr)
@@ -1423,7 +1423,7 @@ implement_tagToId d s p arg names
slide_ws = bytesToWords dflags (d - s + arg_bytes)
return (push_arg
- `appOL` unitOL (PUSH_UBX MachNullAddr 1)
+ `appOL` unitOL (PUSH_UBX LitNullAddr 1)
-- Push bogus word (see Note [Implementing tagToEnum#])
`appOL` concatOL steps
`appOL` toOL [ LABEL label_fail, CASEFAIL,
@@ -1507,7 +1507,7 @@ pushAtom d p (AnnVar var)
= do topStrings <- getTopStrings
dflags <- getDynFlags
case lookupVarEnv topStrings var of
- Just ptr -> pushAtom d p $ AnnLit $ mkMachWord dflags $
+ Just ptr -> pushAtom d p $ AnnLit $ mkLitWord dflags $
fromIntegral $ ptrToWordPtr $ fromRemotePtr ptr
Nothing -> do
let sz = idSizeCon dflags var
@@ -1523,12 +1523,13 @@ pushAtom _ _ (AnnLit lit) = do
wordsToBytes dflags size_words)
case lit of
- MachLabel _ _ _ -> code N
- MachFloat _ -> code F
- MachDouble _ -> code D
- MachChar _ -> code N
- MachNullAddr -> code N
- MachStr _ -> code N
+ LitLabel _ _ _ -> code N
+ LitFloat _ -> code F
+ LitDouble _ -> code D
+ LitChar _ -> code N
+ LitNullAddr -> code N
+ LitString _ -> code N
+ LitRubbish -> code N
LitNumber nt _ _ -> case nt of
LitNumInt -> code N
LitNumWord -> code N
@@ -1539,7 +1540,6 @@ pushAtom _ _ (AnnLit lit) = do
-- representation.
LitNumInteger -> panic "pushAtom: LitInteger"
LitNumNatural -> panic "pushAtom: LitNatural"
- RubbishLit -> code N
pushAtom _ _ expr
= pprPanic "ByteCodeGen.pushAtom"
@@ -1552,7 +1552,7 @@ pushAtom _ _ expr
pushConstrAtom
:: StackDepth -> BCEnv -> AnnExpr' Id DVarSet -> BcM (BCInstrList, ByteOff)
-pushConstrAtom _ _ (AnnLit lit@(MachFloat _)) =
+pushConstrAtom _ _ (AnnLit lit@(LitFloat _)) =
return (unitOL (PUSH_UBX32 lit), 4)
pushConstrAtom d p (AnnVar v)