@@ -48,6 +48,7 @@ import Agda.Compiler.Treeless.AsPatterns
4848import Agda.Compiler.Treeless.Builtin
4949import Agda.Compiler.Treeless.Erase
5050import Agda.Compiler.Treeless.Identity
51+ import Agda.Compiler.Treeless.Simplify
5152import Agda.Compiler.Treeless.Uncase
5253import Agda.Compiler.Treeless.Unused
5354import Agda.Compiler.Treeless.NormalizeNames
@@ -85,7 +86,7 @@ getCompiledClauses q = do
8586 reportSDoc " treeless.convert" 70 $
8687 caseMaybe mst " -- not using split tree" $ \ st ->
8788 " -- using split tree" $$ pretty st
88- CC. compileClauses' translate cs mst
89+ CC. compileClauses' q translate cs mst
8990
9091-- ** Types of pipelines; different backends might use their own custom pipeline.
9192type BuildPipeline = Int -> QName -> Pipeline
@@ -109,7 +110,7 @@ data CCSubst = EraseUnused | IgnoreUnused deriving Eq
109110data CCEnv = CCEnv
110111 { ccCxt :: CCContext
111112 -- ^ Maps case tree de-bruijn indices to TTerm de-bruijn indices.
112- , ccCatchAll :: Maybe Int
113+ , ccCatchall :: Maybe Int
113114 -- ^ TTerm de-bruijn index of the current catch all.
114115 -- If an inner case has no catch-all clause, we use the one from its parent.
115116 , ccEvaluation :: EvaluationStrategy
@@ -124,7 +125,7 @@ type CCConfig = (EvaluationStrategy, CCSubst)
124125initCCEnv :: CCConfig -> CCEnv
125126initCCEnv (eval, su) = CCEnv
126127 { ccCxt = []
127- , ccCatchAll = Nothing
128+ , ccCatchall = Nothing
128129 , ccEvaluation = eval
129130 , ccSubstUnused = su
130131 }
@@ -286,14 +287,14 @@ casetree cc = do
286287 CC. Case _ (CC. Branches True _ _ _ Just {} _ _) -> __IMPOSSIBLE__
287288 CC. Case (Arg _ n) (CC. Branches True conBrs _ _ Nothing _ _) -> lambdasUpTo n $ do
288289 mkRecord =<< traverse casetree (CC. content <$> conBrs)
289- CC. Case (Arg i n) (CC. Branches False conBrs etaBr litBrs catchAll _ lazy) -> lambdasUpTo (n + 1 ) $ do
290+ CC. Case (Arg i n) (CC. Branches False conBrs etaBr litBrs catchall _ lazy) -> lambdasUpTo (n + 1 ) $ do
290291 -- re #3733 TODO: revise when compiling --cubical
291292 conBrs <- fmap Map. fromList $ filterM (isConstructor . fst ) (Map. toList conBrs)
292293 -- We can treat eta-matches as regular matches here.
293294 let conBrs' = caseMaybe etaBr conBrs $ \ (c, br) -> Map. insertWith (\ new old -> old) (conName c) br conBrs
294295 if Map. null conBrs' && Map. null litBrs then do
295296 -- there are no branches, just return default
296- updateCatchAll catchAll fromCatchAll
297+ updateCatchall catchall fromCatchall
297298 else do
298299 -- Get the type of the scrutinee.
299300 caseTy <-
@@ -311,9 +312,9 @@ casetree cc = do
311312 ([] , LitQName _ : _) -> return C. CTQName
312313 _ -> __IMPOSSIBLE__
313314
314- updateCatchAll catchAll $ do
315+ updateCatchall catchall $ do
315316 x <- asks (lookupLevel n . ccCxt)
316- def <- fromCatchAll
317+ def <- fromCatchall
317318 let caseInfo = C. CaseInfo
318319 { caseType = caseTy
319320 , caseLazy = lazy
@@ -327,8 +328,8 @@ casetree cc = do
327328 where
328329 -- normally, Agda should make sure that a pattern match is total,
329330 -- so we set the default to unreachable if no default has been provided.
330- fromCatchAll :: CC C. TTerm
331- fromCatchAll = asks (maybe C. tUnreachable C. TVar . ccCatchAll )
331+ fromCatchall :: CC C. TTerm
332+ fromCatchall = asks (maybe C. tUnreachable C. TVar . ccCatchall )
332333
333334commonArity :: CC. CompiledClauses -> Int
334335commonArity cc =
@@ -349,21 +350,21 @@ commonArity cc =
349350
350351 wArities cxt (WithArity k c) = map (\ x -> x - k + 1 ) $ arities (cxt - 1 + k) c
351352
352- updateCatchAll :: Maybe CC. CompiledClauses -> (CC C. TTerm -> CC C. TTerm )
353- updateCatchAll Nothing cont = cont
354- updateCatchAll (Just cc) cont = do
353+ updateCatchall :: Maybe CC. CompiledClauses -> (CC C. TTerm -> CC C. TTerm )
354+ updateCatchall Nothing cont = cont
355+ updateCatchall (Just cc) cont = do
355356 def <- casetree cc
356357 cxt <- asks ccCxt
357358 reportS " treeless.convert.lambdas" 40 $
358- [ " -- updateCatchAll :"
359+ [ " -- updateCatchall :"
359360 , " -- cxt =" <+> prettyPure cxt
360361 , " -- def =" <+> prettyPure def
361362 ]
362- local (\ e -> e { ccCatchAll = Just 0 , ccCxt = shift 1 cxt }) $ do
363+ local (\ e -> e { ccCatchall = Just 0 , ccCxt = shift 1 cxt }) $ do
363364 C. mkLet def <$> cont
364365
365366-- | Shrinks or grows the context to the given size.
366- -- Does not update the catchAll expression, the catchAll expression
367+ -- Does not update the catchall expression, the catchall expression
367368-- MUST NOT be used inside `cont`.
368369withContextSize :: Int -> CC C. TTerm -> CC C. TTerm
369370withContextSize n cont = do
@@ -430,8 +431,8 @@ withContextSize n cont = do
430431 cont <&> (`C.mkTApp` map C. TVar (downFrom diff'))
431432
432433-- | Prepend the given positive number of lambdas.
433- -- Does not update the catchAll expression,
434- -- the catchAll expression must be updated separately (or not be used).
434+ -- Does not update the catchall expression,
435+ -- the catchall expression must be updated separately (or not be used).
435436createLambdas :: Int -> CC C. TTerm -> CC C. TTerm
436437createLambdas diff cont = do
437438 unless (diff >= 1 ) __IMPOSSIBLE__
@@ -446,30 +447,30 @@ createLambdas diff cont = do
446447 cont <&> \ t -> List. iterate C. TLam t !! diff
447448
448449-- | Adds lambdas until the context has at least the given size.
449- -- Updates the catchAll expression to take the additional lambdas into account.
450+ -- Updates the catchall expression to take the additional lambdas into account.
450451lambdasUpTo :: Int -> CC C. TTerm -> CC C. TTerm
451452lambdasUpTo n cont = do
452453 diff <- asks (((n - ) . length ) . ccCxt)
453454
454455 if diff <= 0 then cont -- no new lambdas needed
455456 else do
456457 createLambdas diff $ do
457- asks ccCatchAll >>= \ case
458- Just catchAll -> do
458+ asks ccCatchall >>= \ case
459+ Just catchall -> do
459460 cxt <- asks ccCxt
460461 reportS " treeless.convert.lambdas" 40 $
461462 [ " lambdasUpTo: n =" <+> (text . show ) n
462463 , " diff =" <+> (text . show ) n
463- , " catchAll =" <+> prettyPure catchAll
464+ , " catchall =" <+> prettyPure catchall
464465 , " ccCxt =" <+> prettyPure cxt
465466 ]
466467 -- the catch all doesn't know about the additional lambdas, so just directly
467468 -- apply it again to the newly introduced lambda arguments.
468469 -- we also bind the catch all to a let, to avoid code duplication
469- local (\ e -> e { ccCatchAll = Just 0
470+ local (\ e -> e { ccCatchall = Just 0
470471 , ccCxt = shift 1 cxt }) $ do
471- let catchAllArgs = map C. TVar $ downFrom diff
472- C. mkLet (C. mkTApp (C. TVar $ catchAll + diff) catchAllArgs )
472+ let catchallArgs = map C. TVar $ downFrom diff
473+ C. mkLet (C. mkTApp (C. TVar $ catchall + diff) catchallArgs )
473474 <$> cont
474475 Nothing -> cont
475476
@@ -499,7 +500,7 @@ replaceVar x n cont = do
499500 (ys, _: zs) = splitAt i cxt
500501 -- compute the de-bruijn indexes of the newly inserted variables
501502 ixs = [0 .. (n - 1 )]
502- local (\ e -> e { ccCxt = upd (ccCxt e) , ccCatchAll = (+ n) <$> ccCatchAll e }) $
503+ local (\ e -> e { ccCxt = upd (ccCxt e) , ccCatchall = (+ n) <$> ccCatchall e }) $
503504 cont
504505
505506
@@ -651,4 +652,3 @@ substArgs = traverse substArg
651652substArg :: Arg I. Term -> CC C. TTerm
652653substArg x | usableModality x = substTerm (unArg x)
653654 | otherwise = return C. TErased
654-
0 commit comments