public class InstructionList extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
static interface |
InstructionList.IFilter
Interface used by code-gen clients that need a chance to adjust the
instruction list after it is generated.
|
Constructor and Description |
---|
InstructionList()
Default constructor.
|
InstructionList(int capacity)
Construct an InstructionList capable of holding a specified number of
instructions.
|
Modifier and Type | Method and Description |
---|---|
void |
addAll(InstructionList src_list)
Add another InstructionList to the sequence.
|
void |
addAllPendingLabels(Collection<Label> prev_pending)
Add pending labels acquired from a component list to this list's
pendingLabels collection.
|
Instruction |
addInstruction(Instruction insn)
Add an instruction to the sequence.
|
Instruction |
addInstruction(int opcode)
Convenience method adds an instruction with no operands.
|
Instruction |
addInstruction(int opcode,
int immed)
Convenience method adds an instruction with an immediate operand.
|
Instruction |
addInstruction(int opcode,
Object operand)
Convenience method adds an instruction with a single operand.
|
Instruction |
addInstruction(int opcode,
Object[] operands)
Convenience method adds an instruction with operands.
|
void |
addLabelAt(Label l,
int pos)
Add a label at an arbitrary position.
|
boolean |
canFallThrough() |
Object |
clone()
Clone this InstructionList; make a shallow copy of the Instructions, deep
copies of the labels.
|
int |
countOccurrences(int opcode)
Count occurrences of an Instruction with a specific opcode.
|
int |
findOccurrences(int opcode,
boolean stop_after_first)
Find occurrences of an Instruction with a specific opcode.
|
Instruction |
firstElement() |
ArrayList<Label> |
getActiveLabels() |
ArrayList<Instruction> |
getInstructions()
Fetch an InstructionList to which instructions can be appended.
|
Label |
getLabel()
Fetch this InstructionList's label.
|
Label |
getLastLabel() |
boolean |
hasPendingLabels() |
boolean |
hasSuchInstruction(int opcode)
Search for an Instruction with a specific opcode.
|
boolean |
isEmpty() |
void |
labelCurrent(Label l)
Label the last executable instruction in this InstructionList.
|
void |
labelFirst(Label l)
Label the first executable instruction in this InstructionList.
|
void |
labelNext(Label l)
Add a Label to this InstructionList's pendingLabels.
|
Instruction |
lastElement() |
void |
pushNumericConstant(long value)
Add an Instruction to this InstructionList to push a numeric constant
onto the value stack.
|
int |
size() |
Collection<Label> |
stripPendingLabels()
This InstructionList is the "body" of a statement that needs to add more
logic.
|
String |
toString()
Format the InstructionList for debugging purposes.
|
public InstructionList()
public InstructionList(int capacity)
capacity
- - the required capacity.public Instruction firstElement()
NoSuchElementException
- if there are no instructions.public Instruction lastElement()
NoSuchElementException
- if there are no instructions.public boolean isEmpty()
public ArrayList<Instruction> getInstructions()
public Label getLabel()
public Instruction addInstruction(Instruction insn)
insn
- the instruction to be added.public Instruction addInstruction(int opcode)
opcode
- - the instruction's opcode.public Instruction addInstruction(int opcode, int immed)
opcode
- - the instruction's opcode.immed
- - the immediate operand.public Instruction addInstruction(int opcode, Object[] operands)
opcode
- - the instruction's opcode.operands
- - the operands.public Instruction addInstruction(int opcode, Object operand)
opcode
- - the instruction's opcode.operand
- - the operand.public void addAll(InstructionList src_list)
src_list
- the InstructionList to be added.public void labelFirst(Label l)
l
- - the Label to be associated with the first executable
instruction in the list.public void labelCurrent(Label l)
l
- - the Label to be associated with the last executable
instruction in the list.public void addLabelAt(Label l, int pos)
l
- - the label.pos
- - the label's position.public ArrayList<Label> getActiveLabels()
public Label getLastLabel()
public void labelNext(Label l)
l
- - the Label to be set pending.public int size()
public boolean hasPendingLabels()
public Collection<Label> stripPendingLabels()
public void addAllPendingLabels(Collection<Label> prev_pending)
prev_pending
- - pending labels returned by a call to
stripPendingLabels().public boolean canFallThrough()
public String toString()
public Object clone()
public boolean hasSuchInstruction(int opcode)
opcode
- - the opcode of interest.public int countOccurrences(int opcode)
opcode
- - the opcode of interest.public int findOccurrences(int opcode, boolean stop_after_first)
opcode
- - the opcode of interest.stop_after_first
- - return a nonzero count after finding at least
one occurence (1-3 occurences in the fixed storage, the first occurence
in variable storage).public void pushNumericConstant(long value)
value
- - the value to push.Copyright © 2016 The Apache Software Foundation. All rights reserved.