refactor: registerAttribute ==> registerBuiltinAttribute

This commit is contained in:
Leonardo de Moura 2020-01-10 17:08:12 -08:00
parent 6fc158f550
commit 48600dbbfc
7 changed files with 11 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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