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

package cx2x.translator.transformation.claw;

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

/**
 * A Kcaching transformation is an independent transformation. The
 * transformation consists of placing an assignment in a scalar variable and
 * use this variable in a loop body before updating it.
 *
 * @author clementval
 */
public class Kcaching extends Transformation {
  private final ClawLanguage _claw;

  /**
   * Constructs a new Kcachine triggered from a specific pragma.
   * @param directive  The directive that triggered the k caching transformation.
   */
  public Kcaching(ClawLanguage directive) {
    super(directive);
    _claw = directive;
  }

  /**
   * @see Transformation#analyze(XcodeProgram, Transformer)
   */
  @Override
  public boolean analyze(XcodeProgram xcodeml, Transformer transformer) {
    return false;
  }

  /**
   * @see Transformation#canBeTransformedWith(Transformation)
   */
  @Override
  public boolean canBeTransformedWith(Transformation other) {
    // independant transformation
    return false;
  }

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

  }
}

@@ -186,16 +186,59 @@
 nguage;%0A
+import cx2x.xcodeml.helper.XelementHelper;%0A
 import c
@@ -280,16 +280,16 @@
 mation;%0A
-
 import c
@@ -324,24 +324,71 @@
 ransformer;%0A
+import cx2x.xcodeml.xelement.XassignStatement;%0A
 import cx2x.
@@ -734,16 +734,50 @@
 e _claw;
+%0A  private XassignStatement _stmt;
 %0A%0A  /**%0A
@@ -1099,32 +1099,32 @@
  */%0A  @Override%0A
-
   public boolean
@@ -1177,24 +1177,567 @@
 nsformer) %7B%0A
+    // pragma must be followed by an assign statement%0A    _stmt = XelementHelper.findDirectNextAssignStmt(_claw.getPragma());%0A    if(_stmt == null)%7B%0A      xcodeml.addError(%22Directive not follwed by an assign statement%22,%0A          _claw.getPragma().getLineNo());%0A      return false;%0A    %7D%0A    // Check if the LHS of the assign stmt is an array reference%0A    if(!_stmt.getLValueModel().isArrayRef())%7B%0A      xcodeml.addError(%22LHS of assign statement is not an array reference%22,%0A          _claw.getPragma().getLineNo());%0A      return false;%0A    %7D%0A
     return f

Set up first part of analysis