File: .lake/packages/lean4/src/lean/Lean/Compiler/ExternAttr.lean

full_name: Lean.ExternEntry.foreign
code: inductive ExternEntry where
  | adhoc    (backend : Name)
  | inline   (backend : Name) (pattern : String)
  | standard (backend : Name) (fn : String)
  | foreign  (backend : Name) (fn : String)
goal: Lean.ExternEntry

full_name: Lean.ExternEntry.inline
code: inductive ExternEntry where
  | adhoc    (backend : Name)
  | inline   (backend : Name) (pattern : String)
  | standard (backend : Name) (fn : String)
  | foreign  (backend : Name) (fn : String)
goal: Lean.ExternEntry

full_name: Lean.ExternEntry
code: inductive ExternEntry where
  | adhoc    (backend : Name)
  | inline   (backend : Name) (pattern : String)
  | standard (backend : Name) (fn : String)
  | foreign  (backend : Name) (fn : String)
goal: Type

full_name: Lean.ExternEntry.standard
code: inductive ExternEntry where
  | adhoc    (backend : Name)
  | inline   (backend : Name) (pattern : String)
  | standard (backend : Name) (fn : String)
  | foreign  (backend : Name) (fn : String)
goal: Lean.ExternEntry

full_name: Lean.ExternEntry.adhoc
code: inductive ExternEntry where
  | adhoc    (backend : Name)
  | inline   (backend : Name) (pattern : String)
  | standard (backend : Name) (fn : String)
  | foreign  (backend : Name) (fn : String)
goal: Lean.ExternEntry

full_name: Lean.ExternAttrData
code: /--
- `@[extern]`
   encoding: ```.entries = [adhoc `all]```
- `@[extern "level_hash"]`
   encoding: ```.entries = [standard `all "levelHash"]```
- `@[extern cpp "lean::string_size" llvm "lean_str_size"]`
   encoding: ```.entries = [standard `cpp "lean::string_size", standard `llvm "leanStrSize"]```
- `@[extern cpp inline "#1 + #2"]`
   encoding: ```.entries = [inline `cpp "#1 + #2"]```
- `@[extern cpp "foo" llvm adhoc]`
   encoding: ```.entries = [standard `cpp "foo", adhoc `llvm]```
- `@[extern 2 cpp "io_prim_println"]`
   encoding: ```.arity? = 2, .entries = [standard `cpp "ioPrimPrintln"]```
-/
structure ExternAttrData where
  arity?   : Option Nat := none
  entries  : List ExternEntry
  deriving Inhabited
goal: Type

full_name: Lean.ExternAttrData.entries
code: /--
- `@[extern]`
   encoding: ```.entries = [adhoc `all]```
- `@[extern "level_hash"]`
   encoding: ```.entries = [standard `all "levelHash"]```
- `@[extern cpp "lean::string_size" llvm "lean_str_size"]`
   encoding: ```.entries = [standard `cpp "lean::string_size", standard `llvm "leanStrSize"]```
- `@[extern cpp inline "#1 + #2"]`
   encoding: ```.entries = [inline `cpp "#1 + #2"]```
- `@[extern cpp "foo" llvm adhoc]`
   encoding: ```.entries = [standard `cpp "foo", adhoc `llvm]```
- `@[extern 2 cpp "io_prim_println"]`
   encoding: ```.arity? = 2, .entries = [standard `cpp "ioPrimPrintln"]```
-/
structure ExternAttrData where
  arity?   : Option Nat := none
  entries  : List ExternEntry
  deriving Inhabited
goal: List Lean.ExternEntry

full_name: Lean.instInhabitedExternAttrData
code: /--
- `@[extern]`
   encoding: ```.entries = [adhoc `all]```
- `@[extern "level_hash"]`
   encoding: ```.entries = [standard `all "levelHash"]```
- `@[extern cpp "lean::string_size" llvm "lean_str_size"]`
   encoding: ```.entries = [standard `cpp "lean::string_size", standard `llvm "leanStrSize"]```
- `@[extern cpp inline "#1 + #2"]`
   encoding: ```.entries = [inline `cpp "#1 + #2"]```
- `@[extern cpp "foo" llvm adhoc]`
   encoding: ```.entries = [standard `cpp "foo", adhoc `llvm]```
- `@[extern 2 cpp "io_prim_println"]`
   encoding: ```.arity? = 2, .entries = [standard `cpp "ioPrimPrintln"]```
-/
structure ExternAttrData where
  arity?   : Option Nat := none
  entries  : List ExternEntry
  deriving Inhabited
goal: Inhabited Lean.ExternAttrData

full_name: Lean.ExternAttrData.arity?
code: /--
- `@[extern]`
   encoding: ```.entries = [adhoc `all]```
- `@[extern "level_hash"]`
   encoding: ```.entries = [standard `all "levelHash"]```
- `@[extern cpp "lean::string_size" llvm "lean_str_size"]`
   encoding: ```.entries = [standard `cpp "lean::string_size", standard `llvm "leanStrSize"]```
- `@[extern cpp inline "#1 + #2"]`
   encoding: ```.entries = [inline `cpp "#1 + #2"]```
- `@[extern cpp "foo" llvm adhoc]`
   encoding: ```.entries = [standard `cpp "foo", adhoc `llvm]```
- `@[extern 2 cpp "io_prim_println"]`
   encoding: ```.arity? = 2, .entries = [standard `cpp "ioPrimPrintln"]```
-/
structure ExternAttrData where
  arity?   : Option Nat := none
  entries  : List ExternEntry
  deriving Inhabited
goal: Option Nat

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.ExternAttr.0.Lean.syntaxToExternAttrData
code: private def syntaxToExternAttrData (stx : Syntax) : AttrM ExternAttrData 
goal: Lean.AttrM Lean.ExternAttrData

full_name: Lean.addExtern
code: @[extern "lean_add_extern"]
opaque addExtern (env : Environment) (n : Name) : ExceptT String Id Environment
goal: ExceptT String Id Lean.Environment

full_name: Lean.externAttr
code: builtin_initialize externAttr : ParametricAttribute ExternAttrData ←
  registerParametricAttribute {
    name := `extern
    descr := "builtin and foreign functions"
    getParam := fun _ stx => syntaxToExternAttrData stx
    afterSet := fun declName _ => do
      let env ← getEnv
      if env.isProjectionFn declName || env.isConstructor declName then
        if let some (.thmInfo ..) := env.find? declName then
          -- We should not mark theorems as extern
          return ()
        let env ← ofExcept <| addExtern env declName
        setEnv env
  }
goal: Lean.ParametricAttribute Lean.ExternAttrData

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.Compiler.ExternAttr._hyg.695
code: builtin_initialize externAttr : ParametricAttribute ExternAttrData ←
  registerParametricAttribute {
    name := `extern
    descr := "builtin and foreign functions"
    getParam := fun _ stx => syntaxToExternAttrData stx
    afterSet := fun declName _ => do
      let env ← getEnv
      if env.isProjectionFn declName || env.isConstructor declName then
        if let some (.thmInfo ..) := env.find? declName then
          -- We should not mark theorems as extern
          return ()
        let env ← ofExcept <| addExtern env declName
        setEnv env
  }
goal: IO (Lean.ParametricAttribute Lean.ExternAttrData)

full_name: Lean.getExternAttrData?
code: @[export lean_get_extern_attr_data]
def getExternAttrData? (env : Environment) (n : Name) : Option ExternAttrData 
goal: Option Lean.ExternAttrData

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.ExternAttr.0.Lean.parseOptNum
code: private def parseOptNum : Nat → String.Iterator → Nat → String.Iterator × Nat
  
goal: Nat → String.Iterator → Nat → String.Iterator × Nat

full_name: Lean.expandExternPatternAux
code: def expandExternPatternAux (args : List String) : Nat → String.Iterator → String → String
  
goal: Nat → String.Iterator → String → String

full_name: Lean.expandExternPattern
code: def expandExternPattern (pattern : String) (args : List String) : String 
goal: String

full_name: Lean.mkSimpleFnCall
code: def mkSimpleFnCall (fn : String) (args : List String) : String 
goal: String

full_name: Lean.ExternEntry.backend
code: def ExternEntry.backend : ExternEntry → Name
  
goal: Lean.ExternEntry → Lean.Name

full_name: Lean.getExternEntryForAux
code: def getExternEntryForAux (backend : Name) : List ExternEntry → Option ExternEntry
  
goal: List Lean.ExternEntry → Option Lean.ExternEntry

full_name: Lean.getExternEntryFor
code: def getExternEntryFor (d : ExternAttrData) (backend : Name) : Option ExternEntry 
goal: Option Lean.ExternEntry

full_name: Lean.isExtern
code: def isExtern (env : Environment) (fn : Name) : Bool 
goal: Bool

full_name: Lean.isExternC
code: /-- We say a Lean function marked as `[extern "<c_fn_nane>"]` is for all backends, and it is implemented using `extern "C"`.
   Thus, there is no name mangling. -/
def isExternC (env : Environment) (fn : Name) : Bool 
goal: Bool

full_name: Lean.getExternNameFor
code: def getExternNameFor (env : Environment) (backend : Name) (fn : Name) : Option String 
goal: Option String

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Compiler.ExternAttr.0.Lean.getExternConstArity
code: private def getExternConstArity (declName : Name) : CoreM Nat 
goal: Lean.CoreM Nat

full_name: Lean.getExternConstArityExport
code: @[export lean_get_extern_const_arity]
def getExternConstArityExport (env : Environment) (declName : Name) : IO (Option Nat) 
goal: IO (Option Nat)