Commit 2f0ef17f authored by Lukáš Marek's avatar Lukáš Marek

DiSL ported to asm 4.0

parent 23061bdd
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/asm-all-3.3.jar"/>
<classpathentry kind="lib" path="lib/jborat-agent.jar"/>
<classpathentry kind="lib" path="lib/jborat-runtime.jar"/>
<classpathentry kind="lib" path="lib/jborat.jar"/>
<classpathentry kind="lib" path="lib/asm-debug-all-4.0_RC1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/jborat-agent.jar"/>
<classpathentry kind="lib" path="lib/jborat-runtime.jar"/>
<classpathentry kind="lib" path="lib/jborat.jar"/>
<classpathentry kind="lib" path="lib/asm-debug-all-4.0_RC1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -180,10 +180,7 @@ public class DiSL implements Instrumentation {
staticAnalysisInstances = new HashMap<Class<?>, Object>();
// instrument all methods in a class
for(Object methodObj : classNode.methods) {
// cast - ASM still uses Java 1.4 interface
MethodNode methodNode = (MethodNode) methodObj;
for(MethodNode methodNode : classNode.methods) {
instrumentMethod(classNode, methodNode);
}
......
......@@ -80,10 +80,7 @@ public class SnippetParser {
// get static initialization code
InsnList origInitCodeIL = null;
for (Object methodObj : classNode.methods) {
// cast - ASM still uses Java 1.4 interface
MethodNode method = (MethodNode) methodObj;
for (MethodNode method : classNode.methods) {
// get the code
if (method.name.equals(Constants.STATIC_INIT_NAME)) {
......@@ -102,10 +99,7 @@ public class SnippetParser {
// add local vars from this class to others
syntheticLocalVars.putAll(slVars);
for (Object methodObj : classNode.methods) {
// cast - ASM still uses Java 1.4 interface
MethodNode method = (MethodNode) methodObj;
for (MethodNode method : classNode.methods) {
// skip the constructor
if (method.name.equals(Constants.CONSTRUCTOR_NAME)) {
......@@ -129,15 +123,13 @@ public class SnippetParser {
}
private Map<String, SyntheticLocalVar> parseSyntheticLocalVars(
String className, List<?> fields) throws AnnotParserException {
String className, List<FieldNode> fields)
throws AnnotParserException {
Map<String, SyntheticLocalVar> result =
new HashMap<String, SyntheticLocalVar>();
for (Object fieldObj : fields) {
// cast - ASM still uses Java 1.4 interface
FieldNode field = (FieldNode) fieldObj;
for (FieldNode field : fields) {
if (field.invisibleAnnotations == null) {
throw new AnnotParserException("DiSL annotation for field "
......@@ -235,11 +227,9 @@ public class SnippetParser {
// more annotations on one snippet
// supported but we will have multiple snippets ;)
for (Object annotationObj : method.invisibleAnnotations) {
for (AnnotationNode annotation : method.invisibleAnnotations) {
MethodAnnotationData annotData =
// cast - ASM still uses Java 1.4 interface
parseMethodAnnotation((AnnotationNode) annotationObj);
MethodAnnotationData annotData = parseMethodAnnotation(annotation);
// if this is unknown annotation
if (!annotData.isKnown()) {
......
......@@ -155,6 +155,8 @@ public class StaticInfo {
// and store for later use
staticAnalysisInstances.put(methodClass, saInst);
}
// TODO ! analysis invoke setter method
// invoke static analysis method
Object result = stAnMethod.invoke(saInst, saInfo);
......
......@@ -66,7 +66,7 @@ public class InsnListHelper {
public static InsnList cloneList(InsnList src, AbstractInsnNode from,
AbstractInsnNode to) {
Map<AbstractInsnNode, AbstractInsnNode> map = new HashMap<AbstractInsnNode, AbstractInsnNode>();
Map<LabelNode, LabelNode> map = new HashMap<LabelNode, LabelNode>();
InsnList dst = new InsnList();
......@@ -74,7 +74,7 @@ public class InsnListHelper {
for (AbstractInsnNode instr : src.toArray()) {
if (instr instanceof LabelNode) {
LabelNode label = new LabelNode(new Label());
map.put(instr, label);
map.put((LabelNode) instr, label);
}
}
......@@ -203,21 +203,25 @@ public class InsnListHelper {
case AbstractInsnNode.LOOKUPSWITCH_INSN: {
// Covers LOOKUPSWITCH
for (Object label : ((LookupSwitchInsnNode) instruction).labels) {
bb_begins.add((AbstractInsnNode) label);
LookupSwitchInsnNode lsin = (LookupSwitchInsnNode) instruction;
for (LabelNode label : lsin.labels) {
bb_begins.add(label);
}
bb_begins.add(((LookupSwitchInsnNode) instruction).dflt);
bb_begins.add(lsin.dflt);
break;
}
case AbstractInsnNode.TABLESWITCH_INSN: {
// Covers TABLESWITCH
for (Object label : ((TableSwitchInsnNode) instruction).labels) {
bb_begins.add((AbstractInsnNode) label);
TableSwitchInsnNode tsin = (TableSwitchInsnNode) instruction;
for (LabelNode label : tsin.labels) {
bb_begins.add(label);
}
bb_begins.add(((TableSwitchInsnNode) instruction).dflt);
bb_begins.add(tsin.dflt);
break;
}
......@@ -226,8 +230,8 @@ public class InsnListHelper {
}
}
for (Object try_catch_block : method.tryCatchBlocks) {
bb_begins.add(((TryCatchBlockNode) try_catch_block).handler);
for (TryCatchBlockNode try_catch_block : method.tryCatchBlocks) {
bb_begins.add(try_catch_block.handler);
}
// Sort
......
......@@ -4,6 +4,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/DiSL"/>
<classpathentry kind="lib" path="/DiSL/lib/jborat.jar"/>
<classpathentry kind="lib" path="/DiSL/lib/asm-all-3.3.jar"/>
<classpathentry kind="lib" path="/DiSL/lib/asm-debug-all-4.0_RC1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
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