forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
final.js
37 lines (33 loc) · 956 Bytes
/
final.js
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
function process_type(c)
{
if ((c.kind == 'class' || c.kind == 'struct') && !c.isIncomplete) {
for each (let base in c.bases)
if (isFinal(base.type))
error("Class '" + c.name + "' derives from final class '" + base.type.name + "'.", c.loc);
}
}
function process_function(decl, body)
{
if (!decl.memberOf)
return;
let c = decl.memberOf;
if ((c.kind == 'class' || c.kind == 'struct') && !c.isIncomplete) {
for each (let base in ancestorTypes(c))
for each (let member in base.members)
if (member.isFunction && isFinal(member) && member.shortName == decl.shortName)
error("Function '" + decl.name + "' overrides final ancestor in '" +
base.name + "'.", c.loc);
}
}
function ancestorTypes(c)
{
for each (let base in c.bases) {
yield base.type;
for (let bb in ancestorTypes(base.type))
yield bb;
}
}
function isFinal(c)
{
return hasAttribute(c, 'NS_final');
}