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

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

public class OperatorOfUnary
extends Expression

単項演算子.

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

フィールドの概要
private  Expression operand
           
private  int operatorBytecode
           
 
クラス org.oklab.compiler.syntaxtree.Node から継承されたフィールド
parent
 
コンストラクタの概要
OperatorOfUnary(Node parentNode, int operatorToken, SourceReader sReader)
          単項演算子の構文木作成.
 
メソッドの概要
 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
 

フィールドの詳細

operatorBytecode

private int operatorBytecode

operand

private Expression operand
コンストラクタの詳細

OperatorOfUnary

public OperatorOfUnary(Node parentNode,
                       int operatorToken,
                       SourceReader sReader)
                throws CompileError
単項演算子の構文木作成.

パラメータ:
parentNode - 親ノード.
operatorToken - トークン.
sReader - 読み込むソースコード.
例外:
CompileError
メソッドの詳細

emitCode

public int emitCode(CodeBufferManager code,
                    int stackPointer)
             throws CompileError
単項演算子のバイトコードをコードバッファに出力する. 単項演算子とは、オペランドがひとつだけの演算子である.例えば-3は、-が単項演算子 で3がオペランドである.このプログラミング言語では、+または-の単項演算子のみを 扱えるようにするので、+の場合は文法的には問題ないので、そのままにして、-の場合は 次にくるオペランドの型チェックと値を反転するバイトコードを出力する.

定義:
クラス Expression 内の emitCode
パラメータ:
code - コードバッファ.
stackPointer - 出力先のオフセット.
例外:
CompileError