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

Side by Side Diff: utils/jstypes.js

Issue 29350140: Issue 4353 - Remove non standard for each syntax (Closed)
Patch Set: Created Aug. 24, 2016, 11:08 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« scripts/decompile.js ('K') | « utils/dumpast.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * This file presents various methods to create a JS typing system. 2 * This file presents various methods to create a JS typing system.
3 */ 3 */
4 4
5 function divine_inheritance(clazz, constants) { 5 function divine_inheritance(clazz, constants) {
6 let aliases = {}; 6 let aliases = {};
7 for each (let c in constants) { 7 for (let c of constants) {
8 aliases[c.name] = c.init; 8 aliases[c.name] = c.init;
9 } 9 }
10 10
11 // First, do we have a QueryInterface variable? 11 // First, do we have a QueryInterface variable?
12 if ("QueryInterface" in clazz.variables) { 12 if ("QueryInterface" in clazz.variables) {
13 // Yes, it's a function, but the variable means that we found a XPCOMUtils 13 // Yes, it's a function, but the variable means that we found a XPCOMUtils
14 // utility. This'll be easy! 14 // utility. This'll be easy!
15 let xpcom = clazz.variables.QueryInterface.init; 15 let xpcom = clazz.variables.QueryInterface.init;
16 assert(xpcom.op == JSOP_CALL && xpcom.kids[0].atom == "generateQI"); 16 assert(xpcom.op == JSOP_CALL && xpcom.kids[0].atom == "generateQI");
17 17
18 if (!clazz.inherits) 18 if (!clazz.inherits)
19 clazz.inherits = []; 19 clazz.inherits = [];
20 for each (let iface in xpcom.kids[1].kids) 20 for (let iface of xpcom.kids[1].kids)
21 clazz.inherits.push(iface.atom); 21 clazz.inherits.push(iface.atom);
22 return; 22 return;
23 } 23 }
24 24
25 if ("QueryInterface" in clazz.functions) { 25 if ("QueryInterface" in clazz.functions) {
26 if (!clazz.inherits) 26 if (!clazz.inherits)
27 clazz.inherits = []; 27 clazz.inherits = [];
28 function findInterfaces(ast) { 28 function findInterfaces(ast) {
29 » if (ast.op == JSOP_GETPROP && ast.kids[0]) { 29 if (ast.op == JSOP_GETPROP && ast.kids[0]) {
30 » » let check = ast.kids[0]; 30 let check = ast.kids[0];
31 » » if (check.atom == "interfaces" && check.kids[0] && 31 if (check.atom == "interfaces" && check.kids[0] &&
32 » » » » check.kids[0].atom == "Components") { 32 check.kids[0].atom == "Components") {
33 clazz.inherits.push(ast.atom); 33 clazz.inherits.push(ast.atom);
34 } 34 }
35 } 35 }
36 } 36 }
37 visit(clazz.functions.QueryInterface.body, findInterfaces, aliases); 37 visit(clazz.functions.QueryInterface.body, findInterfaces, aliases);
38 return; 38 return;
39 } 39 }
40 } 40 }
OLDNEW
« scripts/decompile.js ('K') | « utils/dumpast.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld