Example #1
0
 //------------------------------------------------------------
 // OP SReg形式の命令コードを追加する。
 public void AddOPCode_SReg(BCOpCode.OpType aOP, StackRegister aSR)
 {
     mBCOpCodeList.Add(new BCOpCode(
                           aOP
                           , aSR
                           ));
 }
Example #2
0
 //------------------------------------------------------------
 // OP SReg ConstantTableIndex形式の命令コードを追加する。
 public void AddOPCode_SReg_ConstantTableIndex(BCOpCode.OpType aOP, StackRegister aSR, int aValue)
 {
     mBCOpCodeList.Add(new BCOpCode(
                           aOP
                           , aSR
                           , mBCModule.GetConstantValue(new BCConstantValue(aValue))
                           ));
 }
Example #3
0
 //------------------------------------------------------------
 // OP CU1 SReg形式の命令コードを追加する。
 public void AddOPCode_CU1_SR(BCOpCode.OpType aOP, byte aValue, StackRegister aSR)
 {
     mBCOpCodeList.Add(new BCOpCode(
                           aOP
                           , aValue
                           , aSR
                           ));
 }
Example #4
0
 //------------------------------------------------------------
 // OP SReg1 SReg2形式の命令コードを追加する。
 public void AddOPCode_SReg1_SReg2(BCOpCode.OpType aOP, StackRegister aSR1, StackRegister aSR2)
 {
     mBCOpCodeList.Add(new BCOpCode(
                           aOP
                           , aSR1
                           , aSR2
                           ));
 }
Example #5
0
            //------------------------------------------------------------
            // 同じ数値の演算しか許さないタイプの演算。
            void evaluateNumberType(
                SemanticAnalyzeComponent aComp
                , BCOpCode.OpType aOpType
                , bool aSwapLR // trueなら左辺と右辺を逆転させる。
                )
            {
                // レジスタ設定
                mTransferredEIHolder.ReceiveAndSetSR(aComp);

                // 伝達設定
                mTransferredEIHolder.TransferIfPossible(aComp);

                // 1つめ
                mFirstNode.SendEvent(aComp, EvaluateNodeEventKind.Evaluate);

                // 伝達リセット
                aComp.TransferredEvaluateInfoReset();

                // 可能なら2つめに伝達する
                if (!mFirstNode.GetEvaluateInfo().SR.IsSame(mEvaluateInfo.SR))
                {
                    mTransferredEIHolder.TransferIfPossible(aComp);
                }

                // 2つめ
                mSecondNode.SendEvent(aComp, EvaluateNodeEventKind.Evaluate);

                // 伝達リセット
                aComp.TransferredEvaluateInfoReset();

                // todo:
                // 暗黙の変換の対応
                // 今はintしか対応しない
                if (mFirstNode.GetEvaluateInfo().Kind != EvaluateInfo.InfoKind.Value ||
                    mFirstNode.GetEvaluateInfo().TypeInfo.Symbol.GetBuiltInType() != BuiltInType.SInt32 ||
                    mSecondNode.GetEvaluateInfo().Kind != EvaluateInfo.InfoKind.Value ||
                    mSecondNode.GetEvaluateInfo().TypeInfo.Symbol.GetBuiltInType() != BuiltInType.SInt32
                    )
                {
                    aComp.ThrowErrorException(SymbolTree.ErrorKind.NOT_SUPPORTED_EXPRESSION, mExpr.mOpToken);
                }

                // 演算
                StackRegister leftSR  = mFirstNode.GetEvaluateInfo().SR;
                StackRegister rightSR = mSecondNode.GetEvaluateInfo().SR;

                aComp.BCFunction.AddOPCode_SReg1_SReg2_SReg3(
                    aOpType
                    , mEvaluateInfo.SR
                    , aSwapLR ? rightSR : leftSR
                    , aSwapLR ? leftSR : rightSR
                    );

                // 通知
                mSecondNode.SendEvent(aComp, EvaluateNodeEventKind.Release);
                mFirstNode.SendEvent(aComp, EvaluateNodeEventKind.Release);
            }
Example #6
0
        //------------------------------------------------------------
        // OpFormat.SR1形式のコンストラクタ。
        public BCOpCode(OpType aOp, StackRegister aSR1)
        {
            // 設定
            mFormat = OpFormat.SR1;
            mOp     = aOp;
            mSR1    = aSR1;

            // チェック
            checkOpAndFormat();
        }
Example #7
0
        //------------------------------------------------------------
        // OpFormat.SR1_CTI形式のコンストラクタ。
        public BCOpCode(OpType aOp, StackRegister aSR1, BCConstantValue aCV)
        {
            // 設定
            mFormat        = OpFormat.SR1_CTI;
            mOp            = aOp;
            mSR1           = aSR1;
            mConstantValue = aCV;

            // チェック
            checkOpAndFormat();
        }
Example #8
0
        //------------------------------------------------------------
        // OpFormat.SR1_CS2形式のコンストラクタ。
        public BCOpCode(OpType aOp, StackRegister aSR1, short aCS2)
        {
            // 設定
            mFormat = OpFormat.SR1_CS2;
            mOp     = aOp;
            mSR1    = aSR1;
            mCS2    = aCS2;

            // チェック
            checkOpAndFormat();
        }
Example #9
0
        //------------------------------------------------------------
        // OpFormat.FR_SR形式のコンストラクタ。
        public BCOpCode(OpType aOp, byte aFR, StackRegister aSR)
        {
            // 設定
            mFormat = OpFormat.FR1_SR1;
            mOp     = aOp;
            mFR1    = aFR;
            mSR1    = aSR;

            // チェック
            checkOpAndFormat();
        }
Example #10
0
        //------------------------------------------------------------
        // OpFormat.SR1_SR2_SR3形式のコンストラクタ。
        public BCOpCode(OpType aOp, StackRegister aSR1, StackRegister aSR2, StackRegister aSR3)
        {
            // 設定
            mFormat = OpFormat.SR1_SR2_SR3;
            mOp     = aOp;
            mSR1    = aSR1;
            mSR2    = aSR2;
            mSR3    = aSR3;

            // チェック
            checkOpAndFormat();
        }
Example #11
0
        //------------------------------------------------------------
        // OP SReg Label形式の命令コードを追加する。
        public void AddOPCode_SReg_Label(BCOpCode.OpType aOP, StackRegister aSR, BCLabel aLabel)
        {
            // OpCode作成
            var opCode = new BCOpCode(
                aOP
                , aSR
                , (short)0
                );

            // 追加されるindexをメモ
            uint index = (uint)mBCOpCodeList.Count;

            // OpCode追加
            mBCOpCodeList.Add(opCode);

            // LabelReference追加
            mBCLabelReferenceList.Add(new BCLabelReference(aLabel, opCode, index));
        }
Example #12
0
 //------------------------------------------------------------
 // 等しいか。
 public bool IsSame(StackRegister aRHS)
 {
     return(IsValid == aRHS.IsValid && mIndex == aRHS.mIndex);
 }