// ===========================================================================
// This file has been generated by
// xtc Factory Factory, version 1.13.3,
// (C) 2004-2008 Robert Grimm,
// on Tuesday, June 3, 2008 at 4:37:06 PM.
// Edit at your own risk.
// ===========================================================================

package xtc.lang.c4;

import java.util.List;

import xtc.tree.Node;
import xtc.tree.GNode;

/**
 * Node factory <code>xtc.lang.c4.C4CFactory</code>.
 *
 * <p />This class has been generated by
 * the xtc Factory Factory, version 1.13.3,
 * (C) 2004-2008 Robert Grimm.
 */
public class C4CFactory {

  /** Create a new node factory. */
  public C4CFactory() {
    // Nothing to do.
  }

  /**
   * Create a compound statement.
   *
   * @param statements The statements.
   * @return The generic node.
   */
  public Node createBlock(List<Node> statements) {
    Node v$1 = GNode.create("CompoundStatement", statements.size() + 1).
      addAll(statements).add(null);
    return v$1;
  }

  /**
   * Create a compound statement.
   *
   * @param leftVal The leftVal.
   * @param rightVal The rightVal.
   * @param label The label.
   * @return The generic node.
   */
  public Node createAfterAdviceReturnReplacement(Node leftVal, Node rightVal, 
                                                 String label) {
    Node v$1 = GNode.create("AssignmentExpression", leftVal, "=", rightVal);
    Node v$2 = GNode.create("ExpressionStatement", v$1);
    Node v$3 = GNode.create("PrimaryIdentifier", label);
    Node v$4 = GNode.create("GotoStatement", null, v$3);
    Node v$5 = GNode.create("CompoundStatement", v$2, v$4, null);
    return v$5;
  }

  /**
   * Create a declaration.
   *
   * @param varName The varName.
   * @return The generic node.
   */
  public Node createPointerDeclaration(String varName) {
    Node v$1 = GNode.create("TypedefName", "someType");
    Node v$2 = GNode.create("DeclarationSpecifiers", v$1);
    Node v$3 = GNode.create("TypeQualifierList", false);
    Node v$4 = GNode.create("Pointer", v$3, null);
    Node v$5 = GNode.create("SimpleDeclarator", varName);
    Node v$6 = GNode.create("PointerDeclarator", v$4, v$5);
    Node v$7 = GNode.create("InitializedDeclarator", null, v$6, null, null, 
      null);
    Node v$8 = GNode.create("InitializedDeclaratorList", v$7);
    Node v$9 = GNode.create("Declaration", null, v$2, v$8);
    return v$9;
  }

  /**
   * Create a declaration.
   *
   * @param varName The varName.
   * @return The generic node.
   */
  public Node createDeclaration(String varName) {
    Node v$1 = GNode.create("TypedefName", "someType");
    Node v$2 = GNode.create("DeclarationSpecifiers", v$1);
    Node v$3 = GNode.create("SimpleDeclarator", varName);
    Node v$4 = GNode.create("InitializedDeclarator", null, v$3, null, null, 
      null);
    Node v$5 = GNode.create("InitializedDeclaratorList", v$4);
    Node v$6 = GNode.create("Declaration", null, v$2, v$5);
    return v$6;
  }

  /**
   * Create an expression statement.
   *
   * @param leftVal The leftVal.
   * @param rightVal The rightVal.
   * @return The generic node.
   */
  public Node createAssignemnt(Node leftVal, Node rightVal) {
    Node v$1 = GNode.create("AssignmentExpression", leftVal, "=", rightVal);
    Node v$2 = GNode.create("ExpressionStatement", v$1);
    return v$2;
  }

  /**
   * Create an expression statement.
   *
   * @param struct The struct.
   * @param field The field.
   * @param val The val.
   * @return The generic node.
   */
  public Node createDirectStructFieldAccessAssignment(Node struct, 
                                                      String field, Node val) {
    Node v$1 = GNode.create("DirectComponentSelection", struct, field);
    Node v$2 = GNode.create("AssignmentExpression", v$1, "=", val);
    Node v$3 = GNode.create("ExpressionStatement", v$2);
    return v$3;
  }

  /**
   * Create an expression statement.
   *
   * @param struct The struct.
   * @param field The field.
   * @return The generic node.
   */
  public Node createDirectStructFieldAccess(Node struct, String field) {
    Node v$1 = GNode.create("DirectComponentSelection", struct, field);
    Node v$2 = GNode.create("ExpressionStatement", v$1);
    return v$2;
  }

  /**
   * Create an expression statement.
   *
   * @param struct The struct.
   * @param field The field.
   * @param val The val.
   * @return The generic node.
   */
  public Node createIndirectStructFieldAccessAssignment(Node struct, 
                                                        String field, Node val) {
    Node v$1 = GNode.create("IndirectComponentSelection", struct, field);
    Node v$2 = GNode.create("AssignmentExpression", v$1, "=", val);
    Node v$3 = GNode.create("ExpressionStatement", v$2);
    return v$3;
  }

  /**
   * Create an expression statement.
   *
   * @param struct The struct.
   * @param field The field.
   * @return The generic node.
   */
  public Node createIndirectStructFieldAccess(Node struct, String field) {
    Node v$1 = GNode.create("IndirectComponentSelection", struct, field);
    Node v$2 = GNode.create("ExpressionStatement", v$1);
    return v$2;
  }

  /**
   * Create a declaration.
   *
   * @param tag The tag.
   * @param statements The statements.
   * @return The generic node.
   */
  public Node createStructDeclaration(String tag, List<Node> statements) {
    Node v$1 = GNode.create("StructureDeclarationList", statements.size() + 1).
      addAll(statements).add(null);
    Node v$2 = GNode.create("StructureTypeDefinition", null, tag, v$1, null);
    Node v$3 = GNode.create("DeclarationSpecifiers", v$2);
    Node v$4 = GNode.create("Declaration", null, v$3, null);
    return v$4;
  }

  /**
   * Create a function call.
   *
   * @param functionName The functionName.
   * @param arguments The arguments.
   * @return The generic node.
   */
  public Node createFunctionCall(Node functionName, List<Node> arguments) {
    Node v$1 = GNode.create("ExpressionList", arguments.size()).
      addAll(arguments);
    Node v$2 = GNode.create("FunctionCall", functionName, v$1);
    return v$2;
  }

  /**
   * Create a goto statement.
   *
   * @param label The label.
   * @return The generic node.
   */
  public Node createGoto(String label) {
    Node v$1 = GNode.create("PrimaryIdentifier", label);
    Node v$2 = GNode.create("GotoStatement", null, v$1);
    return v$2;
  }

  /**
   * Create a labeled statement.
   *
   * @param label The label.
   * @return The generic node.
   */
  public Node createLabel(String label) {
    Node v$1 = GNode.create("NamedLabel", label, null);
    Node v$2 = GNode.create("LabeledStatement", v$1, null);
    return v$2;
  }

  /**
   * Create a declaration.
   *
   * @param ptr The ptr.
   * @return The generic node.
   */
  public Node createLabelPointerDeclaration(String ptr) {
    Node v$1 = GNode.create("VoidTypeSpecifier", false);
    Node v$2 = GNode.create("DeclarationSpecifiers", v$1);
    Node v$3 = GNode.create("TypeQualifierList", false);
    Node v$4 = GNode.create("Pointer", v$3, null);
    Node v$5 = GNode.create("SimpleDeclarator", ptr);
    Node v$6 = GNode.create("PointerDeclarator", v$4, v$5);
    Node v$7 = GNode.create("InitializedDeclarator", null, v$6, null, null, 
      null);
    Node v$8 = GNode.create("InitializedDeclaratorList", v$7);
    Node v$9 = GNode.create("Declaration", null, v$2, v$8);
    return v$9;
  }

  /**
   * Create an expression statement.
   *
   * @param ptr The ptr.
   * @param label The label.
   * @return The generic node.
   */
  public Node createLabelAddressExpression(Node ptr, String label) {
    Node v$1 = GNode.create("LabelAddressExpression", label);
    Node v$2 = GNode.create("AssignmentExpression", ptr, "=", v$1);
    Node v$3 = GNode.create("ExpressionStatement", v$2);
    return v$3;
  }

  /**
   * Create a goto statement.
   *
   * @param ptr The ptr.
   * @return The generic node.
   */
  public Node createGotoAddress(Node ptr) {
    Node v$1 = GNode.create("GotoStatement", "*", ptr);
    return v$1;
  }

  /**
   * Create a return statement.
   *
   * @param val The val.
   * @return The generic node.
   */
  public Node createReturnWithVal(Node val) {
    Node v$1 = GNode.create("ReturnStatement", val);
    return v$1;
  }

  /**
   * Create a return statement.
   *
   * @return The generic node.
   */
  public Node createReturn() {
    Node v$1 = GNode.create("ReturnStatement", null);
    return v$1;
  }

}
