Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: utils/jstypes.js

Issue 29350140: Issue 4353 - Remove non standard for each syntax (Closed)
Left Patch Set: Created Aug. 24, 2016, 11:08 a.m.
Right Patch Set: Removed unused code Created Aug. 24, 2016, 2:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « utils/dumpast.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 (let c of 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 (let iface of 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 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld