File tree Expand file tree Collapse file tree 6 files changed +48
-9
lines changed
Transformations/ExtendedSyntax Expand file tree Collapse file tree 6 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ instance FoldNames Val where
2525
2626instance FoldNames BPat where
2727 foldNames f = \ case
28- VarPat v -> f v
29- AsPat v val -> f v <> foldNames f val
28+ VarPat v -> f v
29+ AsPat t vs v -> f v <> foldNames ( ConstTagNode t vs)
3030
3131
3232instance FoldNames CPat where
Original file line number Diff line number Diff line change @@ -310,8 +310,8 @@ lint warningKinds mTypeEnv exp@(Program exts _) =
310310 when (isn't _OnlyVarPat bPat) $ do
311311 forM_ mTypeEnv $ \ typeEnv -> do
312312 fromMaybe (pure () ) $ case bPat of
313- AsPat v val -> do -- Maybe
314- expectedPatType <- normalizeType <$> mTypeOfValTE typeEnv val
313+ AsPat tag fields v -> do -- Maybe
314+ expectedPatType <- normalizeType <$> mTypeOfValTE typeEnv ( ConstTagNode tag fields)
315315 lhsType <- normalizeType <$> extract leftExp
316316 pure $ do -- Lint
317317 -- NOTE: This can still give false positive errors, because bottom-up typing can only approximate the result of HPT.
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ convert = second (view nametable) . flip runState emptyNS . cata build where
8686 ProgramF es defs -> Program <$> mapM external es <*> sequence defs
8787 DefF fn ps body -> Def <$> (nameToIdx fn) <*> (mapM nameToIdx ps) <*> body
8888 EBindF l (VarPat v) r -> EBind <$> l <*> (VarPat <$> nameToIdx v) <*> r
89- EBindF l (AsPat var val ) r -> EBind <$> l <*> (AsPat <$> nameToIdx var <*> value val ) <*> r
89+ EBindF l (AsPat t vars v ) r -> EBind <$> l <*> (AsPat <$> tag t <*> mapM nameToIdx vars <*> nameToIdx v ) <*> r
9090 ECaseF v alts -> ECase <$> nameToIdx v <*> sequence alts
9191 SAppF v ps -> SApp <$> nameToIdx v <*> (mapM nameToIdx ps)
9292 SReturnF v -> SReturn <$> value v
@@ -107,7 +107,7 @@ restore (exp, nt) = cata build exp where
107107 ProgramF es defs -> Program (map rexternal es) defs
108108 DefF fn ps body -> Def (rname fn) (map rname ps) body
109109 EBindF l (VarPat v) r -> EBind l (VarPat $ rname v) r
110- EBindF l (AsPat var val ) r -> EBind l (AsPat (rname var ) (rvalue val )) r
110+ EBindF l (AsPat t vs v ) r -> EBind l (AsPat (rtag t) ( map rname vs ) (rname v )) r
111111 ECaseF v alts -> ECase (rname v) alts
112112 SAppF v ps -> SApp (rname v) (map rname ps)
113113 SReturnF v -> SReturn (rvalue v)
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ instance Pretty Lit where
144144
145145instance Pretty BPat where
146146 pretty = \ case
147- VarPat v -> pretty v
148- AsPat v pat -> pretty pat <+> pretty ' @' <+> pretty v
147+ VarPat v -> pretty v
148+ AsPat tag fields v -> pretty ( ConstTagNode tag fields) <+> pretty ' @' <+> pretty v
149149
150150instance Pretty CPat where
151151 pretty = \ case
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ statistics = cata $ \case
6767 e -> Data.Foldable. fold e
6868
6969tagInBPat :: BPat -> Set. Set Tag
70- tagInBPat (AsPat var ( ConstTagNode t _) ) = Set. singleton t
70+ tagInBPat (AsPat t _ _ ) = Set. singleton t
7171tagInBPat _ = mempty
7272
7373
Original file line number Diff line number Diff line change 1+ easy (without type env):
2+ - DONE: evaluated case elimination
3+ - DONE: trivial case elimination
4+ - DONE: update elimination
5+ - constant propagation
6+
7+
8+ easy (with type env):
9+ - non-shared elimination
10+ - DONE: CSE
11+ - SDFE, SDVE, SDPE
12+ - SCO
13+ - DFE, DPE
14+
15+ medium:
16+ - case copy propagation
17+ - copy propagation
18+ - DVE
19+ - dead data elimination
20+
21+ moderate:
22+ - case hoisting
23+ - inlining
24+
25+ hard:
26+ - arity raising
27+ - generalized unboxing
28+
29+ DONE: investigate update elimination vs CSE
30+
31+ Branches:
32+
33+ [x] 32-conversion-fix
34+ [ ] 32-alt-remove-unnamed
35+ [ ] 32-alt-analyses
36+ [ ] 32-trf-cse
37+ [ ] 32-trf-case-elims
38+
39+ [ ] 32-trf-copy-propagation
You can’t perform that action at this time.
0 commit comments