OLD | NEW |
| (Empty) |
1 /** | |
2 * This file presents various methods to create a JS typing system. | |
3 */ | |
4 | |
5 function divine_inheritance(clazz, constants) { | |
6 let aliases = {}; | |
7 for each (let c in constants) { | |
8 aliases[c.name] = c.init; | |
9 } | |
10 | |
11 // First, do we have a QueryInterface variable? | |
12 if ("QueryInterface" in clazz.variables) { | |
13 // Yes, it's a function, but the variable means that we found a XPCOMUtils | |
14 // utility. This'll be easy! | |
15 let xpcom = clazz.variables.QueryInterface.init; | |
16 assert(xpcom.op == JSOP_CALL && xpcom.kids[0].atom == "generateQI"); | |
17 | |
18 if (!clazz.inherits) | |
19 clazz.inherits = []; | |
20 for each (let iface in xpcom.kids[1].kids) | |
21 clazz.inherits.push(iface.atom); | |
22 return; | |
23 } | |
24 | |
25 if ("QueryInterface" in clazz.functions) { | |
26 if (!clazz.inherits) | |
27 clazz.inherits = []; | |
28 function findInterfaces(ast) { | |
29 if (ast.op == JSOP_GETPROP && ast.kids[0]) { | |
30 let check = ast.kids[0]; | |
31 if (check.atom == "interfaces" && check.kids[0] && | |
32 check.kids[0].atom == "Components") { | |
33 clazz.inherits.push(ast.atom); | |
34 } | |
35 } | |
36 } | |
37 visit(clazz.functions.QueryInterface.body, findInterfaces, aliases); | |
38 return; | |
39 } | |
40 } | |
OLD | NEW |