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

java.lang.Object
  extended by org.apache.commons.nabla.algorithmic.forward.analysis.ClassDifferentiator
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor

public class ClassDifferentiator
extends Object
implements org.objectweb.asm.ClassVisitor

Visitor (in asm sense) for differentiating classes.

This visitor visits classes implementing the UnivariateDifferentiable interface and convert them to classes implementing the UnivariateDerivative interface.

The visitor creates a new class as an inner class of the visited class. Instances of the generated class are therefore automatically bound to their primitive instance which is their directly enclosing instance. As such they have access to the current value of all fields.

The visited class bytecode is not changed at all.


Constructor Summary
ClassDifferentiator(Set<String> mathClasses, org.objectweb.asm.ClassVisitor generator)
          Simple constructor.
 
Method Summary
 String getDerivativeClassName()
          Get the name of the derivative class.
 void reportErrors()
          Report the errors that may have occurred during analysis.
 void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
          
 org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc, boolean visible)
          
 void visitAttribute(org.objectweb.asm.Attribute attr)
          
 void visitEnd()
          
 org.objectweb.asm.FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
          
 void visitInnerClass(String name, String outerName, String innerName, int access)
          
 org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
          
 void visitOuterClass(String owner, String name, String desc)
          
 void visitSource(String source, String debug)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassDifferentiator

public ClassDifferentiator(Set<String> mathClasses,
                           org.objectweb.asm.ClassVisitor generator)
Simple constructor.

Parameters:
mathClasses - math implementation classes
generator - visitor to which class generation calls will be delegated
Method Detail

getDerivativeClassName

public String getDerivativeClassName()
Get the name of the derivative class.

Returns:
name of the (generated) derivative class

visit

public void visit(int version,
                  int access,
                  String name,
                  String signature,
                  String superName,
                  String[] interfaces)

Specified by:
visit in interface org.objectweb.asm.ClassVisitor

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   String name,
                                                   String desc,
                                                   String signature,
                                                   String[] exceptions)

Specified by:
visitMethod in interface org.objectweb.asm.ClassVisitor

visitField

public org.objectweb.asm.FieldVisitor visitField(int access,
                                                 String name,
                                                 String desc,
                                                 String signature,
                                                 Object value)

Specified by:
visitField in interface org.objectweb.asm.ClassVisitor

visitSource

public void visitSource(String source,
                        String debug)

Specified by:
visitSource in interface org.objectweb.asm.ClassVisitor

visitOuterClass

public void visitOuterClass(String owner,
                            String name,
                            String desc)

Specified by:
visitOuterClass in interface org.objectweb.asm.ClassVisitor

visitAnnotation

public org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc,
                                                           boolean visible)

Specified by:
visitAnnotation in interface org.objectweb.asm.ClassVisitor

visitAttribute

public void visitAttribute(org.objectweb.asm.Attribute attr)

Specified by:
visitAttribute in interface org.objectweb.asm.ClassVisitor

visitInnerClass

public void visitInnerClass(String name,
                            String outerName,
                            String innerName,
                            int access)

Specified by:
visitInnerClass in interface org.objectweb.asm.ClassVisitor

visitEnd

public void visitEnd()

Specified by:
visitEnd in interface org.objectweb.asm.ClassVisitor

reportErrors

public void reportErrors()
                  throws DifferentiationException
Report the errors that may have occurred during analysis.

Throws:
DifferentiationException - if the derivative class could not be generated


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