Verified Commit 1c6ae0a1 authored by Camil Staps's avatar Camil Staps 🚀

Derive types for basic macros

parent f951e082
Subproject commit 3bf6da2acd1389d5558cb70f043981ce84d157b8
Subproject commit eff41df0ccb7b171a8c62d95406faa008b34d443
......@@ -288,22 +288,22 @@ where
pd_rewriterules dcl defs st
= [( setLine dcl pos {zero & name=Just id.id_name}
, let doc = findDoc hideIsUsedReturn parseFunctionDoc id st in
if (isNothing (findTypeSpec id defs) && needsTypeWarning doc)
(trace_n $ "Doc warning: expected @type for '" +++ id.id_name +++ "'")
(\x->x)
trace_type_warning id
{ zero
& fe_kind=Macro
, fe_type=getTypeDoc =<< doc
, fe_representation=Just $ priostring id +++ cpp pd
, fe_type=pdType pd <|> (getTypeDoc =<< doc)
, fe_representation=Just $ priostring id pd +++ cpp pd
, fe_priority=findPrio id >>= 'T'.toMaybePriority
, fe_documentation=doc
}
) \\ pd=:(PD_Function pos id isinfix args rhs _) <- defs]
where
priostring :: Ident -> String
priostring id = case findTypeSpec id defs of
Nothing = ""
(Just pri) = cpp pri +++ "\n"
priostring :: Ident ParsedDefinition -> String
priostring id pd = case findTypeSpec id defs of
Just td -> cpp td +++ "\n"
Nothing -> case pdType pd of
Just t -> id.id_name +++ " :: " +++ concat (print False t) +++ "\n"
Nothing -> ""
findPrio :: Ident -> Maybe Priority
findPrio id = (\(PD_TypeSpec _ _ p _ _) -> p) <$> findTypeSpec id defs
......@@ -318,6 +318,12 @@ where
needsTypeWarning Nothing = True
needsTypeWarning (Just (FunctionDoc _ _ _ _ t)) = isNothing t
trace_type_warning :: !Ident !FunctionEntry -> FunctionEntry
trace_type_warning id fe
| isJust (findTypeSpec id defs) = fe
| isJust fe.fe_type = fe
| otherwise = trace_n ("Doc warning: expected @type for '" +++ id.id_name +++ "'") fe
pd_derivations :: !Bool ![ParsedDefinition] -> [('DB'.Name, [('DB'.Type, String, LocationInModule)])]
pd_derivations dcl defs
= [( id.id_name, [('T'.toType gc_type, cpp gc_type, setLine dcl gc_pos zero)])
......
......@@ -97,13 +97,17 @@ different syntax elements, and what they should document.
| Function | ![][y] | ![][y] | ![][y] | | |
| Generic | ![][y] | ![][y] | ![][y] | | ![][y] |
| Instance | | | | | |
| Macro | ![][y] | ![][y] | ![][y] | ![][y] | |
| Macro | ![][y] | ![][y] | ![][y] | ![][y]<sup>2</sup> | |
| Module | ![][y] | | | | |
| Record field | ![][y] | | | | |
| Type | ![][y] | | | | ![][y] | ![][y], for type synonyms
<sup>Note 1: only for shorthand classes like `class zero a :: a`, where there
is no other place for the documentation of the class member.</sup>
<sup>
1: only for shorthand classes like `class zero a :: a`, where there is no other
place for the documentation of the class member.
2: for simple macros (depending on what CleanTypeUnifier's `pdType` can do),
`CloogleDBFactory` can derive the type.
</sup>
| Field | Description
|-------------------|-------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment