Bug 400795 - initial form fill and username autocomplete should share common code...
[wine-gecko.git] / xpcom / analysis / mayreturn.js
blob16114bc5bd2786be79ff9b29aa9c045a19ce1d80
1 /* May-return analysis.
2 * This makes sense only for functions that return a value. The analysis
3 * determines the set of variables that may transitively reach the return
4 * statement. */
6 function MayReturnAnalysis() {
7 BackwardAnalysis.apply(this, arguments);
8 // May-return variables. We collect them all here.
9 this.vbls = create_decl_set();
10 // The return value variable itself
11 this.retvar = undefined;
14 MayReturnAnalysis.prototype = new BackwardAnalysis;
16 MayReturnAnalysis.prototype.flowState = function(isn, state) {
17 if (TREE_CODE(isn) == RETURN_EXPR) {
18 let gms = TREE_OPERAND(isn, 0);
19 if (gms) {
20 // gms is usually a GIMPLE_MODIFY_STMT but can be a RESULT_DECL
21 if (TREE_CODE(gms) == GIMPLE_MODIFY_STMT) {
22 let v = GIMPLE_STMT_OPERAND(gms, 1);
23 this.vbls.add(v);
24 state.add(v);
25 this.retvar = v;
26 } else if (TREE_CODE(gms) == RESULT_DECL) {
27 throw new Error("Weird case hit");
30 } else if (TREE_CODE(isn) == GIMPLE_MODIFY_STMT) {
31 let lhs = GIMPLE_STMT_OPERAND(isn, 0);
32 let rhs = GIMPLE_STMT_OPERAND(isn, 1);
33 if (DECL_P(rhs) && DECL_P(lhs) && state.has(lhs)) {
34 this.vbls.add(rhs);
35 state.add(rhs);
38 for (let e in isn_defs(isn, 'strong')) {
39 if (DECL_P(e)) {
40 state.remove(e);