AS3 parser - filling code stats

This commit is contained in:
Jindra Petk
2014-03-29 21:25:42 +01:00
parent 7f2cc41c10
commit 58951c068e
8 changed files with 134 additions and 94 deletions

View File

@@ -1856,8 +1856,11 @@ public class AVM2Code implements Serializable {
stats.instructionStats[pos].stackpos = stack;
stats.instructionStats[pos].scopepos = scope;
AVM2Instruction ins = code.get(pos);
stack += ins.definition.getStackDelta(ins, abc);
scope += ins.definition.getScopeStackDelta(ins, abc);
int stackDelta = ins.definition.getStackDelta(ins, abc);
stack += stackDelta;
int scopeDelta = ins.definition.getScopeStackDelta(ins, abc);
//System.out.println(""+ins+" stack:"+(stackDelta>0?"+"+stackDelta:stackDelta)+" scope:"+(scopeDelta>0?"+"+scopeDelta:scopeDelta));
scope += scopeDelta;
if (stack > stats.maxstack) {
stats.maxstack = stack;
}
@@ -1872,13 +1875,15 @@ public class AVM2Code implements Serializable {
}
if (ins.definition instanceof SetLocalTypeIns) {
handleRegister(stats, ((SetLocalTypeIns) ins.definition).getRegisterId(ins));
} else if (ins.definition instanceof GetLocalTypeIns) {
handleRegister(stats, ((GetLocalTypeIns) ins.definition).getRegisterId(ins));
} else {
for (int i = 0; i < ins.definition.operands.length; i++) {
if (ins.definition.operands[i] == DAT_REGISTER_INDEX) {
handleRegister(stats, ins.operands[i]);
}
}
}
}
if (ins.definition instanceof ReturnValueIns) {
//check stack=1
return true;
@@ -1919,9 +1924,9 @@ public class AVM2Code implements Serializable {
return true;
}
public CodeStats getStats(ABC abc, MethodBody body) {
CodeStats stats = new CodeStats(this);
if (!walkCode(stats, 0, 0, 0, abc)) {
public CodeStats getStats(ABC abc, MethodBody body, int initScope) {
CodeStats stats = new CodeStats(this);
if (!walkCode(stats, 0, 0, initScope, abc)) {
return null;
}
for (ABCException ex : body.exceptions) {