Class Transform

java.lang.Object
edu.udel.cis.vsl.abc.transform.IF.Transform

public class Transform extends Object
This class manages the set of transformations provided by an execution of ABC. It provides a static method newTransformer(String, ASTFactory) to create a new transformer instance based on the transformer code. It also provides a method that lists all the known codes. If you create a new Transformer, you may edit this file so it knows about your transformer, following the pattern of the others: simply add an entry to array records. It is not required for you to do so---your transformer can be used to transform a program whether or not it appears here. The advantage of appearing here is that a switch will be automatically added to the command line interface for all transformers appearing here. Alternatively, you can add your transformer at runtime using method addTransform(TransformRecord).
  • Constructor Details

    • Transform

      public Transform()
  • Method Details

    • addTransform

      public static void addTransform(TransformRecord record)
      Adds a new transform to the collection of known ones. Use this method if you don't want to hardwire your transform in to the ABC code base. You will need to create an instance of TransformRecord, for example, in the anonymous way done above with the built-in transforms. It can be added at any time but usually it is done in some initialization phase.
      Parameters:
      record - a transform record
      Throws:
      ABCRuntimeException - if there is already a transform with the given code in this current collection
    • getCodes

      public static Collection<String> getCodes()
      Returns the set of transformer codes.
      Returns:
      the set of transformer codes
    • getShortDescription

      public static String getShortDescription(String code)
      Returns the short description associated to the given transformer code.
      Parameters:
      code - a transformer code currently in the collection
      Returns:
      the short description of the transformation
      Throws:
      ABCRuntimeException - if there is no such code in the current collection
    • getLongName

      public static String getLongName(String code)
      Returns the long name associated to the given transformer code.
      Parameters:
      code - a transformer code currently in the collection
      Returns:
      the long name of that transformer, e.g., "MPITransformer"
      Throws:
      ABCRuntimeException - if there is no such code in the current collection
    • getRecord

      public static TransformRecord getRecord(String code)
      Returns the TransformRecord with the given code, or null if no such record exists.
      Parameters:
      code - a transformer code
      Returns:
      the TransformRecord with that code or null
    • newTransformer

      public static Transformer newTransformer(String code, ASTFactory astFactory)
      Produces a new transformer using the given AST Factory. The kind of transformer produced is determined by the given code, which is a string. This string is a short name used to identify the transformer, e.g., "prune" for the Pruner. The short name can also be used as a commandline flag to induce use of that transformer, e.g., "abc -prune foo.c". The given AST Factory become permanently identified with the new transformer. That transformer can only operate on ASTs that were produced with the same AST Factory.
      Parameters:
      code - a short string indicating the kind of transformer to produce
      astFactory - the AST factory that will is used to produce all the ASTs upon which the new transformer will operate
      Returns:
      a new transformer instance of the specified kind
      Throws:
      ABCRuntimeException - if there is no such code in the current collection
    • compareCombiner

      public static Combiner compareCombiner()
      Gets the compare combiner for combining two CIVL programs into one which compares the two for functional equivalence.
      Returns:
      the new compare combiner
    • nameTransformer

      public static NameTransformer nameTransformer(Map<Entity,String> newNameMap, ASTFactory astFactory)