org.oklab.compiler.syntaxtree.expression
クラス ConstantInt

java.lang.Object
  上位を拡張 org.oklab.compiler.syntaxtree.Node
      上位を拡張 org.oklab.compiler.syntaxtree.expression.Expression
          上位を拡張 org.oklab.compiler.syntaxtree.expression.ConstantInt

public class ConstantInt
extends Expression

int型の定数を表す.

導入されたバージョン:
1.0
バージョン:
1.0
作成者:
Satoshi Okita satoshiokita@gmail.com

フィールドの概要
private  int constantValue
          定数の値.
private  int index
          コンテントプール格納先index.
 
クラス org.oklab.compiler.syntaxtree.Node から継承されたフィールド
parent
 
コンストラクタの概要
ConstantInt(Node parentNode, int constantValue)
          定数はすぐにコンテントプールに格納する.
 
メソッドの概要
 int emitCode(CodeBufferManager code, int stackPointer)
          バイトコードをバッファに出力する.
 
クラス org.oklab.compiler.syntaxtree.expression.Expression から継承されたメソッド
parseXStatement
 
クラス org.oklab.compiler.syntaxtree.Node から継承されたメソッド
getReturnType, localVariableCount, parseExpression, parseFactor, parseRefferenceOrCall, parseStatement, parseTerm, setParent
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

index

private int index
コンテントプール格納先index.


constantValue

private int constantValue
定数の値.

コンストラクタの詳細

ConstantInt

public ConstantInt(Node parentNode,
                   int constantValue)
定数はすぐにコンテントプールに格納する.

パラメータ:
parentNode - 構文木の親ノード.
constantValue - 定数値.
メソッドの詳細

emitCode

public int emitCode(CodeBufferManager code,
                    int stackPointer)
             throws CompileError
バイトコードをバッファに出力する. 出力する前に、スタック領域の拡張を行う.その後バイトコードの書き込みを行うが 実行時のパフォーマンスをよくするため、iconst_m1,iconst_0,bipushなど定数の値に よって出力するバイトコードを変更している.

定義:
クラス Expression 内の emitCode
パラメータ:
code - バイトコードの出力先バッファ.
stackPointer - スタックの最大値.
戻り値:
正常時は、int型を返す.
例外:
CompileError