Author: luc
Date: Tue Oct 2 15:14:34 2012
New Revision: 1392962
URL: http://svn.apache.org/viewvc?rev=1392962&view=rev
Log:
Prepare differentiation of multiple methods in one class.
The differentiate method in MethodDifferentiator is now reentrant. This
will allow future handling of INVOKEVIRTUAL instructions.
Modified:
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ClassDifferentiator.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
Modified:
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ClassDifferentiator.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ClassDifferentiator.java?rev=1392962&r1=1392961&r2=1392962&view=diff
==============================================================================
---
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ClassDifferentiator.java
(original)
+++
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ClassDifferentiator.java
Tue Oct 2 15:14:34 2012
@@ -147,10 +147,9 @@ public class ClassDifferentiator {
if (method.name.equals(name) && method.desc.equals(primitiveDesc))
{
final MethodDifferentiator differentiator =
- new MethodDifferentiator(mathClasses, classNode.name);
+ new MethodDifferentiator(mathClasses, classNode);
differentiator.differentiate(primitiveNode.name, method,
Type.getMethodType(derivativeDesc));
- classNode.methods.add(method);
}
}
Modified:
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java?rev=1392962&r1=1392961&r2=1392962&view=diff
==============================================================================
---
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
(original)
+++
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
Tue Oct 2 15:14:34 2012
@@ -52,6 +52,7 @@ import org.apache.commons.nabla.forward.
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
@@ -72,8 +73,8 @@ public class MethodDifferentiator {
/** Math implementation classes. */
private final Set<String> mathClasses;
- /** Name of the derived class. */
- private final String derivedName;
+ /** Derived class (which is under construction). */
+ private final ClassNode derivedClass;
/** Set of converted values. */
private final Set<TrackingValue> converted;
@@ -88,9 +89,9 @@ public class MethodDifferentiator {
* @param mathClasses math implementation classes
* @param derivedName name of the derived class
*/
- public MethodDifferentiator(final Set<String> mathClasses, final String
derivedName) {
+ public MethodDifferentiator(final Set<String> mathClasses, final ClassNode
derivedClass) {
this.mathClasses = mathClasses;
- this.derivedName = derivedName;
+ this.derivedClass = derivedClass;
this.converted = new HashSet<TrackingValue>();
this.frames = new IdentityHashMap<AbstractInsnNode,
Frame<TrackingValue>>();
this.successors = new IdentityHashMap<AbstractInsnNode,
Set<AbstractInsnNode>>();
@@ -100,7 +101,7 @@ public class MethodDifferentiator {
* @return name of the derived class
*/
public String getDerivedName() {
- return derivedName;
+ return derivedClass.name;
}
/**
@@ -173,6 +174,10 @@ public class MethodDifferentiator {
method.access |= Opcodes.ACC_SYNTHETIC;
method.maxLocals = dsIndex + 1;
+ // store the new method in the class
+ derivedClass.methods.add(method);
+
+
} catch (AnalyzerException ae) {
ae.printStackTrace(System.err);
if ((ae.getCause() != null) && ae.getCause() instanceof
DifferentiationException) {