- adhoc: Lean.Name → Lean.ExternEntry
- inline: Lean.Name → String → Lean.ExternEntry
- standard: Lean.Name → String → Lean.ExternEntry
- foreign: Lean.Name → String → Lean.ExternEntry
Equations
- Lean.instInhabitedExternAttrData = { default := { arity? := default, entries := default } }
@[extern lean_add_extern]
Equations
Equations
- Lean.expandExternPatternAux args 0 x x = x
- Lean.expandExternPatternAux args (Nat.succ i) x x = if ¬String.Iterator.hasNext x = true then x else let c := String.Iterator.curr x; if c ≠ Char.ofNat 35 then Lean.expandExternPatternAux args i (String.Iterator.next x) (String.push x c) else let it := String.Iterator.next x; let x := Lean.parseOptNum (String.Iterator.remainingBytes it) it 0; let j := x.2 - 1; Lean.expandExternPatternAux args i x.1 (x ++ List.getD args j "")
Equations
- Lean.expandExternPattern pattern args = Lean.expandExternPatternAux args (String.length pattern) (String.mkIterator pattern) ""
Equations
- Lean.mkSimpleFnCall fn args = fn ++ "(" ++ List.foldl (fun a a_1 => a ++ a_1) "" (List.intersperse ", " args) ++ ")"
Equations
- Lean.ExternEntry.backend x = match x with | Lean.ExternEntry.adhoc n => n | Lean.ExternEntry.inline n x => n | Lean.ExternEntry.standard n x => n | Lean.ExternEntry.foreign n x => n
Equations
- Lean.getExternEntryForAux backend [] = none
- Lean.getExternEntryForAux backend (e :: es) = if (Lean.ExternEntry.backend e == `all) = true then some e else if (Lean.ExternEntry.backend e == backend) = true then some e else Lean.getExternEntryForAux backend es
Equations
- Lean.getExternEntryFor d backend = Lean.getExternEntryForAux backend d.entries
Equations
- Lean.isExtern env fn = Option.isSome (Lean.getExternAttrData env fn)
Equations
- Lean.isExternC env fn = match Lean.getExternAttrData env fn with | some { arity? := x_1, entries := [Lean.ExternEntry.standard (Lean.Name.str Lean.Name.anonymous "all" x_2) x] } => true | x => false
Equations
- Lean.getExternNameFor env backend fn = OptionM.run do let data ← Lean.getExternAttrData env fn let entry ← Lean.getExternEntryFor data backend match entry with | Lean.ExternEntry.standard x n => pure n | Lean.ExternEntry.foreign x n => pure n | x => failure
Equations
- Lean.getExternConstArityExport env declName = do let r ← tryCatch (do let discr ← Lean.Core.CoreM.toIO (Lean.getExternConstArity declName) { options := { entries := [] }, currRecDepth := 0, maxRecDepth := 1000, ref := Lean.Syntax.missing, currNamespace := Lean.Name.anonymous, openDecls := [], initHeartbeats := 0, maxHeartbeats := Lean.Core.getMaxHeartbeats { entries := [] } } { env := env, nextMacroScope := Lean.firstFrontendMacroScope + 1, ngen := { namePrefix := `_uniq, idx := 1 }, traceState := { enabled := true, traces := { root := Std.PersistentArrayNode.node (Array.mkEmpty (USize.toNat Std.PersistentArray.branching)), tail := Array.mkEmpty (USize.toNat Std.PersistentArray.branching), size := 0, shift := Std.PersistentArray.initShift, tailOff := 0 } } } let x : Nat × Lean.Core.State := discr match x with | (arity, x) => pure (some arity)) fun ex => match ex with | IO.Error.userError msg => pure none | x => pure none pure r