refactor: registerAttribute ==> registerBuiltinAttribute
This commit is contained in:
parent
6fc158f550
commit
48600dbbfc
7 changed files with 11 additions and 11 deletions
|
|
@ -53,7 +53,7 @@ IO.mkRef {}
|
|||
constant attributeMapRef : IO.Ref (PersistentHashMap Name AttributeImpl) := arbitrary _
|
||||
|
||||
/- Low level attribute registration function. -/
|
||||
def registerAttribute (attr : AttributeImpl) : IO Unit := do
|
||||
def registerBuiltinAttribute (attr : AttributeImpl) : IO Unit := do
|
||||
m ← attributeMapRef.get;
|
||||
when (m.contains attr.name) $ throw (IO.userError ("invalid attribute declaration, '" ++ toString attr.name ++ "' has already been used"));
|
||||
initializing ← IO.initializing;
|
||||
|
|
@ -185,7 +185,7 @@ let attrImpl : AttributeImpl := {
|
|||
| Except.error msg => throw (IO.userError ("invalid attribute '" ++ toString name ++ "', " ++ msg))
|
||||
| _ => pure $ ext.addEntry env decl
|
||||
};
|
||||
registerAttribute attrImpl;
|
||||
registerBuiltinAttribute attrImpl;
|
||||
pure { attr := attrImpl, ext := ext }
|
||||
|
||||
namespace TagAttribute
|
||||
|
|
@ -237,7 +237,7 @@ let attrImpl : AttributeImpl := {
|
|||
| Except.error msg => throw (IO.userError ("invalid attribute '" ++ toString name ++ "', " ++ msg))
|
||||
| Except.ok env => pure env
|
||||
};
|
||||
registerAttribute attrImpl;
|
||||
registerBuiltinAttribute attrImpl;
|
||||
pure { attr := attrImpl, ext := ext }
|
||||
|
||||
namespace ParametricAttribute
|
||||
|
|
@ -293,7 +293,7 @@ let attrs := attrDescrs.map $ fun ⟨name, descr, val⟩ => { AttributeImpl .
|
|||
| Except.error msg => throw (IO.userError ("invalid attribute '" ++ toString name ++ "', " ++ msg))
|
||||
| _ => pure $ ext.addEntry env (decl, val)
|
||||
};
|
||||
attrs.forM registerAttribute;
|
||||
attrs.forM registerBuiltinAttribute;
|
||||
pure { ext := ext, attrs := attrs }
|
||||
|
||||
namespace EnumAttributes
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ partial def getClassName (env : Environment) : Expr → Option Name
|
|||
else none
|
||||
|
||||
@[init] def registerClassAttr : IO Unit :=
|
||||
registerAttribute {
|
||||
registerBuiltinAttribute {
|
||||
name := `class,
|
||||
descr := "type class",
|
||||
add := fun env decl args persistent => do
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ match env.addAndCompile {} decl with
|
|||
| Except.ok env => IO.ofExcept (setInitAttr env name)
|
||||
|
||||
@[init] def registerBuiltinCommandElabAttr : IO Unit :=
|
||||
registerAttribute {
|
||||
registerBuiltinAttribute {
|
||||
name := `builtinCommandElab,
|
||||
descr := "Builtin command elaborator",
|
||||
add := fun env declName arg persistent => do {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ match env.addAndCompile {} decl with
|
|||
| Except.ok env => IO.ofExcept (setInitAttr env name)
|
||||
|
||||
@[init] def registerBuiltinTermElabAttr : IO Unit :=
|
||||
registerAttribute {
|
||||
registerBuiltinAttribute {
|
||||
name := `builtinTermElab,
|
||||
descr := "Builtin term elaborator",
|
||||
add := fun env declName arg persistent => do {
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ let attrImpl : AttributeImpl := {
|
|||
add := ElabAttribute.add parserNamespace typeName ext,
|
||||
applicationTime := AttributeApplicationTime.afterCompilation
|
||||
};
|
||||
registerAttribute attrImpl;
|
||||
registerBuiltinAttribute attrImpl;
|
||||
pure { ext := ext, attr := attrImpl, kind := kind }
|
||||
|
||||
@[init] private def regTraceClasses : IO Unit := do
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ match env.find? constName with
|
|||
pure $ instanceExtension.addEntry env { keys := keys, val := c }
|
||||
|
||||
@[init] def registerInstanceAttr : IO Unit :=
|
||||
registerAttribute {
|
||||
registerBuiltinAttribute {
|
||||
name := `instance,
|
||||
descr := "type class instance",
|
||||
add := fun env declName args persistent => do
|
||||
|
|
|
|||
|
|
@ -1640,7 +1640,7 @@ The parsing tables for builtin parsers are "stored" in the extracted source code
|
|||
-/
|
||||
def registerBuiltinParserAttribute (attrName : Name) (catName : Name) : IO Unit := do
|
||||
addBuiltinParserCategory catName;
|
||||
registerAttribute {
|
||||
registerBuiltinAttribute {
|
||||
name := attrName,
|
||||
descr := "Builtin parser",
|
||||
add := BuiltinParserAttribute.add attrName catName,
|
||||
|
|
@ -1681,7 +1681,7 @@ let attrImpl : AttributeImpl := {
|
|||
add := ParserAttribute.add attrName catName,
|
||||
applicationTime := AttributeApplicationTime.afterCompilation
|
||||
};
|
||||
registerAttribute attrImpl
|
||||
registerBuiltinAttribute attrImpl -- TODO improve
|
||||
|
||||
-- declare `termParser` here since it is used everywhere via antiquotations
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue