public abstract static class SwitchStrategy.BaseSwitchClosure extends Object implements SwitchStrategy.SwitchClosure
conditionalJump(int, Condition, Label)
method.Modifier and Type | Field and Description |
---|---|
private CompilationResultBuilder |
crb |
private LabelRef |
defaultTarget |
private LabelRef[] |
keyTargets |
private Assembler |
masm |
Constructor and Description |
---|
BaseSwitchClosure(CompilationResultBuilder crb,
Assembler masm,
LabelRef[] keyTargets,
LabelRef defaultTarget) |
Modifier and Type | Method and Description |
---|---|
void |
bind(Label label)
Binds a label returned by
SwitchStrategy.SwitchClosure.conditionalJump(int, Condition) . |
Label |
conditionalJump(int index,
Condition condition)
Create a new label and generate a conditional jump to it.
|
void |
conditionalJump(int index,
Condition condition,
boolean targetDefault)
Generates a conditional or unconditional jump.
|
protected abstract void |
conditionalJump(int index,
Condition condition,
Label target)
This method generates code for a comparison between the actual value and the constant at
the given index and a condition jump to target.
|
void |
conditionalJumpOrDefault(int index,
Condition condition,
boolean canFallThrough)
Generates a conditional jump to the target with the specified index.
|
boolean |
isSameTarget(int index1,
int index2)
Return true iff the target of both indexes is the same.
|
private final CompilationResultBuilder crb
private final LabelRef[] keyTargets
private final LabelRef defaultTarget
public BaseSwitchClosure(CompilationResultBuilder crb, Assembler masm, LabelRef[] keyTargets, LabelRef defaultTarget)
protected abstract void conditionalJump(int index, Condition condition, Label target)
public void conditionalJump(int index, Condition condition, boolean targetDefault)
SwitchStrategy.SwitchClosure
conditionalJump
in interface SwitchStrategy.SwitchClosure
index
- Index of the value and the jump target (only used if defaultTarget == false)condition
- The condition on which to jump (can be null)targetDefault
- true if the jump should go to the default target, false if index
should be used.public void conditionalJumpOrDefault(int index, Condition condition, boolean canFallThrough)
SwitchStrategy.SwitchClosure
conditionalJumpOrDefault
in interface SwitchStrategy.SwitchClosure
index
- Index of the value and the jump targetcondition
- The condition on which to jumpcanFallThrough
- true if this is the last instruction in the switch statement, to
allow for fall-through optimizations.public Label conditionalJump(int index, Condition condition)
SwitchStrategy.SwitchClosure
conditionalJump
in interface SwitchStrategy.SwitchClosure
index
- Index of the value and the jump targetcondition
- The condition on which to jumppublic void bind(Label label)
SwitchStrategy.SwitchClosure
SwitchStrategy.SwitchClosure.conditionalJump(int, Condition)
.bind
in interface SwitchStrategy.SwitchClosure
public boolean isSameTarget(int index1, int index2)
SwitchStrategy.SwitchClosure
isSameTarget
in interface SwitchStrategy.SwitchClosure