# XForm Release History and Notes

1.8.?? (2/15/07)
  Minor bug fix release.

  Bug fixes:

  - Driver now defaults to one run instead of two.
  - For expressions double counting bug has been fixed.
  - Nested new node creation correctly modifies the AST.

1.8.2 (8/31/06)
  Minor feature and bug fix release

  This release adds minor changes to the XForm grammar along with some bug fixes

  The XForm Grammar has been changed as follows:

  - The grammar now supports item removal operations. For example

              remove //IfStatement

    removes all IfStatements from the AST.
  - The grammar now supports addition operations. For example,

               add Foo<> to //Bar

    adds a Foo node as the last child to all Bar nodes.

  Bug fixes:

  - Bad or out of range predicates no longer cause RuntimeException. Instead empty Sequences are returned.

1.8.0 (6/6/06)
  Major feature and bug fix release.

  This release modifies the XForm driver to improve command line support for program manipulation. It also adds some useful library functions to the XForm package. This is aimed at making it easier for users to implement program transformations using pure XForm. This release also modifies XForm's grammar and engine to add more functionality and fix minor bugs.

  The XForm Grammar has been changed as follows:
  - The grammar now supports item insertion operations. Two flavours of insert are supported, "insert before" and "insert after"
    For example

         insert Foo<> before //Bar

    inserts Foo nodes before all Bar nodes in the AST
  - XForm now provides an 'differ' operator to determine the logical difference of two sets. The differ operation returns the elements in the first set that are not contained in the second
    For example, the query

        //IfStatement differ //IfStatement[ Block ]

    returns a list of all IfStatements that do not have a Block
  - Function calls can be used as predicates. example //Block[ last(.) ]
  - Function call arguments can be sequences, strings, or integers

  The XForm Engine has changed as follows:
  - It is now possible to use expressions as predicates. This feature was unimplemented in previous versions.
    For example

        //IfStatement[ Block ]

    returns all IfStatement nodes that have a Block child.
  - Nested new Item creation now functions properly
  - Several minor bug fixes

  The XForm Driver has changed as follows:
  - It is now possible use command line options to specify the parser that the XForm driver should use. This change is intended to improve XForms flexibility. For example, a user defines a grammar and generates a parser for an extension to Java named JExt. JExt is to be desugared to Java using XForm. Instead of writing a JExtDriver, one can use XForm with the command options "-parser xtc.lang.JExtParser" and "-unit CompilationUnit". The -parser option instructs the driver to use the JavaExtParser and the -unit option indicates that the program unit is named CompilationUnit. The -c and -java options are still available and specify XTC's default C and Java parsers.
    Additionally the -printer option specifies the printer for pretty-printing post-query source code. The -printC and -printJava options indicate that the XForm driver is to use XTC's default JavaPrinter and CPrinter
    For the example extension JExt, a complete command line for a desugaring transformation with XForm and printing the resulting Java code could be "java xtc.xform.Driver -parser xtc.lang.JExtParser -unit CompilationUnit -printJava jextdesug.xform test.jext"
    Note: the command line options have changed
  - Functionality and command line options for XForm perfomance evaluations have been added.
  - To take advantage of new tool builiding support provided by xtc, the XForm Driver has been rewritten to use the xtc.util.Tool class. This rewrite changes some of the driver's command line options.
  - XForm driver now has default optiosn for manipulating both C and Java source files. C files are specified with the -c command line option and Java files with -java.

  The XForm function library has changed as follows:
  - Added library functions for string manipulation including: concat(), substring(), uppercase()
  - Added the lines(), count(), empty(), last(), and subsequence() library function
  - It is no longer necessary to do explicit imports for built-in Xform functions. Import statements are still required for user added functions, however.
  - Library functions can now return Objects instead of Lists. This allows users to write library functions that return Integer values. These functions can then be used as predicates in queries.
    For example, the library function last(.) returns the index of the last item in a sequence, so the query:

        //Block/*[ last(.) ]

    returns the last child of each Block node in the AST

  The XForm samples set has been changed as follows:
  - Added a sample java extension and desugaring transformation to xform/samples/javaproperty. This extension add C# like properties to Java. It is desugared to Java using an XForm transformation.
  - Added more example queries to the xform/samples directory. These include queries to detect coding convention violations in Java code (Find if statements without braces, for example), and queries to correct some coding conventions errors (example, add missing braces).

Pre 1.8.0 Release Notes

This release introduces several changes to XForm. For more details, see the xtc.xform package notes.

- It is now possible to perform logical operations on queries.

- As of this release, support for the `function_directory` file has been removed from XForm and a new mechanism for loading external functions has been introduced. If you'd like to use an external function within your query, you must first include an `import` statement at the beginning of your query.

- In previous versions of XForm, if a query consisted of several comma-separated expressions, the values of each expression were simply concatenated into a single list (with null values being ignored) and returned. Now, the result of a list of expressions is a list of the values of each expression. Whereas this list isimplicitly flattened within the context of the engine, the `run` method will return a list of lists. Furthermore, the results of each expression will provide an implicit focus for the expression that follows it.

  For example, the query

        //IfStatement, CompoundStatement

  will return a list of two lists. The first list will contain all `IfStatement` nodes in the AST, whereas the second list will contain all `CompoundStatement` children of `IfStatement` nodes. This feature has proven helpful when attempting to gather statistics about a body of source code.

- "Inside-out" traversal of an AST is now possible. To perform an inside-out traversal of the AST, use the `inside_out` path specifier. For example:

        inside_out ForStatement/CompoundStatement

  The above code will perform a bottom-up, breadth-first traversal of the AST, searching for any `CompoundStatement` children of `ForStatement` nodes.

- Replacement expressions now return the items that were inserted (or moved) within the tree, rather than the root of the tree.

- The following other changes have also been made to the XForm implementation:
  - The `xtc.xform.Parent` class has been removed, and its functionality has been subsumed by the `xtc.xform.Item` class.
  - The `test` method of the `QueryVisitor` class has been rewritten for efficiency.
  - The engine now stores its own copy of the target AST in an internal format that caches paths up and down the tree. This change has lead to a drastic reduction in the number of objects allocated while performing a query (a factor of 90).