org.apache.commons.nabla.algorithmic.forward.analysis
Class MethodDifferentiator

java.lang.Object
  extended by org.objectweb.asm.tree.MemberNode
      extended by org.objectweb.asm.tree.MethodNode
          extended by org.apache.commons.nabla.algorithmic.forward.analysis.MethodDifferentiator
All Implemented Interfaces:
org.objectweb.asm.MethodVisitor

public class MethodDifferentiator
extends org.objectweb.asm.tree.MethodNode

Class transforming a method computing a value to a method computing both a value and its differential.


Field Summary
static String DP_DESCRIPTOR
          Descriptor for the DifferentialPair class.
static String DP_NAME
          Name for the DifferentialPair class.
static String DP_RETURN_DP_DESCRIPTOR
          Descriptor for the derivative class f method.
 
Fields inherited from class org.objectweb.asm.tree.MethodNode
access, annotationDefault, desc, exceptions, instructions, invisibleParameterAnnotations, localVariables, maxLocals, maxStack, name, signature, tryCatchBlocks, visibleParameterAnnotations
 
Fields inherited from class org.objectweb.asm.tree.MemberNode
attrs, invisibleAnnotations, visibleAnnotations
 
Constructor Summary
MethodDifferentiator(int access, String name, String desc, String signature, String[] exceptions, org.objectweb.asm.MethodVisitor generator, String primitiveName, Set<String> mathClasses, ErrorReporter errorReporter)
          Build a differentiator for a method.
 
Method Summary
 org.objectweb.asm.tree.AbstractInsnNode clone(org.objectweb.asm.tree.AbstractInsnNode insn)
          Clone an instruction.
 int getTmp(int number)
          Get index of a size 2 temporary variable.
 boolean isMathImplementationClass(String name)
          Test if a class is a math implementation class.
 void shiftVariable(org.objectweb.asm.tree.VarInsnNode insn)
          Shifted the index of a variable instruction.
 void useLocal(int index, int size)
          Set a local variable as used by the modified code.
 void visitEnd()
          
 
Methods inherited from class org.objectweb.asm.tree.MethodNode
accept, accept, getLabelNode, visitAnnotationDefault, visitCode, visitFieldInsn, visitFrame, visitIincInsn, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn, visitVarInsn
 
Methods inherited from class org.objectweb.asm.tree.MemberNode
visitAnnotation, visitAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.asm.MethodVisitor
visitAnnotation, visitAttribute
 

Field Detail

DP_NAME

public static final String DP_NAME
Name for the DifferentialPair class.


DP_DESCRIPTOR

public static final String DP_DESCRIPTOR
Descriptor for the DifferentialPair class.


DP_RETURN_DP_DESCRIPTOR

public static final String DP_RETURN_DP_DESCRIPTOR
Descriptor for the derivative class f method.

Constructor Detail

MethodDifferentiator

public MethodDifferentiator(int access,
                            String name,
                            String desc,
                            String signature,
                            String[] exceptions,
                            org.objectweb.asm.MethodVisitor generator,
                            String primitiveName,
                            Set<String> mathClasses,
                            ErrorReporter errorReporter)
Build a differentiator for a method.

Parameters:
access - access flags of the method
name - name of the method
desc - descriptor of the method
signature - signature of the method
exceptions - exceptions thrown by the method
generator - bytecode generator to use for the transformed method
primitiveName - primitive class name
mathClasses - math implementation classes
errorReporter - reporter used for delaying exceptions
Method Detail

visitEnd

public void visitEnd()

Specified by:
visitEnd in interface org.objectweb.asm.MethodVisitor
Overrides:
visitEnd in class org.objectweb.asm.tree.MemberNode

isMathImplementationClass

public boolean isMathImplementationClass(String name)
Test if a class is a math implementation class.

Parameters:
name - name of the class to test
Returns:
true if the named class is a math implementation class

useLocal

public void useLocal(int index,
                     int size)
              throws DifferentiationException
Set a local variable as used by the modified code.

Parameters:
index - index of the variable
size - size of the variable (1 or 2 for standard variables, 4 for special expanded differential pairs)
Throws:
DifferentiationException - if the number of the temporary variable lies outside of the allowed range

getTmp

public int getTmp(int number)
           throws DifferentiationException
Get index of a size 2 temporary variable.

Temporary variables can be used for very short duration storage of size 2 values (i.e one double, or one long or two integers). These variables are reused in many replacement instructions sequences, so their content may be overridden at any time: they should be considered to have a scope limited to one replacement sequence only. This means that one should not store a value in a variable in one replacement sequence and retrieve it later in another replacement sequence as it may have been overridden in between.

At most 5 temporary variables may be used.

Parameters:
number - number of the temporary variable (must be between 1 and the maximal number of available temporary variables)
Returns:
index of the variable within the local variables array
Throws:
DifferentiationException - if the number of the temporary variable lies outside of the allowed range

shiftVariable

public void shiftVariable(org.objectweb.asm.tree.VarInsnNode insn)
Shifted the index of a variable instruction.

Parameters:
insn - variable instruction

clone

public org.objectweb.asm.tree.AbstractInsnNode clone(org.objectweb.asm.tree.AbstractInsnNode insn)
Clone an instruction.

Parameters:
insn - instruction to clone
Returns:
cloned instruction


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.