feat: Pickle constants in goal state
This commit is contained in:
parent
c1f63af019
commit
fef7f1e2f3
|
@ -59,6 +59,12 @@ and then add the new constants.
|
||||||
def environmentPickle (env : Environment) (path : System.FilePath) : IO Unit :=
|
def environmentPickle (env : Environment) (path : System.FilePath) : IO Unit :=
|
||||||
Pantograph.pickle path (env.header.imports, env.constants.map₂)
|
Pantograph.pickle path (env.header.imports, env.constants.map₂)
|
||||||
|
|
||||||
|
def resurrectEnvironment
|
||||||
|
(imports : Array Import)
|
||||||
|
(map₂ : PHashMap Name ConstantInfo)
|
||||||
|
: IO Environment := do
|
||||||
|
let env ← importModules imports {} 0
|
||||||
|
env.replay (Std.HashMap.ofList map₂.toList)
|
||||||
/--
|
/--
|
||||||
Unpickle an `Environment` from disk.
|
Unpickle an `Environment` from disk.
|
||||||
|
|
||||||
|
@ -68,8 +74,7 @@ and then replace the new constants.
|
||||||
@[export pantograph_env_unpickle_m]
|
@[export pantograph_env_unpickle_m]
|
||||||
def environmentUnpickle (path : System.FilePath) : IO (Environment × CompactedRegion) := unsafe do
|
def environmentUnpickle (path : System.FilePath) : IO (Environment × CompactedRegion) := unsafe do
|
||||||
let ((imports, map₂), region) ← Pantograph.unpickle (Array Import × PHashMap Name ConstantInfo) path
|
let ((imports, map₂), region) ← Pantograph.unpickle (Array Import × PHashMap Name ConstantInfo) path
|
||||||
let env ← importModules imports {} 0
|
return (← resurrectEnvironment imports map₂, region)
|
||||||
return (← env.replay (Std.HashMap.ofList map₂.toList), region)
|
|
||||||
|
|
||||||
|
|
||||||
open Lean.Core in
|
open Lean.Core in
|
||||||
|
@ -88,7 +93,9 @@ def goalStatePickle (goalState : GoalState) (path : System.FilePath) : IO Unit :
|
||||||
savedState := {
|
savedState := {
|
||||||
term := {
|
term := {
|
||||||
meta := {
|
meta := {
|
||||||
core,
|
core := {
|
||||||
|
env, nextMacroScope, ngen, ..
|
||||||
|
},
|
||||||
meta,
|
meta,
|
||||||
}
|
}
|
||||||
«elab»,
|
«elab»,
|
||||||
|
@ -100,9 +107,10 @@ def goalStatePickle (goalState : GoalState) (path : System.FilePath) : IO Unit :
|
||||||
convMVar?,
|
convMVar?,
|
||||||
calcPrevRhs?,
|
calcPrevRhs?,
|
||||||
} := goalState
|
} := goalState
|
||||||
--let env := core.env
|
|
||||||
Pantograph.pickle path (
|
Pantograph.pickle path (
|
||||||
({ core with } : CompactCoreState),
|
env.constants.map₂,
|
||||||
|
|
||||||
|
({ nextMacroScope, ngen } : CompactCoreState),
|
||||||
meta,
|
meta,
|
||||||
«elab»,
|
«elab»,
|
||||||
tactic,
|
tactic,
|
||||||
|
@ -117,6 +125,8 @@ def goalStatePickle (goalState : GoalState) (path : System.FilePath) : IO Unit :
|
||||||
def goalStateUnpickle (path : System.FilePath) (env : Environment)
|
def goalStateUnpickle (path : System.FilePath) (env : Environment)
|
||||||
: IO (GoalState × CompactedRegion) := unsafe do
|
: IO (GoalState × CompactedRegion) := unsafe do
|
||||||
let ((
|
let ((
|
||||||
|
map₂,
|
||||||
|
|
||||||
compactCore,
|
compactCore,
|
||||||
meta,
|
meta,
|
||||||
«elab»,
|
«elab»,
|
||||||
|
@ -127,6 +137,8 @@ def goalStateUnpickle (path : System.FilePath) (env : Environment)
|
||||||
convMVar?,
|
convMVar?,
|
||||||
calcPrevRhs?,
|
calcPrevRhs?,
|
||||||
), region) ← Pantograph.unpickle (
|
), region) ← Pantograph.unpickle (
|
||||||
|
PHashMap Name ConstantInfo ×
|
||||||
|
|
||||||
CompactCoreState ×
|
CompactCoreState ×
|
||||||
Meta.State ×
|
Meta.State ×
|
||||||
Elab.Term.State ×
|
Elab.Term.State ×
|
||||||
|
@ -137,6 +149,7 @@ def goalStateUnpickle (path : System.FilePath) (env : Environment)
|
||||||
Option (MVarId × MVarId × List MVarId) ×
|
Option (MVarId × MVarId × List MVarId) ×
|
||||||
Option (MVarId × Expr)
|
Option (MVarId × Expr)
|
||||||
) path
|
) path
|
||||||
|
let env ← env.replay (Std.HashMap.ofList map₂.toList)
|
||||||
let goalState := {
|
let goalState := {
|
||||||
savedState := {
|
savedState := {
|
||||||
term := {
|
term := {
|
||||||
|
|
Loading…
Reference in New Issue