public class CodeBlock
extends java.lang.Object
A block can be a a scope block, an If/Else block, or a Try/Catch/Finally block.
Variables allocated within a block go out of scope when the block ends and can have their indexes reused.
Modifier and Type | Field and Description |
---|---|
protected ByteArray |
code
The byte[] being written to.
|
protected CodeBuilder |
codeBuilder
The code builder.
|
protected Label |
endLabel
Linked list of labels to be defined at blockEnd().
|
protected int |
endPC
The PC where the block was ended.
|
protected LocalVariable |
headVar
Linked list of scoped variables.
|
protected int |
startPC
The PC where the block was started.
|
protected CodeBlock |
surroundingBlock
Link to surrounding block.
|
protected LocalVariable |
undeclaredLocals
List of undeclared LocalVariable.
|
Constructor and Description |
---|
CodeBlock(CodeBuilder cb)
Create a new CodeBlock.
|
Modifier and Type | Method and Description |
---|---|
void |
addLocal(LocalVariable local)
Add a local variable to this block's scope, to be declared in the
containing CfMethod once the block is ended.
|
void |
clearEndLabel()
Clear the end label (set it to null).
|
void |
end()
End the block, noting the endPC and defining any labels specified
to be defined at block end.
|
Label |
getEndLabel()
Return a label that will be defined when the block ends.
|
int |
getEndPC() |
CfMethod |
getMethod()
Get the method builder.
|
int |
getStartPC() |
CodeBlock |
getSurroundingBlock()
Return the surrounding block.
|
void |
setCodeBuilder(CodeBuilder cb)
Set the CodeBuilder, in case this block was pooled.
|
void |
setEndLabel(Label end)
Set the end label.
|
void |
setSurroundingBlock(CodeBlock sb)
Make the given block the surrounding block.
|
void |
start()
Formally start the block, noting the startPC.
|
protected int startPC
protected int endPC
protected CodeBuilder codeBuilder
protected ByteArray code
protected LocalVariable headVar
protected Label endLabel
protected CodeBlock surroundingBlock
protected LocalVariable undeclaredLocals
public CodeBlock(CodeBuilder cb)
public void setCodeBuilder(CodeBuilder cb)
public CfMethod getMethod()
public CodeBlock getSurroundingBlock()
public void setSurroundingBlock(CodeBlock sb)
public Label getEndLabel()
Note that the block may not have begun yet.
public void setEndLabel(Label end)
public void clearEndLabel()
public void start()
public void end()
public int getStartPC()
public int getEndPC()
public void addLocal(LocalVariable local)
Copyright ? 2000-2003 Clarity Systems Group, LLC. All Rights Reserved.