Commit 31f558ca authored by Lubomir Bulej's avatar Lubomir Bulej

Use lambdas in AsmHelper

parent 7985b098
package ch.usi.dag.disl;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.LookupSwitchInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TableSwitchInsnNode;
import org.objectweb.asm.tree.TryCatchBlockNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
public abstract class AsmHelper {
......@@ -515,7 +541,7 @@ public abstract class AsmHelper {
// Clone all the labels and key them to the original label.
// LB: Consider using an instruction filter.
//
final Map <LabelNode, LabelNode> result = new HashMap <LabelNode, LabelNode> ();
final Map <LabelNode, LabelNode> result = new HashMap <> ();
for (final AbstractInsnNode insn : Insns.selectAll (insnList)) {
if (insn instanceof LabelNode) {
final LabelNode clone = new LabelNode (new Label ());
......@@ -549,7 +575,7 @@ public abstract class AsmHelper {
final List <TryCatchBlockNode> tryCatchBlocks,
final Map <LabelNode, LabelNode> replacementLabels
) {
final List <TryCatchBlockNode> result = new LinkedList <TryCatchBlockNode> ();
final List <TryCatchBlockNode> result = new LinkedList <> ();
for (final TryCatchBlockNode tcb : tryCatchBlocks) {
final TryCatchBlockNode tcbClone = new TryCatchBlockNode (
replacementLabels.get (tcb.start),
......@@ -644,12 +670,7 @@ public abstract class AsmHelper {
* @return An {@link Iterable} instance for the given instruction list.
*/
public static Iterable <AbstractInsnNode> selectAll (final InsnList list) {
return new Iterable <AbstractInsnNode> () {
@Override
public Iterator <AbstractInsnNode> iterator () {
return list.iterator ();
}
};
return () -> list.iterator ();
}
......@@ -662,12 +683,7 @@ public abstract class AsmHelper {
* @return An {@link Iterable} instance for the given instruction list.
*/
public static Iterable <AbstractInsnNode> selectReal (final InsnList list) {
return new Iterable <AbstractInsnNode> () {
@Override
public Iterator <AbstractInsnNode> iterator () {
return __onlyRealInsnsIterator (list);
}
};
return () -> __onlyRealInsnsIterator (list);
}
private static Iterator <AbstractInsnNode> __onlyRealInsnsIterator (final InsnList list) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment