-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccessDomain.h
52 lines (41 loc) · 1.55 KB
/
AccessDomain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef SS_ACCESSDOMAIN_H
#define SS_ACCESSDOMAIN_H
#include "Prereqs.h"
namespace SS {
class Node;
// Accessibility domains come in 3 flavors:
// 1) Universal access (this happens if something is public, or a public member of something else that's public, etc.)
// 2) Access lexically inside some node (this happens if something is private, or public inside something else that is private)
// 3) Access lexically inside of some class, and also in all derived classes
// (if something is protected, or public inside something protected, etc.)
// This only encodes the domain itself, not the public/private/on what/etc. data.
class SS_EXPORT AccessDomain
{
public:
AccessDomain(Node* node = 0, bool derivedClasses = false) : m_node(node), m_derivedClasses(derivedClasses) {}
// Creates a new access domain representing everywhere (a universal domain.)
static AccessDomain Universal()
{
return AccessDomain(0, false);
}
// Create a new access domain representing a lexical domain: things physically
// within a certain block in a file.
static AccessDomain Lexical(Node* n)
{
return AccessDomain(n, false);
}
// Creates a new access domain representing the area contained by a
// class and all its subclasses.
static AccessDomain ClassAndSubclasses(Node* n)
{
return AccessDomain(n, true);
}
// Checks if an acces domain contains another domain.
bool Contains(Node* ctx) const;
private:
Node* m_node;
bool m_derivedClasses;
};
bool IsAccessible(Node* n, Node* context);
}
#endif // SS_ACCESSDOMAIN_H