|
7 | 7 | import org.jruby.ir.instructions.ResultInstr; |
8 | 8 | import org.jruby.ir.operands.LocalVariable; |
9 | 9 | import org.jruby.ir.operands.Operand; |
| 10 | +import org.jruby.ir.operands.TemporaryLocalVariable; |
| 11 | +import org.jruby.ir.operands.TemporaryVariable; |
10 | 12 | import org.jruby.ir.operands.Variable; |
11 | 13 | import org.jruby.ir.operands.WrappedIRClosure; |
12 | 14 | import org.jruby.ir.IRClosure; |
@@ -79,7 +81,11 @@ public void applyTransferFunction(Instr i) { |
79 | 81 | // Variables that belong to outer scopes should always |
80 | 82 | // be considered defined. |
81 | 83 | for (Variable v: i.getUsedVariables()) { |
82 | | - if (v instanceof LocalVariable && ((LocalVariable)v).getScopeDepth() > 0) { |
| 84 | + if (v instanceof LocalVariable) { |
| 85 | + if (((LocalVariable)v).getScopeDepth() > 0) { |
| 86 | + tmp.set(problem.getDFVar(v)); |
| 87 | + } |
| 88 | + } else if (v instanceof TemporaryLocalVariable) { |
83 | 89 | tmp.set(problem.getDFVar(v)); |
84 | 90 | } |
85 | 91 | } |
@@ -116,17 +122,22 @@ public void identifyInits(Set<Variable> undefinedVars) { |
116 | 122 | initSolution(); |
117 | 123 | for (Instr i: basicBlock.getInstrs()) { |
118 | 124 | for (Variable v: i.getUsedVariables()) { |
119 | | - LocalVariable lv; |
120 | 125 | if (!v.isSelf()) { |
121 | 126 | if (v instanceof LocalVariable) { |
122 | | - lv = (LocalVariable)v; |
| 127 | + LocalVariable lv = (LocalVariable) v; |
123 | 128 | // Variables that belong to outer scopes |
124 | 129 | // are considered already defined. |
125 | 130 | if (lv.getScopeDepth() < parentScopeDepth && !tmp.get(problem.getDFVar(v))) { |
126 | 131 | // We want lv suitable for initializing in this scope |
127 | 132 | undefinedVars.add(lv.getScopeDepth() == 0 ? lv : lv.cloneForDepth(0)); |
128 | 133 | } |
129 | 134 | tmp.set(problem.getDFVar(lv)); |
| 135 | + } else if (v instanceof TemporaryLocalVariable) { |
| 136 | + TemporaryLocalVariable tlv = (TemporaryLocalVariable) v; |
| 137 | + if (!tmp.get(problem.getDFVar(v))) { |
| 138 | + undefinedVars.add(tlv); |
| 139 | + } |
| 140 | + tmp.set(problem.getDFVar(tlv)); |
130 | 141 | } |
131 | 142 | } |
132 | 143 | } |
|
0 commit comments