use diamond

This commit is contained in:
2015-07-05 21:34:49 +02:00
parent 8928a3c9ee
commit bf2c6cb822
37 changed files with 160 additions and 158 deletions
@@ -488,7 +488,7 @@ public abstract class Action implements GraphSourceItem {
continue;
}
if (!containers.containsKey(addr)) {
containers.put(addr, new ArrayList<GraphSourceItemContainer>());
containers.put(addr, new ArrayList<>());
}
containers.get(addr).add(cnt);
}
@@ -737,7 +737,7 @@ public abstract class Action implements GraphSourceItem {
}
public static List<GraphTargetItem> actionsToTree(List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
return actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
return actionsToTree(new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
}
/**
@@ -937,7 +937,7 @@ public abstract class Action implements GraphSourceItem {
}
for (long size : cnt.getContainerSizes()) {
if (size == 0) {
outs.add(new ArrayList<GraphTargetItem>());
outs.add(new ArrayList<>());
continue;
}
List<GraphTargetItem> out;
@@ -61,7 +61,7 @@ import java.util.Map;
public class ActionGraph extends Graph {
public ActionGraph(List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList<Integer>());
super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList<>());
//this.version = version;
/*heads = makeGraph(code, new ArrayList<GraphPart>());
for (GraphPart head : heads) {
@@ -120,7 +120,7 @@ public class ActionGraph extends Graph {
break;
}
} else {
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<String>());
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<>());
targetStart = t;
targetStartItem = it;
}
@@ -179,7 +179,7 @@ public class ActionList extends ArrayList<Action> {
public void saveToFile(String fileName) {
File file = new File(fileName);
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
Action.actionsToString(new ArrayList<DisassemblyListener>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE, writer);
Action.actionsToString(new ArrayList<>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE, writer);
} catch (IOException ex) {
Logger.getLogger(ActionList.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -187,7 +187,7 @@ public class ActionList extends ArrayList<Action> {
@Override
public String toString() {
return Action.actionsToString(new ArrayList<DisassemblyListener>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE);
return Action.actionsToString(new ArrayList<>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE);
}
public String toSource() {
@@ -137,7 +137,7 @@ public class ActionListReader {
Map<Long, Long> nextOffsets = new HashMap<>();
Action entryAction = readActionListAtPos(listeners, null,
sis, actionMap, nextOffsets,
ip, 0, endIp, path, false, new ArrayList<Long>());
ip, 0, endIp, path, false, new ArrayList<>());
if (actionMap.isEmpty()) {
return new ActionList();
@@ -239,9 +239,9 @@ public class ActionListReader {
// Map of the actions. Use TreeMap to sort the keys in ascending order
Map<Long, Action> actionMap = new TreeMap<>();
Map<Long, Long> nextOffsets = new HashMap<>();
readActionListAtPos(new ArrayList<DisassemblyListener>(), null,
readActionListAtPos(new ArrayList<>(), null,
sis, actionMap, nextOffsets,
startIp, startIp, endIp + 1, "", false, new ArrayList<Long>());
startIp, startIp, endIp + 1, "", false, new ArrayList<>());
return new ArrayList<>(actionMap.values());
}
@@ -293,14 +293,14 @@ public class ActionListReader {
}
deobfustaceActionListAtPosRecursive(listeners,
new ArrayList<GraphTargetItem>(),
new HashMap<Long, List<GraphSourceItemContainer>>(),
new ArrayList<>(),
new HashMap<>(),
new ActionLocalData(),
new TranslateStack(path),
new ConstantPool(),
actionMap, ip, retMap, ip, endIp, path,
new HashMap<Integer, Integer>(), false,
new HashMap<Integer, HashMap<String, GraphTargetItem>>(),
new HashMap<>(), false,
new HashMap<>(),
version, 0, maxRecursionLevel);
ActionList ret = new ActionList();
@@ -800,7 +800,7 @@ public class ActionListReader {
}
if (debugMode) {
String atos = a.getASMSource(new ActionList(), new HashSet<Long>(), ScriptExportMode.PCODE);
String atos = a.getASMSource(new ActionList(), new HashSet<>(), ScriptExportMode.PCODE);
if (a instanceof GraphSourceItemContainer) {
atos = a.toString();
}
@@ -888,10 +888,10 @@ public class ActionListReader {
} else if (!(a instanceof GraphSourceItemContainer)) {
//return in for..in, TODO:Handle this better way
if (((a instanceof ActionEquals) || (a instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
}
if ((a instanceof ActionStoreRegister) && stack.isEmpty()) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
}
a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path);
}
@@ -920,7 +920,7 @@ public class ActionListReader {
List<List<GraphTargetItem>> output2s = new ArrayList<>();
for (long size : cnt.getContainerSizes()) {
if (size == 0) {
output2s.add(new ArrayList<GraphTargetItem>());
output2s.add(new ArrayList<>());
continue;
}
ActionLocalData localData2;
@@ -122,7 +122,7 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple {
byte[] actionBytes = Action.actionsToBytes(actions, true, SWF.DEFAULT_VERSION);
try {
SWFInputStream rri = new SWFInputStream(swf, actionBytes);
ActionList newActions = ActionListReader.readActionList(new ArrayList<DisassemblyListener>(), rri, SWF.DEFAULT_VERSION, 0, actionBytes.length, "", -1);
ActionList newActions = ActionListReader.readActionList(new ArrayList<>(), rri, SWF.DEFAULT_VERSION, 0, actionBytes.length, "", -1);
actions.setActions(newActions);
} catch (IOException | InterruptedException ex) {
Logger.getLogger(ActionDeobfuscator.class.getName()).log(Level.SEVERE, null, ex);
@@ -392,9 +392,9 @@ public class ActionScript2Parser {
}
if (s.type == SymbolType.ASSIGN) {
if (isStatic) {
staticVars.add(new MyEntry<GraphTargetItem, GraphTargetItem>(pushConst(ident), expression(false, false, true, variables)));
staticVars.add(new MyEntry<>(pushConst(ident), expression(false, false, true, variables)));
} else {
vars.add(new MyEntry<GraphTargetItem, GraphTargetItem>(pushConst(ident), expression(false, false, true, variables)));
vars.add(new MyEntry<>(pushConst(ident), expression(false, false, true, variables)));
}
s = lex();
}
@@ -1850,7 +1850,7 @@ public class ActionScript2Parser {
ActionSourceGenerator gen = new ActionSourceGenerator(swfVersion, constantPool);
List<Action> ret = new ArrayList<>();
SourceGeneratorLocalData localData = new SourceGeneratorLocalData(
new HashMap<String, Integer>(), 0, Boolean.FALSE, 0);
new HashMap<>(), 0, Boolean.FALSE, 0);
List<GraphSourceItem> srcList = gen.generate(localData, tree);
for (GraphSourceItem s : srcList) {
if (s instanceof Action) {
@@ -582,7 +582,7 @@ public class ActionSourceGenerator implements SourceGenerator {
} while (item instanceof GetMemberActionItem);
if (item instanceof GetVariableActionItem) {
GetVariableActionItem v = (GetVariableActionItem) item;
item = new GetMemberActionItem(null, new GetVariableActionItem(null, new DirectValueActionItem(null, 0, "_global", new ArrayList<String>())), v.name);
item = new GetMemberActionItem(null, new GetVariableActionItem(null, new DirectValueActionItem(null, 0, "_global", new ArrayList<>())), v.name);
if (mem != null) {
mem.object = item;
}
@@ -682,7 +682,7 @@ public class ActionSourceGenerator implements SourceGenerator {
if (constructor == null) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
}
@@ -734,7 +734,7 @@ public class ActionSourceGenerator implements SourceGenerator {
if (constr.isEmpty()) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
}
@@ -148,7 +148,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
@Override
public void translateContainer(List<List<GraphTargetItem>> content, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<VariableActionItem>());
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList<>());
//ActionGraph.translateViaGraph(regNames, variables, functions, code, version)
stack.push(fti);
functions.put(functionName, fti);
@@ -288,7 +288,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
@Override
public void translateContainer(List<List<GraphTargetItem>> content, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<VariableActionItem>());
FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList<>());
functions.put(functionName, fti);
stack.push(fti);
}