/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */
package cx2x.translator.transformation.utility;

import cx2x.translator.language.ClawLanguage;
import cx2x.xcodeml.transformation.Transformation;
import cx2x.xcodeml.transformation.Transformer;
import cx2x.xcodeml.xnode.XcodeProgram;

/**
 * Transformation to fix some issues raised in XcodeML.
 *
 * @author clementval
 */
public class XcodeMLWorkaround extends Transformation {

  private final ClawLanguage _claw;

  /**
   * XcodeMLWorkaround ctor.
   * @param claw The directive that triggered the transformation. In case of
   *             this specific transformation, there is no directive.
   */
  public XcodeMLWorkaround(ClawLanguage claw) {
    super(claw);
    _claw = claw;
  }

  @Override
  public boolean analyze(XcodeProgram xcodeml, Transformer transformer) {
    return true;
  }

  @Override
  public boolean canBeTransformedWith(Transformation other) {
    return false; // Independent transformation
  }

  @Override
  public void transform(XcodeProgram xcodeml, Transformer transformer,
                        Transformation other) throws Exception
  {


  }
}

@@ -188,16 +188,54 @@
 nguage;%0A
+import cx2x.xcodeml.helper.XnodeUtil;%0A
 import c
@@ -364,16 +364,87 @@
 Program;
+%0Aimport cx2x.xcodeml.xnode.XfunctionDefinition;%0A%0Aimport java.util.List;
 %0A%0A/**%0A *
@@ -587,45 +587,8 @@
  %7B%0A%0A
-  private final ClawLanguage _claw;%0A%0A
   /*
@@ -840,26 +840,8 @@
 w);%0A
-    _claw = claw;%0A
   %7D%0A
@@ -1226,16 +1226,411 @@
 ion%0A  %7B%0A
-%0A
+    checkDeclarations(xcodeml);%0A  %7D%0A%0A  /**%0A   * Check the declaration table of each function definition.%0A   * @param xcodeml Current XcodeML program unit.%0A   */%0A  private void checkDeclarations(XcodeProgram xcodeml)%7B%0A    List%3CXfunctionDefinition%3E definitions = XnodeUtil.getAllFctDef(xcodeml);%0A    for(XfunctionDefinition fct : definitions)%7B%0A      fct.getDeclarationTable().checkOrder(fct);%0A    %7D
 %0A  %7D%0A%7D%0A

Check all function definition