Compute the maximum index M
used in a declaration.
We M
to initialize the fresh index generator used to create fresh
variable and join point names.
Recall that we variable and join points share the same namespace in our implementation.
@[reducible, inline]
Equations
Instances For
Equations
- Lean.IR.MaxIndex.instAndThenCollector = { andThen := fun (a : Lean.IR.MaxIndex.Collector) (b : Unit → Lean.IR.MaxIndex.Collector) => Lean.IR.MaxIndex.seq✝ a (b ()) }
Equations
- Lean.IR.MaxIndex.collectDecl (Lean.IR.Decl.fdecl f xs type b info) = Lean.IR.MaxIndex.collectParams✝ xs >> Lean.IR.MaxIndex.collectFnBody b
- Lean.IR.MaxIndex.collectDecl (Lean.IR.Decl.extern f xs type ext) = Lean.IR.MaxIndex.collectParams✝ xs
Instances For
Equations
- b.maxIndex = Lean.IR.MaxIndex.collectFnBody b 0
Instances For
Equations
- d.maxIndex = Lean.IR.MaxIndex.collectDecl d 0
Instances For
We say a variable (join point) index (aka name) is free in a function body
if there isn't a FnBody.vdecl
(Fnbody.jdecl
) binding it.
@[reducible, inline]
Instances For
Equations
- Lean.IR.FreeIndices.insertParams s ys = Array.foldl (fun (s : Lean.IR.IndexSet) (p : Lean.IR.Param) => Lean.RBTree.insert s p.x.idx) s ys
Instances For
Equations
- Lean.IR.FreeIndices.instAndThenCollector = { andThen := fun (a : Lean.IR.FreeIndices.Collector) (b : Unit → Lean.IR.FreeIndices.Collector) => Lean.IR.FreeIndices.seq✝ a (b ()) }
Equations
- b.collectFreeIndices vs = Lean.IR.FreeIndices.collectFnBody b ∅ vs
Instances For
Instances For
In principle, we can check whether a function body b
contains an index i
using
b.freeIndices.contains i
, but it is more efficient to avoid the construction
of the set of freeIndices and just search whether i
occurs in b
or not.
Equations
- Lean.IR.HasIndex.visitVar w x = (w == x.idx)
Instances For
Equations
- Lean.IR.HasIndex.visitJP w x = (w == x.idx)
Instances For
Equations
Instances For
Equations
- Lean.IR.HasIndex.visitArgs w xs = xs.any (Lean.IR.HasIndex.visitArg w)
Instances For
Equations
- Lean.IR.HasIndex.visitParams w ps = ps.any fun (p : Lean.IR.Param) => w == p.x.idx
Instances For
Equations
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.ctor i ys) = Lean.IR.HasIndex.visitArgs w ys
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.reset n x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.reuse x_1 i updtHeader ys) = (Lean.IR.HasIndex.visitVar w x_1 || Lean.IR.HasIndex.visitArgs w ys)
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.proj i x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.uproj i x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.sproj n offset x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.fap c ys) = Lean.IR.HasIndex.visitArgs w ys
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.pap c ys) = Lean.IR.HasIndex.visitArgs w ys
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.ap x_1 ys) = (Lean.IR.HasIndex.visitVar w x_1 || Lean.IR.HasIndex.visitArgs w ys)
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.box ty x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.unbox x_1) = Lean.IR.HasIndex.visitVar w x_1
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.lit v) = false
- Lean.IR.HasIndex.visitExpr w (Lean.IR.Expr.isShared x_1) = Lean.IR.HasIndex.visitVar w x_1
Instances For
Equations
- arg.hasFreeVar x = Lean.IR.HasIndex.visitArg x.idx arg
Instances For
Equations
- e.hasFreeVar x = Lean.IR.HasIndex.visitExpr x.idx e
Instances For
Equations
- b.hasFreeVar x = Lean.IR.HasIndex.visitFnBody x.idx b