Search in sources :

Example 16 with IllegalTransformationException

use of cx2x.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.

the class XnodeUtil method appendBody.

/**
   * Insert all the statements from a given body at the end of another body
   *
   * @param originalBody The body in which the extra body will be appended
   * @param extraBody    The body that will be appended to the original body
   * @throws IllegalTransformationException if one of the body or their base
   *                                        element is null.
   */
public static void appendBody(Xnode originalBody, Xnode extraBody) throws IllegalTransformationException {
    if (originalBody == null || originalBody.element() == null || extraBody == null || extraBody.element() == null || originalBody.opcode() != Xcode.BODY || extraBody.opcode() != Xcode.BODY) {
        throw new IllegalTransformationException("One of the body is null.");
    }
    // Append content of loop-body (loop) to this loop-body
    Node childNode = extraBody.element().getFirstChild();
    while (childNode != null) {
        Node nextChild = childNode.getNextSibling();
        // Do something with childNode, including move or delete...
        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
            originalBody.element().appendChild(childNode);
        }
        childNode = nextChild;
    }
}
Also used : IllegalTransformationException(cx2x.xcodeml.exception.IllegalTransformationException) Node(org.w3c.dom.Node)

Aggregations

IllegalTransformationException (cx2x.xcodeml.exception.IllegalTransformationException)16 ClawDimension (cx2x.translator.language.common.ClawDimension)6 OverPosition (cx2x.translator.language.common.OverPosition)3 ClawReshapeInfo (cx2x.translator.language.common.ClawReshapeInfo)2 Xnode (cx2x.xcodeml.xnode.Xnode)2 Node (org.w3c.dom.Node)2 NestedDoStatement (cx2x.translator.common.NestedDoStatement)1 ClawConstraint (cx2x.translator.language.common.ClawConstraint)1 ClawMapping (cx2x.translator.language.common.ClawMapping)1 ClawMappingVar (cx2x.translator.language.common.ClawMappingVar)1 PromotionInfo (cx2x.translator.transformation.claw.parallelize.PromotionInfo)1 ClawTransformer (cx2x.translator.transformer.ClawTransformer)1 IllegalDirectiveException (cx2x.xcodeml.exception.IllegalDirectiveException)1 TransformationGroup (cx2x.xcodeml.transformation.TransformationGroup)1 XfunctionDefinition (cx2x.xcodeml.xnode.XfunctionDefinition)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Transformer (javax.xml.transform.Transformer)1 DOMSource (javax.xml.transform.dom.DOMSource)1