Literal -> Lit, LitE -> Lit
This commit is contained in:
@@ -123,7 +123,7 @@ Alter :: { Alter Name }
|
||||
Alter : litint ParList '->' Expr { Alter (AltData $1) $2 $4 }
|
||||
|
||||
Expr1 :: { Expr Name }
|
||||
Expr1 : litint { LitE $ IntL $1 }
|
||||
Expr1 : litint { Lit $ IntL $1 }
|
||||
| Id { Var $1 }
|
||||
| PackCon { $1 }
|
||||
| ExprPragma { $1 }
|
||||
|
||||
@@ -7,7 +7,7 @@ Description : Core ASTs and the like
|
||||
module Core.Syntax
|
||||
( Expr(..)
|
||||
, Type(..)
|
||||
, Literal(..)
|
||||
, Lit(..)
|
||||
, pattern (:$)
|
||||
, Binding(..)
|
||||
, AltCon(..)
|
||||
@@ -47,7 +47,7 @@ data Expr b = Var Name
|
||||
| Lam [b] (Expr b)
|
||||
| Let Rec [Binding b] (Expr b)
|
||||
| App (Expr b) (Expr b)
|
||||
| LitE Literal
|
||||
| Lit Lit
|
||||
| Type Type
|
||||
deriving (Show, Read, Lift)
|
||||
|
||||
@@ -87,11 +87,11 @@ data Rec = Rec
|
||||
deriving (Show, Read, Eq, Lift)
|
||||
|
||||
data AltCon = AltData Tag
|
||||
| AltLiteral Literal
|
||||
| AltLit Lit
|
||||
| Default
|
||||
deriving (Show, Read, Eq, Lift)
|
||||
|
||||
data Literal = IntL Int
|
||||
data Lit = IntL Int
|
||||
deriving (Show, Read, Eq, Lift)
|
||||
|
||||
type Name = String
|
||||
|
||||
@@ -32,7 +32,7 @@ rhssOf = fromList . fmap f
|
||||
|
||||
isAtomic :: Expr b -> Bool
|
||||
isAtomic (Var _) = True
|
||||
isAtomic (LitE _) = True
|
||||
isAtomic (Lit _) = True
|
||||
isAtomic _ = False
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
@@ -55,7 +55,7 @@ floatNonStrictCases g = goE
|
||||
where
|
||||
goE :: Expr' -> Floater Expr'
|
||||
goE (Var k) = pure (Var k)
|
||||
goE (LitE l) = pure (LitE l)
|
||||
goE (Lit l) = pure (Lit l)
|
||||
goE (Case e as) = pure (Case e as)
|
||||
goE (Let Rec bs e) = Let Rec <$> bs' <*> goE e
|
||||
where bs' = travBs goE bs
|
||||
@@ -77,7 +77,7 @@ floatNonStrictCases g = goE
|
||||
goC (f :$ x) = (:$) <$> goC f <*> goC x
|
||||
goC (Let r bs e) = Let r <$> bs' <*> goE e
|
||||
where bs' = travBs goC bs
|
||||
goC (LitE l) = pure (LitE l)
|
||||
goC (Lit l) = pure (Lit l)
|
||||
goC (Var k) = pure (Var k)
|
||||
goC (Con t as) = pure (Con t as)
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ buildInitialHeap (Program ss) = mapAccumL allocateSc mempty compiledScs
|
||||
f (NameKey n, _) = Just n
|
||||
f _ = Nothing
|
||||
|
||||
compileC _ (LitE l) = compileCL l
|
||||
compileC _ (Lit l) = compileCL l
|
||||
|
||||
-- >> [ref/compileC]
|
||||
compileC g (App f x) = compileC g x
|
||||
@@ -661,16 +661,16 @@ buildInitialHeap (Program ss) = mapAccumL allocateSc mempty compiledScs
|
||||
|
||||
compileC _ _ = error "yet to be implemented!"
|
||||
|
||||
compileCL :: Literal -> Code
|
||||
compileCL :: Lit -> Code
|
||||
compileCL (IntL n) = [PushInt n]
|
||||
|
||||
compileEL :: Literal -> Code
|
||||
compileEL :: Lit -> Code
|
||||
compileEL (IntL n) = [PushInt n]
|
||||
|
||||
-- compile an expression in a strict context such that a pointer to the
|
||||
-- expression is left on top of the stack in WHNF
|
||||
compileE :: Env -> Expr' -> Code
|
||||
compileE _ (LitE l) = compileEL l
|
||||
compileE _ (Lit l) = compileEL l
|
||||
compileE g (Let NonRec bs e) =
|
||||
-- we use compileE instead of compileC
|
||||
mconcat binders <> compileE g' e <> [Slide d]
|
||||
|
||||
Reference in New Issue
Block a user