TapList

public final class TapList<T> implements Iterable<T>

List of Objects, simply chained forward.

Fields

tail

public TapList<T> tail

The tail of this list.

Constructors

TapList

public TapList()

Creates a new list cell and initializes it to null.

TapList

public TapList(T head, TapList<T> tail)

Creates a new list cell with given “head” and “tail”.

Methods

addAll

public static <T> TapList<T> addAll(TapList<T> list1, TapList<T> list2)
Returns

a new TapList containing all elements of “list1” or “list2”.

addIntoLeaves

public static void addIntoLeaves(TapList zonesTree, TapIntList newInts)

Adds all integers in TapIntList “newInts” into each TapIntList leaf of the TapList tree “zonesTree”.

addLast

public static <T> TapList<T> addLast(TapList<T> list, T object)
Returns

the list made of the given “list” plus the “object” at the end. Modifies the original “list” when non-null.

addUnlessPresent

public static <T> TapList<T> addUnlessPresent(TapList<T> list, T obj)

addUnlessPresentEquals

protected static <T> TapList<T> addUnlessPresentEquals(TapList<T> list, T obj)

allSingletonLeaves

public static boolean allSingletonLeaves(TapList<?> tree)
Returns

true when all the (TapIntList) leaves are singletons. Takes care of infinite cycles in the tree.

append

public static <T> TapList<T> append(TapList<T> list1, TapList<T> list2)
Returns

a new TapList, concatenation of “list1” followed by “list2”. Caution: the result shares structure with “list2”.

assq

public static <KEYTYPE, VALUETYPE> TapPair<KEYTYPE, VALUETYPE> assq(KEYTYPE key, TapList<TapPair<KEYTYPE, VALUETYPE>> list)

Return the element matching “key” in the association list “list”. Comparison is done with == .

Parameters
  • list – The association list, assumed to be a list of TapPair.

Returns

null if no matching association is found.

assq

public static Int2ZoneInfo assq(int key, TapList<Int2ZoneInfo> list)
Parameters
  • list – The association list, assumed to be a list of Int2ZoneInfo.

Returns

null if no matching association is found. Comparison is done with == .

assqOne

public static <T> TapPair<TapIntList, T> assqOne(int key, TapList<TapPair<TapIntList, T>> list)
Parameters
  • list – The association list, assumed to be a list of TapPair, with first elements being TapIntList

Returns

null if no matching association is found. Comparison is done with == .

assqString

public static <T> TapPair<String, T> assqString(String string, TapList<TapPair<String, T>> list)

Same as assq, but looks for “string” with String.equals().

assqStringInTriplet

public static <T, U> TapTriplet<String, T, U> assqStringInTriplet(String string, TapList<TapTriplet<String, T, U>> list)

Same as assqString, but the association list is made of TapTriplet.

assqTree

public static TapPair<Tree, Tree> assqTree(Tree tree, TapList<TapPair<Tree, Tree>> list)

cassq

public static <KEYTYPE, VALUETYPE> VALUETYPE cassq(KEYTYPE key, TapList<TapPair<KEYTYPE, VALUETYPE>> list)

Return the value in the element matching “key” in the association list “list”. Comparison is done with == .

Parameters
  • list – The association list, assumed to be a list of TapPair

Returns

null if no matching association is found.

cassq

public static ZoneInfo cassq(int key, TapList<Int2ZoneInfo> list)
Parameters
  • list – The association list, assumed to be a list of Int2ZoneInfo.

Returns

null if no matching association is found. Comparison is done with == .

cassqString

public static <T> T cassqString(String string, TapList<TapPair<String, T>> list)

Same as cassq, but looks for “string” with String.equals().

cleanExtraInfoValue

public static TapList<String> cleanExtraInfoValue(TapList<String> extraInfo, String lcValue)

Removes the given “lcValue” from the given list of “extraInfo”. To be made cleaner and less specific.

contains

public static <T> boolean contains(TapList<T> list, T obj)
Returns

true if “obj” is found in the given list Comparison is done with ==.

containsEquals

public static <T> boolean containsEquals(TapList<T> list, T obj)
Returns

true if “obj” is found in the given list Comparison is done with equals().

containsEqualsObjectPair

public static boolean containsEqualsObjectPair(TapList<TapPair<Unit, String>> list, Unit first, String second)

containsObjectPair

protected static <T, U> boolean containsObjectPair(TapList<TapPair<T, U>> list, T first, U second)
Returns

true if an TapPair containing the given first and second is found in the given list.

containsOneOfStrings

public static boolean containsOneOfStrings(TapList<String> list, String[] searched, boolean caseSensitive)
Parameters
  • caseSensitive – when true, the string equality is case sensitive.

Returns

true if “list” contains one String that is in “searched”.

containsSameNameSymbolDecl

public static boolean containsSameNameSymbolDecl(TapList<SymbolDecl> list, SymbolDecl symbolDecl)
Returns

true if the given list contains a SymbolDecl with the same name as for the given “symbolDecl”.

containsString

public static boolean containsString(TapList<String> list, String str, boolean caseSensitive)
Parameters
  • caseSensitive – when true, the string equality is case sensitive.

Returns

true if the string “str” is found in “list”.

containsTree

public static boolean containsTree(TapList<Tree> list, Tree tree)
Returns

true if the given list contains the given “tree”. Comparison is done with ILUtils.eqOrDisjointRef and not Tree.equals(). TODO: does not work well with pointers !

containsTreeEquals

public static boolean containsTreeEquals(TapList<Tree> list, Tree tree)
Returns

true if the given “tree” is found in the given list. Comparison is done with t1.equalsTree(t2).

containsVariableDecl

public static boolean containsVariableDecl(TapList<SymbolDecl> list, VariableDecl varDecl)
Returns

true if the given “varDecl” is found in the given list. Comparison is done with VariableDecl.equalsOther().

copy

public static <T> TapList<T> copy(TapList<T> list)
Returns

a copy of the given list.

copyTree

public static TapList<?> copyTree(TapList<?> model)
Returns

a deep copy of this TapList, which must be a tree of TapIntList’s, Boolean’s, or ToBool’s . Takes care of infinite trees that come from variables of recursive type.

copyTreeNoPointed

public static TapList<?> copyTreeNoPointed(TapList<?> model)
Returns

a deep copy of this TapList, which must be a tree of TapIntList’s, Boolean’s, or ToBool’s . Shares (i.e. does not copy) the leaves of the tree. Does not copy pointer destination part. Therefore there is no risk of infinite looping.

cumulOr

public static BoolVector cumulOr(TapList<?> tree)

OR-accumulates all leaves of tree, which are BoolVector’s, into a single BoolVector and returns it. Does not go inside pointers, therefore there is no risk of infinite looping.

cumulWithOper

public static TapList<?> cumulWithOper(TapList<?> target, Object added, int oper)

Recursively accumulates tree “added” into tree “target”, using operation “oper”.

Returns

the resulting tree, which in general is the new contents of “target”. Takes care of cycles in the trees. The leaves of the tree may be all Boolean’s or all BoolVector’s or all TapIntList’s. The result will maybe share structure with the original “target”, but will never share structure with “added”. In other words, the parts of “added” which appear in the result will be deep copies.

dagSize

public int dagSize(TapList<TapList> dejaVu)

delete

public static <T> TapList<T> delete(T delElem, TapList<T> list)
Returns

a TapList containing all elements of “list” that are not == to “delElem”. Caution: the result shares structure with “list”.

deleteAll

public static <T> TapList<T> deleteAll(TapList<T> delList, TapList<T> list)
Returns

a TapList containing all elements of “list” that are not in “delList”. Caution: the result shares structure with “list”.

deleteContainsString

public static TapList<String> deleteContainsString(String delElem, TapList<String> list)
Returns

a TapList containing all elements of “list” that are a String containing “delElem”. Caution: the result shares structure with “list”.

deleteNth

public static <T> TapList<T> deleteNth(TapList<T> list, int n)
Returns

a copy of “list” with the n-th element deleted Elements are counted from 0 up. Caution: the result shares structure with “list”.

deleteString

public static TapList<String> deleteString(String delElem, TapList<String> list)
Returns

a TapList containing all elements of “list” that are not String.equals() to “delElem”. Caution: the result shares structure with “list”.

dump

public void dump()

Prints the contents of this TapList onto TapEnv.curOutputStream().

equalsImportedModules

protected static boolean equalsImportedModules(TapList<Instruction> l1, TapList<Instruction> l2)

findExtraInfos

public TapList<TapPair<Unit, Tree>> findExtraInfos(Unit unit)

findNamedSymbolDecl

public static SymbolDecl findNamedSymbolDecl(TapList<SymbolDecl> list, String name)
Returns

null if no element is found. Comparison is done with String.equals().

findTypeSpec

public static WrapperTypeSpec findTypeSpec(TapList<TypeSpec> list, WrapperTypeSpec typeSpec)
Returns

null if no element is found. Comparison is done with WrapperTypeSpec.equalLiterally.

fromObjectArray

public static <T> TapList<T> fromObjectArray(T[] array)

Convert an array of Object to a TapList.

getSetFieldLocation

public static TapList<?> getSetFieldLocation(TapList infoTree, Tree accessTree, boolean createIfAbsent)
Returns

(or creates and returns) the sub-tree of the given tree “infoTree” which is accessed through the given “accessTree” (e.g. %x[3]%toto). When “createIfAbsent” is true, this function never returns null ! When “createIfAbsent” is false, doesn’t modify “infoTree” and may return null if nothing found. This function assumes that it is given a non-null “infoTree” ! CONVENTION [Jan 2008] on the placement of pointer destination info: REMAIN IN SYNC with CONVENTION in DataFlowAnalyzer.includePointedElementsInTreeRec().

intersectTreeEquals

public static boolean intersectTreeEquals(TapList<Tree> list1, TapList<Tree> list2)

iterator

public java.util.Iterator<T> iterator()

TapList implements Iterable.

last

public static <T> T last(TapList<T> list)
Returns

the last element of the given list.

length

public static <T> int length(TapList<T> list)
Returns

the length of given list. Returns 0 if list is null.

lengthWithCycle

public static <T> int lengthWithCycle(TapList<T> list)

Same as length, but stops on a cycle.

Returns

the length of given list.

negateBooleans

public static void negateBooleans(TapList tree)

Modifies inside the given tree, which is a TapList tree of Booleans, replacing all Boolean leaves with their negation.

newR

public void newR(T object)

Adds element “object” at the end of this list.

nreverse

public static <T> TapList<T> nreverse(TapList<T> list)

Physically reverses the given “list” and returns it.

nth

public static Object nth(TapList<?> list, int rank)
Returns

the rank’th element in “list”. When rank=0, this returns the first element.

oneFalse

public static boolean oneFalse(TapList<?> boolsTree)

oneNonSingleton

public static boolean oneNonSingleton(TapList<?> boolsTree)
Returns

true if at least one leaf of the given “boolsTree” is a TapIntList with more than one element. Takes care of infinite cycles in the tree. boolsTree must be a TapList tree of TapIntList’s.

oneTrue

public static boolean oneTrue(TapList<?> boolsTree)
Returns

true if at least one leaf of the given “boolsTree” is true. Takes care of infinite cycles in the tree. boolsTree must be a TapList tree of Boolean’s.

oneTrueInHead

public static boolean oneTrueInHead(TapList<?> boolsTree)
Returns

true if at least one leaf in the HEAD of the given TapList of Boolean’s “boolsTree” is true.

parseIdentifier

public static TapList<String> parseIdentifier(String ident)

Parses an identifier String of the form toto.x.z or toto%x%z into a list of Strings ("toto" "x" "y"). To handle pointers, parsing of toto**.y returns ("toto" "*" "*" "y"), representing (C-style) (*toto)->y.

placdl

public TapList<T> placdl(T obj)

Replaces the tail of this list by a new list cell, whose head is “obj”, and whose tail is the previous tail of this list.

Returns

this new list cell.

prependNoDups

public static <T> TapList<T> prependNoDups(TapList<T> newElems, TapList<T> oldList)

Prepends the elements of “newElems” in front of “oldList”, discarding duplicates. @return the resulting list. So far, we don’t try to preserve the order of newElems.

rank

public int rank(Object obj)
Returns

the rank of the Object “obj” in the current list. Comparison is done with == . First is 0, and “not found” is -1.

rankString

public int rankString(String str)
Returns

the rank of the string “str” in the current list. Comparison is done with String.equals(). First is 0, and “not found” is -1.

rassq

public static <KEYTYPE, VALUETYPE> TapPair<KEYTYPE, VALUETYPE> rassq(VALUETYPE value, TapList<TapPair<KEYTYPE, VALUETYPE>> list)

Return the first element containing “value” in the association list “list”. Comparison is done with == .

Parameters
  • list – The association list, assumed to be a list of TapPair

Returns

null if no matching association is found.

rassqString

public static TapPair<String, String> rassqString(String string, TapList<TapPair<String, String>> list)

Same as rassq, but looks for “string” with String.equals().

removeLast

public static <T> TapList<T> removeLast(TapList<T> list)

Removes the last element of the given “list”.

removeNonWritableZones

public static void removeNonWritableZones(TapList tree)

Remove zones Null, UnknownDests and IO (generally 0, 1, and 2) in all TapIntLists in tree

replace

public static <T> void replace(TapList<T> list, T from, T to)

Replaces all occurences of “from” into “to” in “list”.

replaceExtraInfoValue

public static void replaceExtraInfoValue(TapList<String> extraInfo, String lcValue, String lcValue2)

replaceIntsWithValueInts

public static void replaceIntsWithValueInts(TapList zonesTree, int[] values, int offset)

Sweeps through the given (TapList tree of TapIntList) “zonesTree”, replacing each integer by the value at this rank (plus offset) in the given array “values”.

reverse

public static <T> TapList<T> reverse(TapList<T> list)
Returns

a reversed copy of the given “list”.

safeDelete

public static <T> TapList<T> safeDelete(T delElem, TapList<T> list)

Variant of delete() that does not modify the given list. Still, the resulting list shares a part with “list”.

sameTree

public static boolean sameTree(TapList<?> tree1, TapList<?> tree2)
Returns

true if the two TapList-trees are the same, even if not ==.

setAll

public void setAll(boolean value)

Sets all Boolean leaves to the given value. Assumes this is a TapList tree of Boolean Skips pointer derefs.

split

public static TapList<Instruction>[] split(TapList<Instruction> list, TapIntList listRank)

coupe la liste en 2n+1 sous-listes n longueur de la liste des positions de coupure suppose que listRank est une liste ordonnee croissante des positions retourne un tableau de 2n+1 Object les indices impairs du tableau correspondent aux contenus reperes par listRank.

toLast

public static <T> TapList<T> toLast(TapList<T> list)
Returns

the last cell of the given list, i.e. the one that contains its last element.

toString

public String toString()

toString

public String toString(Object info)

trueForAll

public static boolean trueForAll(TapList<?> boolsTree)

Utility for RefDescriptor ignoreXXX mechanism. Not very general yet.

union

public static <T> TapList<T> union(TapList<T> list1, TapList<T> list2)
Returns

the set union of “list1” and “list2”. “list1” is assumed to be already a set (no duplicates). Apart for removed duplicate elements, the result preserves the order of “list1” followed by “list2”.

unionString

public static TapList<String> unionString(TapList<String> list1, TapList<String> list2)

Same as “union()”, but equality test is on Strings.

unique

public static <T> TapList<T> unique(TapList<T> list)
Returns

a copy of “list” with duplicated elements removed.