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

java.lang.Object
  上位を拡張 org.oklab.compiler.syntaxtree.Node
      上位を拡張 org.oklab.compiler.syntaxtree.expression.Expression
          上位を拡張 org.oklab.compiler.syntaxtree.expression.Variable
直系の既知のサブクラス:
VariableOfGlobal, VariableOfLocal

public abstract class Variable
extends Expression

変数を表す抽象クラス. 変数は実際にはローカル変数やグローバル変数で表すが共通する情報はこのクラス で定義してある.

導入されたバージョン:
1.0
バージョン:
1.0
作成者:
Satoshi Okita satoshiokita@gmail.com
関連項目:
VariableOfGlobal, VariableOfLocal

フィールドの概要
protected  int type
          型情報.
 
クラス org.oklab.compiler.syntaxtree.Node から継承されたフィールド
parent
 
コンストラクタの概要
Variable(Node parent, int type)
          Creates a new instance of Variable
 
メソッドの概要
abstract  Variable createReference(Node parent)
           
 int emitCode(CodeBufferManager code)
          istore用インタフェース.
protected abstract  void emitCode(CodeBufferManager code, boolean isLoad)
          フィールドからの読み込みか、書き込みのバイトコードを出力.
 int emitCode(CodeBufferManager code, int stackPointer)
          iload用インタフェース.
private  void isInt(int type)
           
 Statement parseXStatement(Node parent, SourceReader sReader)
          variableAAA = 10 * 20;のような文は代入文である.はじめが変数で始まる文は 代入文か関数呼び出しになる.ここでは代入文の場合の構文解析になる.
 
クラス 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
 

フィールドの詳細

type

protected int type
型情報.

コンストラクタの詳細

Variable

public Variable(Node parent,
                int type)
Creates a new instance of Variable

メソッドの詳細

createReference

public abstract Variable createReference(Node parent)

parseXStatement

public Statement parseXStatement(Node parent,
                                 SourceReader sReader)
                          throws CompileError
variableAAA = 10 * 20;のような文は代入文である.はじめが変数で始まる文は 代入文か関数呼び出しになる.ここでは代入文の場合の構文解析になる.

オーバーライド:
クラス Expression 内の parseXStatement
例外:
CompileError
関連項目:
Call.parseXStatement(Node parent, SourceReader sReader), Substitute

emitCode

public int emitCode(CodeBufferManager code)
             throws CompileError
istore用インタフェース. a = 1; という式であれば、aに値を代入する.このメソッドはその"代入"にあたる バイトコードを出力する.

例外:
CompileError
関連項目:
Substitute.emitCode(CodeBufferManager)

emitCode

public int emitCode(CodeBufferManager code,
                    int stackPointer)
             throws CompileError
iload用インタフェース. 式がhoveVal + 50などのように変数と定数で構成されている場合、hogeVal変数は 実際の値に展開してから計算を行う.その"展開"にあたる部分のバイトコードを出力する. そのため、条件文やその他式でこのメソッドは多用される.

定義:
クラス Expression 内の emitCode
例外:
CompileError

isInt

private void isInt(int type)
            throws CompileError
例外:
CompileError

emitCode

protected abstract void emitCode(CodeBufferManager code,
                                 boolean isLoad)
                          throws CompileError
フィールドからの読み込みか、書き込みのバイトコードを出力.

パラメータ:
code - 書き込み先バッファ
isLoad - trueの場合、フィールドの読み込み,falseの場合フィールドの書き込み バイトコードを出力する.
例外:
CompileError