refactoring

This commit is contained in:
Jindra Pet��k
2013-08-20 19:58:02 +02:00
parent 2998b0279a
commit 64f47c92b9
6 changed files with 21 additions and 16 deletions
@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.abc.avm2.model.NotCompileTimeAVM2Item;
import com.jpexs.decompiler.graph.NotCompileTimeItem;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.StoreTypeAction;
@@ -996,7 +996,7 @@ public class SWFInputStream extends InputStream {
if (varname != null) {
GraphTargetItem varval = vars.get(varname);
if (varval != null && varval.isCompileTime() && indeterminate) {
vars.put(varname, new NotCompileTimeAVM2Item(null, varval));
vars.put(varname, new NotCompileTimeItem(null, varval));
}
}
}
@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.graph.NotCompileTimeItem;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
@@ -2340,7 +2341,7 @@ public class AVM2Code implements Serializable {
HashMap<Integer, GraphTargetItem> registers = (HashMap<Integer, GraphTargetItem>) localData.get(2);
GraphTargetItem regVal = registers.get(regId);
if (regVal.isCompileTime()) {
registers.put(regId, new NotCompileTimeAVM2Item(null, regVal));
registers.put(regId, new NotCompileTimeItem(null, regVal));
}
}
}
@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NotCompileTimeAVM2Item;
import com.jpexs.decompiler.graph.NotCompileTimeItem;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -44,7 +44,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
assignCount = regAssignCount.get(regId);
}
if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation
computedValue = new NotCompileTimeAVM2Item(ins, computedValue);
computedValue = new NotCompileTimeItem(ins, computedValue);
}
/*if (!isRegisterCompileTime(regId, ip, refs, code)) {
computedValue = new NotCompileTimeAVM2Item(ins, computedValue);
@@ -57,7 +57,7 @@ public class AddActionItem extends BinaryOpItem {
public Object getResult() {
if (version2) {
if (EcmaScript.type(leftSide.getResult()) == EcmaType.STRING || EcmaScript.type(rightSide.getResult()) == EcmaType.STRING) {
return leftSide.getResult().toString() + rightSide.getResult().toString();
return ""+leftSide.getResult() + rightSide.getResult();
}
return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult());
} else {
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.graph.NotCompileTimeItem;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.TemporaryRegister;
@@ -14,32 +14,25 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
package com.jpexs.decompiler.graph;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class NotCompileTimeAVM2Item extends AVM2Item {
public class NotCompileTimeItem extends GraphTargetItem {
public GraphTargetItem object;
public NotCompileTimeAVM2Item(GraphSourceItem instruction, GraphTargetItem object) {
public NotCompileTimeItem(GraphSourceItem instruction, GraphTargetItem object) {
super(instruction, NOPRECEDENCE);
this.object = object;
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(constants, localRegNames, fullyQualifiedNames);
}
@Override
public boolean isCompileTime() {
return false;
@@ -52,4 +45,14 @@ public class NotCompileTimeAVM2Item extends AVM2Item {
}
return object.getThroughNotCompilable();
}
@Override
public String toString(List<Object> localData) {
return object.toString(localData);
}
@Override
public boolean hasReturnValue() {
return object.hasReturnValue();
}
}