edu.wisc.cs.java
Class Branch
java.lang.Object
|
+--edu.wisc.cs.java.Bytecode
|
+--edu.wisc.cs.java.Branch
- public class Branch
- extends Bytecode
Represents a conditional or unconditional branch instruction.
Field Summary |
protected CodeLabel |
target
The symbolic label corresponding to the target of this branch. |
Constructor Summary |
Branch(int opcode,
CodeLabel lbl)
Creates a new branch instruction with the specified label as the target. |
Branch(int op,
java.io.DataInputStream in,
int pc)
Constructs a new Branch object from information presumably read from a
class file. |
Method Summary |
int |
getParamBytes()
Returns the number of bytes this instruction uses for parameters. |
CodeLabel |
getTarget()
Returns the symbolic label corresponding to the target of this branch. |
java.lang.String |
toString()
Returns a string representation of this branch instruction. |
void |
writeTo(java.io.DataOutputStream out,
java.util.HashMap labels,
int pc)
Writes a branch instruction to a stream in the
specified format. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
target
protected CodeLabel target
- The symbolic label corresponding to the target of this branch.
Branch
public Branch(int op,
java.io.DataInputStream in,
int pc)
throws java.io.IOException
- Constructs a new Branch object from information presumably read from a
class file.
- Parameters:
w
- true if this is to be a wide instruction, false otherwise.op
- the opcode for the new instruction.p
- an array of parameter bytes.
Branch
public Branch(int opcode,
CodeLabel lbl)
- Creates a new branch instruction with the specified label as the target.
- Parameters:
opcode
- the opcode for this instruction.lbl
- the target label.
writeTo
public void writeTo(java.io.DataOutputStream out,
java.util.HashMap labels,
int pc)
throws java.io.IOException
- Writes a branch instruction to a stream in the
specified format. The pad is already expected to have been adjusted to the
proper value given the pc.
- Parameters:
out
- a stream to which to write the data for this instruction.labels
- a map comtaining the labels in the method and their pc's.pc
- the program counter for this instruction.- Throws:
- java.io.IOException - if there is a problem writing to the stream.
toString
public java.lang.String toString()
- Returns a string representation of this branch instruction.
- Overrides:
- toString in class Bytecode
- Returns:
- a string representation of this branch instruction.
getTarget
public CodeLabel getTarget()
- Returns the symbolic label corresponding to the target of this branch.
- Returns:
- the symbolic label corresponding to the target of this branch.
getParamBytes
public int getParamBytes()
- Returns the number of bytes this instruction uses for parameters.
- Overrides:
- getParamBytes in class Bytecode
- Returns:
- the number of bytes this instruction uses for parameters.