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