public class XnodeUtil
extends java.lang.Object
Constructor and Description |
---|
XnodeUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
deleteBetween(Xnode start,
Xnode end)
Delete all the elements between the two given elements.
|
static java.util.List<Xnode> |
findAllReferences(Xnode parent)
Find all the var elements that are real references to a variable.
|
static java.util.List<Xnode> |
findAllReferences(Xnode parent,
java.lang.String id)
Find all the var elements that are real references to a variable.
|
static java.util.List<HoistedNestedDoStatement> |
findDoStatementForHoisting(Xnode from,
Xnode endPragma,
java.util.List<java.lang.String> inductionVars)
Find all the nested do statement groups following the inductions iterations
define in inductionVars and being located between the "from" element and
the end pragma.
|
static java.util.List<Xnode> |
findIndexes(Xnode parent)
Find all the index elements (arrayIndex and indexRange) in an element.
|
static java.util.List<java.lang.String> |
gatherArguments(XcodeProgram xcodeml,
Xnode fctCall,
Intent intent,
boolean arrayOnly)
Gather arguments of a function call.
|
static java.util.List<Xnode> |
getAllArrayReferences(Xnode parent,
java.lang.String arrayName)
Find all array references elements in a given body and give var name.
|
static java.util.List<Xnode> |
getAllArrayReferencesByOffsets(Xnode from,
java.lang.String identifier,
java.util.List<java.lang.Integer> offsets)
Find all array references in the next children that match the given
criteria.
|
static java.util.List<Xnode> |
getAllArrayReferencesInSiblings(Xnode from,
java.lang.String identifier)
Get all array references in the siblings of the given element.
|
static java.util.List<Xnode> |
getAllVarReferences(Xnode parent,
java.lang.String varName)
Find all var references elements in a given body and give var name.
|
static java.util.List<Xnode> |
getArrayAssignInBlock(Xnode from,
java.lang.String endPragma)
Find all assignment statement from a node until the end pragma.
|
static Xnode |
getFirstArrayAssign(Xnode from,
java.lang.String arrayName)
Get the first assignment statement for an array reference.
|
static java.util.List<Xnode> |
getIdxRangesFromArrayRef(Xnode arrayRef)
Retrieve the index ranges of an array notation.
|
static java.util.Set<java.lang.String> |
getNamesFromReferences(java.util.List<Xnode> nodes)
Get all the variables names from a list of var elements.
|
static java.util.List<Xnode> |
getNodes(Xnode root,
java.util.List<Xcode> nodeOpcodes)
Get given statements in the subtree.
|
static java.util.List<Xnode> |
getNodes(Xnode from,
Xnode to,
java.util.List<Xcode> nodeOpcodes)
Get given statements in between from and to included.
|
static boolean |
isInductionIndex(Xnode arrayIndex,
java.util.List<java.lang.String> inductionVariables)
Check whether the index of an arrayIndex element is an induction variable
given in the list.
|
static org.w3c.dom.Document |
readXmlFile(java.lang.String input)
Read XML file.
|
static void |
safeDelete(Xnode node)
Delete a node in the ast.
|
public static java.util.List<Xnode> getAllArrayReferences(Xnode parent, java.lang.String arrayName)
parent
- The body element to search for the array references.arrayName
- Name of the array for the array reference to be found.public static java.util.List<Xnode> getAllVarReferences(Xnode parent, java.lang.String varName)
parent
- The body element to search for the array references.varName
- Name of the var for the reference to be found.public static java.util.List<Xnode> getIdxRangesFromArrayRef(Xnode arrayRef)
arrayRef
- The array reference statements to extract the ranges from.public static java.util.List<Xnode> getArrayAssignInBlock(Xnode from, java.lang.String endPragma)
Find all assignment statement from a node until the end pragma. We intersect all assign statements which are next siblings of the "from" element with all the assign statements which are previous siblings of the ending pragma.
from
- The element from which the search is initiated.endPragma
- Value of the end pragma. Search will be performed until
there.public static java.util.List<Xnode> getAllArrayReferencesInSiblings(Xnode from, java.lang.String identifier)
from
- Element to start from.identifier
- Array name value.public static Xnode getFirstArrayAssign(Xnode from, java.lang.String arrayName)
from
- Statement to look from.arrayName
- Identifier of the array.public static java.util.List<HoistedNestedDoStatement> findDoStatementForHoisting(Xnode from, Xnode endPragma, java.util.List<java.lang.String> inductionVars)
from
- Element from which the search is started.endPragma
- End pragma that terminates the search block.inductionVars
- Induction variables that define the nested group to
locates.public static java.util.List<Xnode> getAllArrayReferencesByOffsets(Xnode from, java.lang.String identifier, java.util.List<java.lang.Integer> offsets)
from
- The element from which the search is initiated.identifier
- Identifier of the array.offsets
- List of offsets to be search for.public static java.util.List<Xnode> findIndexes(Xnode parent)
parent
- Root element to search from.public static java.util.List<Xnode> findAllReferences(Xnode parent)
parent
- Root element to search from.public static java.util.Set<java.lang.String> getNamesFromReferences(java.util.List<Xnode> nodes)
nodes
- List containing var element.public static java.util.List<Xnode> findAllReferences(Xnode parent, java.lang.String id)
parent
- Root element to search from.id
- Identifier of the var to be found.public static boolean isInductionIndex(Xnode arrayIndex, java.util.List<java.lang.String> inductionVariables)
arrayIndex
- arrayIndex to be checked.inductionVariables
- List of potential induction variables.public static java.util.List<Xnode> getNodes(Xnode root, java.util.List<Xcode> nodeOpcodes)
root
- Root of the subtree.nodeOpcodes
- List of statements to look for.public static java.util.List<Xnode> getNodes(Xnode from, Xnode to, java.util.List<Xcode> nodeOpcodes)
from
- Node from.to
- Node to.nodeOpcodes
- List of statements to look for.public static void deleteBetween(Xnode start, Xnode end)
start
- The start element. Deletion start from next element.end
- The end element. Deletion end just before this element.public static org.w3c.dom.Document readXmlFile(java.lang.String input)
input
- Xml file path.public static void safeDelete(Xnode node)
node
- Node to be deleted.public static java.util.List<java.lang.String> gatherArguments(XcodeProgram xcodeml, Xnode fctCall, Intent intent, boolean arrayOnly)
xcodeml
- Current XcodeML translation unit.fctCall
- functionCall node in which the arguments are retrieved.intent
- Intent to use for gathering.arrayOnly
- If true, gather only arrays arguments.