|
|
@ -371,31 +371,31 @@ public class TransformConstructors { |
|
|
|
private Expression renameJikesSuper(Expression expr, |
|
|
|
private Expression renameJikesSuper(Expression expr, |
|
|
|
MethodAnalyzer methodAna, |
|
|
|
MethodAnalyzer methodAna, |
|
|
|
int firstOuterSlot, |
|
|
|
int firstOuterSlot, |
|
|
|
int firstParamSlot, |
|
|
|
int firstParamSlot) { |
|
|
|
int slotDist) { |
|
|
|
|
|
|
|
if (expr instanceof LocalLoadOperator) { |
|
|
|
if (expr instanceof LocalLoadOperator) { |
|
|
|
LocalLoadOperator llop = (LocalLoadOperator) expr; |
|
|
|
LocalLoadOperator llop = (LocalLoadOperator) expr; |
|
|
|
int slot = llop.getLocalInfo().getSlot(); |
|
|
|
int slot = llop.getLocalInfo().getSlot(); |
|
|
|
if (slot < firstOuterSlot) |
|
|
|
if (slot >= firstOuterSlot && slot < firstParamSlot) |
|
|
|
return llop; |
|
|
|
return outerValues.getValueBySlot(slot); |
|
|
|
if (slot >= firstParamSlot) { |
|
|
|
else { |
|
|
|
Type[] paramTypes = methodAna.getType().getParameterTypes(); |
|
|
|
Type[] paramTypes = methodAna.getType().getParameterTypes(); |
|
|
|
int param; |
|
|
|
int param; |
|
|
|
slot -= slotDist + 1; |
|
|
|
/* Adjust the slot */ |
|
|
|
for (param = 0; slot > 0 && param < paramTypes.length; param++) |
|
|
|
if (slot >= firstParamSlot) |
|
|
|
|
|
|
|
slot -= firstParamSlot - firstOuterSlot; |
|
|
|
|
|
|
|
for (param = 0; slot > 1 && param < paramTypes.length; param++) |
|
|
|
slot -= paramTypes[param].stackSize(); |
|
|
|
slot -= paramTypes[param].stackSize(); |
|
|
|
llop.setLocalInfo(methodAna.getParamInfo(1+param)); |
|
|
|
llop.setLocalInfo(methodAna.getParamInfo(1+param)); |
|
|
|
llop.setMethodAnalyzer(methodAna); |
|
|
|
llop.setMethodAnalyzer(methodAna); |
|
|
|
return llop; |
|
|
|
return llop; |
|
|
|
} |
|
|
|
} |
|
|
|
return outerValues.getValueBySlot(slot); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (expr instanceof Operator) { |
|
|
|
if (expr instanceof Operator) { |
|
|
|
Expression subExpr[] = ((Operator)expr).getSubExpressions(); |
|
|
|
Expression subExpr[] = ((Operator)expr).getSubExpressions(); |
|
|
|
for (int i=0; i< subExpr.length; i++) { |
|
|
|
for (int i=0; i< subExpr.length; i++) { |
|
|
|
Expression newSubExpr = |
|
|
|
Expression newSubExpr = |
|
|
|
renameJikesSuper(subExpr[i], methodAna, |
|
|
|
renameJikesSuper(subExpr[i], methodAna, |
|
|
|
firstOuterSlot, firstParamSlot, slotDist); |
|
|
|
firstOuterSlot, firstParamSlot); |
|
|
|
if (newSubExpr != subExpr[i]) |
|
|
|
if (newSubExpr != subExpr[i]) |
|
|
|
((Operator)expr).setSubExpressions(i, newSubExpr); |
|
|
|
((Operator)expr).setSubExpressions(i, newSubExpr); |
|
|
|
} |
|
|
|
} |
|
|
@ -425,21 +425,26 @@ public class TransformConstructors { |
|
|
|
* constructor$?(optional outerValues[0], params); |
|
|
|
* constructor$?(optional outerValues[0], params); |
|
|
|
* } |
|
|
|
* } |
|
|
|
* |
|
|
|
* |
|
|
|
* The outerValues[0] parameter is the normal this of the |
|
|
|
* The outerValues[0] parameter is the this local in the |
|
|
|
* surrounding method (but what is the surrounding method? |
|
|
|
* surrounding method. But we can't be sure, what the |
|
|
|
* That can't be determined in some cases). If the |
|
|
|
* surrounding method is, since it could be either the method |
|
|
|
* surrounding method is static, the outerValues[0] parameter |
|
|
|
* that uses the class, or a method that declares the class, that |
|
|
|
* disappears! |
|
|
|
* contains the method that uses the class.<br> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* If the surrounding method is static, the outerValues[0] |
|
|
|
|
|
|
|
* parameter disappears. |
|
|
|
* |
|
|
|
* |
|
|
|
* Move optional super to method constructor$? |
|
|
|
* Move optional super to method constructor$? |
|
|
|
* (renaming local variables) and mark constructor and |
|
|
|
* (renaming local variables) and mark constructor and |
|
|
|
* constructor$? as Jikes constructor. |
|
|
|
* constructor$? as Jikes constructor. */ |
|
|
|
*/ |
|
|
|
|
|
|
|
StructuredBlock sb = constr.getMethodHeader().block; |
|
|
|
StructuredBlock sb = constr.getMethodHeader().block; |
|
|
|
|
|
|
|
|
|
|
|
Vector localLoads = null; |
|
|
|
Vector localLoads = null; |
|
|
|
InstructionBlock superBlock = null; |
|
|
|
InstructionBlock superBlock = null; |
|
|
|
if (i >= type0Count) { |
|
|
|
if (i >= type0Count) { |
|
|
|
|
|
|
|
/* Extract the super() or this() call at the beginning |
|
|
|
|
|
|
|
* of the constructor |
|
|
|
|
|
|
|
*/ |
|
|
|
if (!(sb instanceof SequentialBlock) |
|
|
|
if (!(sb instanceof SequentialBlock) |
|
|
|
|| !(sb.getSubBlocks()[1] instanceof InstructionBlock)) |
|
|
|
|| !(sb.getSubBlocks()[1] instanceof InstructionBlock)) |
|
|
|
continue constr_loop; |
|
|
|
continue constr_loop; |
|
|
@ -493,8 +498,8 @@ public class TransformConstructors { |
|
|
|
if (outerValues.isJikesAnonymousInner()) |
|
|
|
if (outerValues.isJikesAnonymousInner()) |
|
|
|
paramCount--; |
|
|
|
paramCount--; |
|
|
|
|
|
|
|
|
|
|
|
int minOuterCount = 0; |
|
|
|
|
|
|
|
int maxOuterCount = paramCount - methodParams.length + 2; |
|
|
|
int maxOuterCount = paramCount - methodParams.length + 2; |
|
|
|
|
|
|
|
int minOuterCount = maxOuterCount - 1; |
|
|
|
int slot = 1; |
|
|
|
int slot = 1; |
|
|
|
int firstParam = 1; |
|
|
|
int firstParam = 1; |
|
|
|
Expression outer0 = null; |
|
|
|
Expression outer0 = null; |
|
|
@ -502,18 +507,18 @@ public class TransformConstructors { |
|
|
|
if (maxOuterCount > 0 |
|
|
|
if (maxOuterCount > 0 |
|
|
|
&& methodParams.length > 1 |
|
|
|
&& methodParams.length > 1 |
|
|
|
&& outerValues.getCount() > 0) { |
|
|
|
&& outerValues.getCount() > 0) { |
|
|
|
/* check if the outerValues[0] param is present. |
|
|
|
/* Check if the outerValues[0] param is present. |
|
|
|
* we can't be sure if maxOuterCount equals 1, but |
|
|
|
* we can't be sure if maxOuterCount equals 1, but |
|
|
|
* we assume so. |
|
|
|
* we assume so, since at this time all possible |
|
|
|
* Also calculate the correct minOuterSlots. |
|
|
|
* info about outers have been collected. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (((LocalLoadOperator)methodParams[firstParam] |
|
|
|
if (((LocalLoadOperator)methodParams[firstParam] |
|
|
|
).getLocalInfo().getSlot() == 1) { |
|
|
|
).getLocalInfo().getSlot() == 1) { |
|
|
|
|
|
|
|
minOuterCount = maxOuterCount; |
|
|
|
outer0 = outerValues.getValue(0); |
|
|
|
outer0 = outerValues.getValue(0); |
|
|
|
firstParam++; |
|
|
|
firstParam++; |
|
|
|
} else |
|
|
|
} else |
|
|
|
maxOuterCount--; |
|
|
|
maxOuterCount--; |
|
|
|
minOuterCount = maxOuterCount; |
|
|
|
|
|
|
|
for (int j=0; j < maxOuterCount; j++) |
|
|
|
for (int j=0; j < maxOuterCount; j++) |
|
|
|
slot += paramTypes[j].stackSize(); |
|
|
|
slot += paramTypes[j].stackSize(); |
|
|
|
} |
|
|
|
} |
|
|
@ -541,13 +546,13 @@ public class TransformConstructors { |
|
|
|
if (superBlock != null) { |
|
|
|
if (superBlock != null) { |
|
|
|
Expression newExpr = |
|
|
|
Expression newExpr = |
|
|
|
renameJikesSuper(superBlock.getInstruction(), methodAna, |
|
|
|
renameJikesSuper(superBlock.getInstruction(), methodAna, |
|
|
|
firstOuterSlot, firstParamSlot, slotDist); |
|
|
|
firstOuterSlot, firstParamSlot); |
|
|
|
superBlock.removeBlock(); |
|
|
|
superBlock.removeBlock(); |
|
|
|
methodAna.insertStructuredBlock(superBlock); |
|
|
|
methodAna.insertStructuredBlock(superBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
if (outer0 != null) { |
|
|
|
if (outer0 != null) { |
|
|
|
constr.getParamInfo(1).setExpression(outer0); |
|
|
|
methodAna.getParamInfo(1).setExpression(outer0); |
|
|
|
cons[i].getMethodHeader().simplify(); |
|
|
|
methodAna.getMethodHeader().simplify(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|