public final class DataSection extends Object implements Iterable<DataSection.Data>
Modifier and Type | Class and Description |
---|---|
static class |
DataSection.Data |
static interface |
DataSection.DataBuilder |
Modifier and Type | Field and Description |
---|---|
private ArrayList<DataSection.Data> |
dataItems |
private boolean |
finalLayout |
private int |
sectionAlignment |
private int |
sectionSize |
Constructor and Description |
---|
DataSection() |
Modifier and Type | Method and Description |
---|---|
private static int |
align(int position,
int alignment) |
void |
buildDataSection(ByteBuffer buffer,
Consumer<CompilationResult.DataPatch> patch)
Build the data section.
|
void |
clear() |
boolean |
equals(Object obj) |
void |
finalizeLayout()
Compute the layout of the data section.
|
DataSection.Data |
findData(CompilationResult.DataSectionReference ref) |
int |
getSectionAlignment()
Get the minimum alignment requirement of the data section.
|
int |
getSectionSize()
Get the size of the data section.
|
int |
hashCode() |
CompilationResult.DataSectionReference |
insertData(DataSection.Data data)
Insert a
DataSection.Data item into the data section. |
Iterator<DataSection.Data> |
iterator() |
private static int |
lcm(int x,
int y) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
private final ArrayList<DataSection.Data> dataItems
private boolean finalLayout
private int sectionAlignment
private int sectionSize
public DataSection()
public CompilationResult.DataSectionReference insertData(DataSection.Data data)
DataSection.Data
item into the data section. If the item is already in the data section,
the same CompilationResult.DataSectionReference
is returned.data
- the DataSection.Data
item to be insertedCompilationResult.DataSectionReference
identifying the DataSection.Data
itempublic void finalizeLayout()
public int getSectionSize()
finalizeLayout()
.public int getSectionAlignment()
finalizeLayout()
.public void buildDataSection(ByteBuffer buffer, Consumer<CompilationResult.DataPatch> patch)
finalizeLayout()
.buffer
- The ByteBuffer
where the data section should be built. The buffer must
hold at least getSectionSize()
bytes.patch
- A Consumer
to receive data patches
for relocations in
the data section.public DataSection.Data findData(CompilationResult.DataSectionReference ref)
public Iterator<DataSection.Data> iterator()
iterator
in interface Iterable<DataSection.Data>
private static int lcm(int x, int y)
private static int align(int position, int alignment)
public void clear()