Commit d87bc376 authored by Yudi Zheng's avatar Yudi Zheng
Browse files

Redefine MarkedRegion, change the filed 'end' to a list for multiple exits. Fix the body marker.

parent a796a733
......@@ -3,6 +3,8 @@ package ch.usi.dag.disl.snippet.marker;
import java.util.LinkedList;
import java.util.List;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
......@@ -14,9 +16,14 @@ public class BodyMarker implements Marker {
InsnList ilst = method.instructions;
MarkedRegion region = new MarkedRegion();
region.start = ilst.getFirst();
// FIXME Does the region contain the return-instruction?
// What about a try-finally block?
region.end = ilst.getLast();
for (AbstractInsnNode instr : method.instructions.toArray()) {
int opcode = instr.getOpcode();
if (opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)
region.addExitPoint(instr.getPrevious());
}
regions.add(region);
return regions;
}
......
package ch.usi.dag.disl.snippet.marker;
import java.util.LinkedList;
import java.util.List;
import org.objectweb.asm.tree.AbstractInsnNode;
public class MarkedRegion {
public AbstractInsnNode start;
public AbstractInsnNode end;
public List<AbstractInsnNode> ends;
public MarkedRegion() {
this.start = null;
this.end = null;
this.ends = new LinkedList<AbstractInsnNode>();
}
public MarkedRegion(AbstractInsnNode start, AbstractInsnNode end) {
this.start = start;
this.end = end;
this.ends = new LinkedList<AbstractInsnNode>();
this.ends.add(end);
}
public void addExitPoint(AbstractInsnNode exitpoint) {
this.ends.add(exitpoint);
}
}
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