Add DeclarationAnnotation

This commit is contained in:
Jason Cobb 2019-12-19 18:04:46 -05:00
parent bc71f61467
commit be14d5f28d
No known key found for this signature in database
GPG Key ID: 2A3F6A6DCA1E8DED
3 changed files with 13 additions and 0 deletions

View File

@ -449,6 +449,13 @@ string Scopable::sourceUnitName() const
return sourceUnit().annotation().path;
}
DeclarationAnnotation& Declaration::annotation() const
{
if (!m_annotation)
m_annotation = make_unique<DeclarationAnnotation>();
return dynamic_cast<DeclarationAnnotation&>(*m_annotation);
}
bool VariableDeclaration::isLValue() const
{
// Constant declared variables are Read-Only

View File

@ -231,6 +231,8 @@ public:
/// @returns null when it is not accessible as a function.
virtual FunctionTypePointer functionType(bool /*_internal*/) const { return {}; }
DeclarationAnnotation& annotation() const override;
protected:
virtual Visibility defaultVisibility() const { return Visibility::Public; }

View File

@ -82,6 +82,10 @@ struct ScopableAnnotation
ASTNode const* scope = nullptr;
};
struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation
{
};
struct ImportAnnotation: ASTAnnotation
{
/// The absolute path of the source unit to import.