protected ElementList createElementList() { return new ElementList(); }
@Override public boolean addAll(Collection<? extends Element> arg) { boolean changed = false; for (Element e : arg) { changed |= this.add(e); } return changed; }
public int getIndexForSection(PECoffSection s) { return elements.elementIndexToSectionIndex(elements.indexOf(s)) + 1; }
Section getSection(int sectionIndex) { int elementIndex = sectionIndexToElementIndex(sectionIndex); if (elementIndex == -1) { return null; } Element found = get(elementIndex); assert found instanceof Section; return (Section) found; }
Iterator<Section> iter = sectionsIterator(); while (iter.hasNext()) { assert i == sectionsCount(); return size(); while (get(ei) != s) { ++ei;
private Element(String name, int alignment, int elementIndex) { /* Null is not allowed as an Element name. */ assert name != null : "Null not allowed as Element name."; /* The empty string is not allowed as a name. */ assert !name.equals("") : "The empty string is not allowed as an Element name."; this.name = name; if (elementIndex == -1) { ObjectFile.this.elements.add(this); } else { ObjectFile.this.elements.add(elementIndex, this); } /* check our name mapping was created. */ assert ObjectFile.this.elements.forName(getName()) == this; this.alignment = alignment; }
@Override public boolean add(Element arg) { elementForName.put(arg.getName(), arg); boolean changed = entries.add(arg); if (changed) { int pos = size() - 1; incrementSectionCounters(arg, pos); } return changed; }
@Override public boolean remove(Object arg) { boolean ret = entries.remove(arg); int pos = entries.indexOf(arg); if (ret) { // remove its index from the appropriate set decrementSectionCounters((Element) arg, pos); // adjust other indices adjustAllGE(nonSectionElementIndices, pos, -1); adjustAllGE(sectionElementIndices, pos, -1); // now we can remove it elementForName.remove(((Element) arg).getName()); } return ret; }
@Override public Element remove(int arg0) { adjustAllGE(sectionElementIndices, arg0, -1); adjustAllGE(nonSectionElementIndices, arg0, -1); Element e = entries.remove(arg0); elementForName.remove(e.getName()); return e; }
@Override public boolean removeAll(Collection<?> arg0) { boolean removed = false; for (Object o : arg0) { removed |= this.remove(o); } return removed; }
public Element elementForName(String s) { return elements.forName(s); }
@Override public int sectionIndexToElementIndex(int sectionIndex) { /* naive for now */ int i = 0; Iterator<Section> it = sectionsIterator(); while (it.hasNext()) { Section s = it.next(); if (sectionIndex == i) { return elements.indexOf(s); } ++i; } return -1; }
public PECoffSection getSectionByIndex(int i) { // if this cast fails, our sectionIndexToElementIndex logic is wrong return (PECoffSection) elements.get(elements.sectionIndexToElementIndex(i - 1)); // NOTE: two levels of translation here: PECoff (1-based) shndx to section index (0-based) // to // element index }
@Override public void add(int pos, Element arg1) { // all numbers >= pos in the two sets must be incremented by one adjustAllGE(sectionElementIndices, pos, 1); adjustAllGE(nonSectionElementIndices, pos, 1); // now we can do the addition entries.add(pos, arg1); ((arg1 instanceof Section) ? sectionElementIndices : nonSectionElementIndices).add(pos); elementForName.put(arg1.getName(), arg1); }
@Override public boolean retainAll(Collection<?> arg0) { boolean changed = false; for (Element e : this) { if (!arg0.contains(e)) { changed |= this.remove(e); } } return changed; }
public ELFSection getSectionByIndex(int i) { // if this cast fails, our sectionIndexToElementIndex logic is wrong return (ELFSection) elements.get(elements.sectionIndexToElementIndex(i - 1)); // NOTE: two levels of translation here: ELF (1-based) shndx to section index (0-based) to // element index }
public int getIndexForSection(ELFSection s) { return elements.elementIndexToSectionIndex(elements.indexOf(s)) + 1; }
@Override public boolean addAll(int arg0, Collection<? extends Element> arg1) { int pos = arg0; boolean changed = false; for (Element e : arg1) { this.add(pos++, e); changed = true; } return changed; }