Compare commits

...

2 Commits

Author SHA1 Message Date
Kim Morrison
2ebf07302d merge master 2024-07-09 01:25:20 +10:00
Kim Morrison
2fe968c0c0 chore: upstream ToExpr FilePath and compile_time_search_path% 2024-06-14 11:38:46 +10:00
4 changed files with 28 additions and 4 deletions

View File

@@ -106,6 +106,10 @@ instance : ToExpr Unit where
toExpr := fun _ => mkConst `Unit.unit
toTypeExpr := mkConst ``Unit
instance : ToExpr System.FilePath where
toExpr p := mkApp (mkConst ``System.FilePath.mk) (toExpr p.toString)
toTypeExpr := mkConst ``System.FilePath
private def Name.toExprAux (n : Name) : Expr :=
if isSimple n 0 then
mkStr n 0 #[]

View File

@@ -29,4 +29,5 @@ import Lean.Util.OccursCheck
import Lean.Util.HasConstCache
import Lean.Util.FileSetupInfo
import Lean.Util.Heartbeats
import Lean.Util.SearchPath
import Lean.Util.SafeExponentiation

View File

@@ -0,0 +1,23 @@
/-
Copyright (c) 2024 Lean FRO. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
prelude
import Lean.ToExpr
import Lean.Util.Path
import Lean.Elab.Term
open Lean
/--
Term elaborator that retrieves the current `SearchPath`.
Typical usage is `searchPathRef.set compile_time_search_path%`.
This must not be used in files that are potentially compiled on another machine and then imported.
(That is, if used in an imported file it will embed the search path from whichever machine
compiled the `.olean`.)
-/
elab "compile_time_search_path%" : term =>
return toExpr ( searchPathRef.get)

View File

@@ -22,7 +22,3 @@ def mkRelPathString (path : FilePath) : String :=
scoped instance : ToJson FilePath where
toJson path := toJson <| mkRelPathString path
scoped instance : ToExpr FilePath where
toExpr p := mkApp (mkConst ``System.FilePath.mk) (toExpr p.toString)
toTypeExpr := mkConst ``System.FilePath