privacy: reach: Rename ReachLevel enum

This commit is contained in:
Arthur Cohen 2022-04-05 12:11:34 +02:00
parent 8bf037fede
commit e01a814061
3 changed files with 8 additions and 5 deletions

View File

@ -28,8 +28,8 @@ namespace Privacy {
*/
enum ReachLevel
{
Private,
Public,
Unreachable,
Reachable,
};
class PrivacyContext

View File

@ -56,16 +56,19 @@ ReachabilityVisitor::visit (HIR::TypeAlias &type_alias)
void
ReachabilityVisitor::visit (HIR::StructStruct &struct_item)
{
auto struct_reach = ReachLevel::Private;
auto struct_reach = ReachLevel::Unreachable;
// FIXME: This feels very wrong. Should we check for `has_visibility`
// beforehand? Is it just private otherwise? Should the `HIR::Visibility` also
// keep variants for private items?
if (struct_item.get_visibility ().get_vis_type () == HIR::Visibility::NONE)
struct_reach = ReachLevel::Public;
struct_reach = ReachLevel::Reachable;
// FIXME: Here we want to update only if the visibility is higher
ctx.insert_reachability (struct_item.get_mappings (), struct_reach);
// FIXME: We need to also visit the fields as they might have their own set
// of reachability levels
for (auto &field : struct_item.get_fields ())
ctx.insert_reachability (field.get_mappings (), struct_reach);

View File

@ -37,7 +37,7 @@ class ReachabilityVisitor : public HIR::HIRVisItemVisitor
{
public:
ReachabilityVisitor (PrivacyContext &ctx)
: current_level (ReachLevel::Private), ctx (ctx)
: current_level (ReachLevel::Unreachable), ctx (ctx)
{}
virtual void visit (HIR::Module &mod);