public final class Label
extends java.lang.Object
Constructor and Description |
---|
Label(ByteArray code)
Create a new label over the given byte array, but do not
define it yet.
|
Modifier and Type | Method and Description |
---|---|
void |
define()
Define the label to be equal to the current PC.
|
int |
getOffset(boolean isWide)
Return the offset to write to the byte[] from the given offset,
depending on whether a short or int offset is needed, in order to
branch to this label from the current PC location.
|
boolean |
hasFixups()
Returns true if there are unresolved references to this label.
|
boolean |
isDefined()
Return true if the label has already been defined.
|
Label |
next()
Get the next label in the chain.
|
void |
setPC(int pc)
Set the PC of the label.
|
public Label(ByteArray code)
public int getOffset(boolean isWide)
If the label is defined, it returns the offset from the current PC (of course).
If NOT defined, it returns a backpatch address, which will be fixed when the label is defined.
When generating branch instructions, be sure to call this BEFORE adding the branch opcode, which will change the PC and cause this to return an incorrect offset.
public boolean hasFixups()
public Label next()
public boolean isDefined()
public void define()
public void setPC(int pc)
Copyright ? 2000-2003 Clarity Systems Group, LLC. All Rights Reserved.