File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ module Agda.Utils where
55
66import Control.Applicative ( liftA2 )
77import Data.Bifunctor ( second )
8+ import Data.Functor ( (<&>) )
89import Data.Maybe ( isJust , isNothing , catMaybes )
10+ import Data.Text ( Text )
911
1012import Agda.Compiler.Backend ( getUniqueCompilerPragma , PureTCM , HasConstInfo (getConstInfo ) )
1113import Agda.Syntax.Abstract.Name
@@ -31,11 +33,22 @@ import Agda.TypeChecking.Reduce (reduceDefCopy)
3133
3234-- * Miscellaneous
3335
36+ -- | Pragma string for the agda2lambox backend.
37+ agda2lamboxP :: Text
38+ agda2lamboxP = " AGDA2LAMBOX"
39+
3440pp :: Pretty a => a -> String
3541pp = prettyShow
3642
3743hasPragma :: QName -> TCM Bool
38- hasPragma qn = isJust <$> getUniqueCompilerPragma " AGDA2LAMBOX" qn
44+ hasPragma qn = isJust <$> getUniqueCompilerPragma agda2lamboxP qn
45+
46+ -- | Retrieve the additional info to a COMPILE pragma, if any
47+ getPragmaInfo :: QName -> TCM (Maybe String )
48+ getPragmaInfo qn =
49+ getUniqueCompilerPragma agda2lamboxP qn <&> \ case
50+ Nothing -> Nothing
51+ Just (CompilerPragma _ info) -> Just info
3952
4053isDataDef , isRecDef , isFunDef , isDataOrRecDef :: Defn -> Bool
4154isDataDef = \ case
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import Agda.TypeChecking.Pretty
1717import Agda.Utils.Monad ( ifM , ifNotM , orM )
1818import Agda.Utils.SmallSet qualified as SmallSet
1919
20- import Agda.Utils ( hasPragma , isDataOrRecDef , treeless , isArity )
20+ import Agda.Utils ( isDataOrRecDef , isArity , getPragmaInfo )
2121
2222import Agda2Lambox.Compile.Monad
2323import Agda2Lambox.Compile.Target
@@ -47,7 +47,13 @@ compile t qs = do
4747
4848compileDefinition :: Target t -> Definition -> CompileM (Maybe (GlobalDecl t ))
4949compileDefinition target defn@ Defn {.. } = setCurrentRange defName do
50- reportSDoc " agda2lambox.compile" 1 $ " Compiling definition: " <+> prettyTCM defName
50+ reportSDoc " agda2lambox.compile" 1 $ " Compiling definition:" <+> prettyTCM defName
51+
52+ -- retrieve compile annotation written in COMPILE pragma
53+ annotation <- liftTCM $ getPragmaInfo defName
54+
55+ reportSDoc " agda2lambox.compile" 1 $
56+ " Definition is annotated as such:" <+> prettyTCM annotation
5157
5258 -- we skip definitions introduced by module application
5359
You can’t perform that action at this time.
0 commit comments