|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.claritysys.jvm.builder.CodeBlock
public class CodeBlock
Represents a code block, which defines a scope for local variables.
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.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
CodeBlock(CodeBuilder cb)
Create a new CodeBlock. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int startPC
protected int endPC
protected CodeBuilder codeBuilder
protected ByteArray code
protected LocalVariable headVar
protected Label endLabel
protected CodeBlock surroundingBlock
protected LocalVariable undeclaredLocals
| Constructor Detail |
|---|
public CodeBlock(CodeBuilder cb)
| Method Detail |
|---|
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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||