/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.translator.language.helper;

import cx2x.translator.language.ClawLanguage;
import cx2x.translator.transformation.loop.LoopFusion;
import cx2x.xcodeml.transformation.Transformer;
import cx2x.xcodeml.xelement.XbaseElement;
import cx2x.xcodeml.xelement.XcodeProgram;
import cx2x.xcodeml.xelement.XdoStatement;
import xcodeml.util.XmOption;

/**
 * @author clementval
 */
public class TransformationHelper {


  /**
   *
   * @param claw
   * @param xcodeml
   * @param transformer
   * @param stmt
   */
  public static void generateAdditionalTransformation(ClawLanguage claw,
                                                      XcodeProgram xcodeml,
                                                      Transformer transformer,
                                                      XbaseElement stmt)
  {
    applyFusionClause(claw, xcodeml, transformer, stmt);
  }


  /**
   *
   * @param claw
   * @param xcodeml
   * @param transformer
   * @param stmt
   */
  private static void applyFusionClause(ClawLanguage claw,
                                        XcodeProgram xcodeml,
                                        Transformer transformer,
                                        XbaseElement stmt)
  {
    if(claw.hasFusionOption()){
      LoopFusion fusion = new LoopFusion((XdoStatement) stmt,
          claw.getGroupName(), claw.getPragma().getLineNo());
      transformer.addTransformation(fusion);

      if(XmOption.isDebugOutput()){
        System.out.println("Loop fusion added: " + claw.getGroupName());
      }
    }
  }

}

@@ -358,27 +358,27 @@
 lement.X
-codeProgram
+doStatement
 ;%0Aimport
@@ -374,37 +374,32 @@
 ent;%0Aimport 
-cx2x.
 xcodeml.
 xelement.Xdo
@@ -390,218 +390,731 @@
 eml.
-xelement.XdoStatement;%0Aimport xcodeml.util.XmOption;%0A%0A/**%0A * @author clementval%0A */%0Apublic class TransformationHelper %7B%0A%0A%0A  /**%0A   *%0A   * @param claw%0A   * @param xcodeml%0A   * @param transformer%0A   * @param stmt
+util.XmOption;%0A%0A/**%0A * The class TransformationHelper contains only static method to help the%0A * generation of additional transformation described as clause in main%0A * directive.%0A *%0A * @author clementval%0A */%0Apublic class TransformationHelper %7B%0A%0A%0A  /**%0A   * Generate corresponding additional transformation according to optional%0A   * clauses given to the directive.%0A   * @param claw        ClawLanguage object that tells encapsulates all%0A   *                    information about the current directives and its%0A   *                    clauses.%0A   * @param transformer Transformer object in which new transformation are%0A   *                    added.%0A   * @param stmt        Statement on which the transformation is attached.
 %0A   
@@ -1193,84 +1193,8 @@
 aw,%0A
-                                                      XcodeProgram xcodeml,%0A
     
@@ -1372,25 +1372,16 @@
 se(claw,
- xcodeml,
  transfo
@@ -1413,86 +1413,534 @@
    *
-%0A   * @param claw%0A   * @param xcodeml%0A   * @param transformer%0A   * @param stmt
+ Generate loop fusion transformation if the clause is present in the%0A   * directive.%0A   * @param claw        ClawLanguage object that tells encapsulates all%0A   *                    information about the current directives and its%0A   *                    clauses.%0A   * @param transformer Transformer object in which new transformation are%0A   *                    added.%0A   * @param stmt        Statement on which the transformation is attached. Must%0A   *                    be a FdoStatement for the loop fusion transformation.
 %0A   
@@ -2005,70 +2005,8 @@
 aw,%0A
-                                        XcodeProgram xcodeml,%0A
     
@@ -2158,16 +2158,48 @@
 Option()
+ && stmt instanceof XdoStatement
 )%7B%0A     

Add missing javadoc and remove redundant parameter