feat: add instantiateLCtxMVars and instantiateMVarDeclMVars
This commit is contained in:
parent
b0298697c5
commit
0c9107fc72
2 changed files with 21 additions and 1 deletions
|
|
@ -59,7 +59,7 @@ mkFVar decl.fvarId
|
|||
end LocalDecl
|
||||
|
||||
structure LocalContext :=
|
||||
(fvarIdToDecl : PersistentHashMap Name LocalDecl := {})
|
||||
(fvarIdToDecl : PersistentHashMap FVarId LocalDecl := {})
|
||||
(decls : PersistentArray (Option LocalDecl) := {})
|
||||
|
||||
namespace LocalContext
|
||||
|
|
|
|||
|
|
@ -546,6 +546,26 @@ def instantiateMVars (mctx : MetavarContext) (e : Expr) : Expr × MetavarContext
|
|||
if !e.hasMVar then (e, mctx)
|
||||
else (WithHashMapCache.toState $ InstantiateExprMVars.main e).run mctx
|
||||
|
||||
def instantiateLCtxMVars (mctx : MetavarContext) (lctx : LocalContext) : LocalContext × MetavarContext :=
|
||||
lctx.foldl
|
||||
(fun (result : LocalContext × MetavarContext) ldecl =>
|
||||
let (lctx, mctx) := result;
|
||||
match ldecl with
|
||||
| LocalDecl.cdecl _ fvarId userName type bi =>
|
||||
let (type, mctx) := mctx.instantiateMVars type;
|
||||
(lctx.mkLocalDecl fvarId userName type bi, mctx)
|
||||
| LocalDecl.ldecl _ fvarId userName type value =>
|
||||
let (type, mctx) := mctx.instantiateMVars type;
|
||||
let (value, mctx) := mctx.instantiateMVars value;
|
||||
(lctx.mkLetDecl fvarId userName type value, mctx))
|
||||
({}, mctx)
|
||||
|
||||
def instantiateMVarDeclMVars (mctx : MetavarContext) (mvarId : MVarId) : MetavarContext :=
|
||||
let mvarDecl := mctx.getDecl mvarId;
|
||||
let (lctx, mctx) := mctx.instantiateLCtxMVars mvarDecl.lctx;
|
||||
let (type, mctx) := mctx.instantiateMVars mvarDecl.type;
|
||||
{ decls := mctx.decls.insert mvarId { lctx := lctx, type := type, .. mvarDecl }, .. mctx }
|
||||
|
||||
namespace DependsOn
|
||||
|
||||
private abbrev M := StateM ExprSet
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue