File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,23 @@ structure TrivialStructureInfo where
3535 fieldIdx : Nat
3636 deriving Inhabited, Repr
3737
38+ builtin_initialize trivialStructureInfoExt : CacheExtension Name (Option TrivialStructureInfo) ←
39+ CacheExtension.register
40+
3841/--
3942Return `some fieldIdx` if `declName` is the name of an inductive datatype s.t.
4043- It does not have builtin support in the runtime.
4144- It has only one constructor.
4245- This constructor has only one computationally relevant field.
4346 -/
4447def hasTrivialStructure? (declName : Name) : CoreM (Option TrivialStructureInfo) := do
48+ match (← trivialStructureInfoExt.find? declName) with
49+ | some info? => return info?
50+ | none =>
51+ let info? ← fillCache
52+ trivialStructureInfoExt.insert declName info?
53+ return info?
54+ where fillCache : CoreM (Option TrivialStructureInfo) := do
4555 if isRuntimeBultinType declName then return none
4656 let .inductInfo info ← getConstInfo declName | return none
4757 if info.isUnsafe || info.isRec then return none
You can’t perform that action at this time.
0 commit comments