@@ -13,6 +13,8 @@ import Agda.Utils
1313import Agda.Syntax.Literal
1414import Agda.Syntax.Abstract.Name ( QName (.. ), ModuleName (.. ) )
1515import Agda.Syntax.Common.Pretty ( prettyShow )
16+ import Agda.TypeChecking.Primitive.Base ( getBuiltinName )
17+ import Agda.Compiler.Backend ( builtinNat , builtinZero , builtinSuc )
1618
1719import LambdaBox
1820import qualified LambdaBox as L
@@ -50,7 +52,7 @@ instance A.TTerm ~> L.Term where
5052 A. Erased _ -> fail " Erased matches are not supported."
5153 A. NotErased _ -> do
5254 calts <- traverse go talts
53- cind <- go caseType
55+ cind <- go caseType
5456 return $ LCase cind 0 (LRel n) calts
5557 A. TUnit -> return LBox
5658 A. TSort -> return LBox
@@ -68,12 +70,25 @@ instance A.CaseType ~> L.Inductive where
6870 go = \ case
6971 A. CTData qn -> return $ L. Inductive (qnameToKerName qn) 0
7072 -- TODO(flupe): handle mutual inductive
73+
74+ -- Builtin Nat
75+ A. CTNat -> do
76+ liftTCM (getBuiltinName builtinNat) >>= \ case
77+ Nothing -> fail " Builtin Nat not bound."
78+ Just qn -> return $ L. Inductive (qnameToKerName qn) 0
79+
7180 _ -> fail " Not supported case type"
7281
7382-- TODO(flupe): handle using MetaCoq tPrim and prim_val
7483instance A. Literal ~> L. Term where
7584 go = \ case
76- LitNat n -> fail " Literal natural numbers not supported"
85+ LitNat n -> do
86+ Just qnat <- liftTCM $ getBuiltinName builtinNat
87+
88+ let indnat = L. Inductive (qnameToKerName qnat) 0
89+
90+ return $ (!! fromInteger n) $ iterate (LApp (LCtor indnat 1 [] )) (LCtor indnat 0 [] )
91+
7792 LitWord64 w -> fail " Literal int64 not supported"
7893 LitFloat f -> fail " Literal float not supported"
7994 LitString s -> fail " Literal string not supported"
0 commit comments