|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectorg.oklab.compiler.nametable.CodeBufferManager
public class CodeBufferManager
コードを保持するクラス. コードとは、メソッド内に書かれた文(Statement)や式の事.変数や関数などはその文字列を コンテントプールに保持して、保持する場所のindex情報をFieldManagerやMethodManagerが管理する. 実際の実行されるコード部分である{}内の情報はこのクラスが管理する.またバイトコードを そのたびに出力するのではなく、このクラスのバッファで保持して、最後に一気にファイル出力をする.
| フィールドの概要 | |
|---|---|
private int |
attributeNameIndex
クラスファイル内のCodeと示された文字列が実際の実行コードのindexとなる. |
private static int |
BYTECODE_BUFFER_SIZE
|
private int |
bytecodeByteSize
バイトコードのバイト数. |
private byte[] |
bytecodes
実際のバイトコードを保持する. |
private static CodeBufferManager |
instance
|
private int |
maxLocalVariable
ローカル変数の最大数. |
private int |
maxOperandStack
オペランドスタックの最大数. |
| コンストラクタの概要 | |
|---|---|
private |
CodeBufferManager()
バイトコードを保持するために初期化. |
| メソッドの概要 | |
|---|---|
int |
appendEmpty(int size)
空領域を確保して、確保する前のバイトコードのバイト数を返す.このコードバッファマネージャ のバイトコード数は引数の数値分増加する. |
void |
emitCode(java.io.DataOutputStream classfile)
クラスファイルに書き出し. |
int |
getBytecodeByteSize()
バッファに書き込まれたバイトコードのバイト数.保存される領域の最大値ではない. |
static CodeBufferManager |
getInstance()
|
void |
init()
|
void |
insertEmpty(int offset,
int size)
空領域を途中に挿入する. |
void |
patchByte(int bytecodeByteSize,
int code)
|
void |
patchInt(int bytecodeByteSize,
int code)
|
void |
patchShort(int bytecodeByteSize,
int code)
|
void |
patchUnsignedByte(int bytecodeByteSize,
int code)
|
void |
patchUnsignedShort(int bytecodeByteSize,
int code)
|
private void |
requireToExtendCode(int currentBytecodeSize)
もしコード領域が足りない場合は、確認して拡張する. |
void |
setMaxLocalVariable(int localVariable)
|
void |
setMaxOperandStack(int stackPointer)
|
void |
writeByte(int code)
|
void |
writeInt(int code)
|
(package private) void |
writeReturnBytecode()
|
void |
writeShort(int code)
|
void |
writeUnsignedByte(int code)
|
void |
writeUnsignedShort(int code)
|
| クラス java.lang.Object から継承されたメソッド |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| フィールドの詳細 |
|---|
private static int BYTECODE_BUFFER_SIZE
private int attributeNameIndex
private byte[] bytecodes
private int maxOperandStack
private int maxLocalVariable
private int bytecodeByteSize
private static CodeBufferManager instance
| コンストラクタの詳細 |
|---|
private CodeBufferManager()
throws CompileError
CompileError| メソッドの詳細 |
|---|
public static CodeBufferManager getInstance()
throws CompileError
CompileError
public void setMaxOperandStack(int stackPointer)
throws CompileError
CompileError
public void setMaxLocalVariable(int localVariable)
throws CompileError
CompileError
public void emitCode(java.io.DataOutputStream classfile)
throws CompileError
CompileErrorpublic int getBytecodeByteSize()
public void patchByte(int bytecodeByteSize,
int code)
throws CompileError
CompileError
public void patchUnsignedByte(int bytecodeByteSize,
int code)
throws CompileError
CompileError
public void patchShort(int bytecodeByteSize,
int code)
throws CompileError
CompileError
public void patchUnsignedShort(int bytecodeByteSize,
int code)
throws CompileError
CompileError
public void patchInt(int bytecodeByteSize,
int code)
throws CompileError
CompileError
public void writeByte(int code)
throws CompileError
CompileError
public void writeUnsignedByte(int code)
throws CompileError
CompileError
public void writeShort(int code)
throws CompileError
CompileError
public void writeUnsignedShort(int code)
throws CompileError
CompileError
public void writeInt(int code)
throws CompileError
CompileError
public void insertEmpty(int offset,
int size)
offset - 空領域を作り始める場所.size - 空領域のバイト数.public int appendEmpty(int size)
size - 空領域のバイト数.
private void requireToExtendCode(int currentBytecodeSize)
void writeReturnBytecode()
throws CompileError
CompileErrorpublic void init()
IntermediateLangManager 内の init
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||