Esempio n. 1
0
        //------------------------------------------------------------
        // XDataに変換する。
        public string ToXDataXml()
        {
            // 作成
            var xdata = new XDataWriter();

            // BCModule
            xdata.WriteCommentLine("BCModule");
            using (new XDataWriter.IndentScope(xdata))
            {
                {// BCVersion
                    xdata.WriteIndent();
                    xdata.WriteComment("version (" + BC_VERSION_PUBLISH_MAJOR + "." + BC_VERSION_PUBLISH_MINOR + "." + BC_VERSION_PRIVATE_MAJOR + "." + BC_VERSION_PRIVATE_MINOR + ")");
                    xdata.WriteUInt8(BC_VERSION_PUBLISH_MAJOR);
                    xdata.WriteUInt8(BC_VERSION_PUBLISH_MINOR);
                    xdata.WriteUInt8(BC_VERSION_PRIVATE_MAJOR);
                    xdata.WriteUInt8(BC_VERSION_PRIVATE_MINOR);
                    xdata.WriteLine();
                }
                xdata.WriteStringLine("path", SymbolNodeUtil.FullPath(mModuleSymbolNode));
                mConstantValueTable.XDataWriteReference(xdata);
                mSymbolLinkTable.XDataWriteReference(xdata);
                mObjectTypeList.XDataWriteReference(xdata);
            }

            // 各実体
            mConstantValueTable.XDataWriteEntity(xdata);
            mSymbolLinkTable.XDataWriteEntity(xdata);
            mObjectTypeList.XDataWriteEntity(xdata);

            // 結果を返す
            return(xdata.ToXMLText());
        }
Esempio n. 2
0
        //------------------------------------------------------------
        // XDataに実体を書き込む。
        public void XDataWriteEntity(XDataWriter aWriter)
        {
            aWriter.WriteCommentLine("BCConstantValueTable");
            using (new XDataWriter.IndentScope(aWriter))
            {
                // アライメントとラベル
                aWriter.WriteAlignLine(8);
                aWriter.WriteLabelLine(XDATA_LABEL);

                // テーブルのサイズ
                aWriter.WriteUInt32Line("size", mSize);

                // 各定数
                uint pos = 0;
                foreach (var entry in mList)
                {
                    // オフセット位置までpadding
                    uint offset = entry.Offset();
                    if (pos < offset)
                    {
                        uint padSize = offset - pos;
                        aWriter.WriteIndent();
                        aWriter.WriteComment("padding (" + padSize + ")");
                        for (uint i = 0; i < padSize; ++i)
                        {
                            aWriter.WriteUInt8(0xFF);
                        }
                        aWriter.WriteLine();
                    }
                    pos = offset;

                    // 値
                    entry.XDataWriteEntity(aWriter);
                    pos += entry.Size();
                }
            }
        }
Esempio n. 3
0
        //------------------------------------------------------------
        // XDataに書き込む。
        public void XDataWrite(XDataWriter aWriter, uint aIndex)
        {
            aWriter.WriteIndent();
            aWriter.WriteComment("[" + aIndex.ToString("X4") + "]" + ToASMText());
            aWriter.WriteUInt8((byte)mOp);
            switch (mFormat)
            {
            case OpFormat.CS2:
            {
                aWriter.WriteUInt8(0xFF);         // dummy
                aWriter.WriteSInt16(mCS2);
            }
            break;

            case OpFormat.CU1:
            {
                aWriter.WriteUInt8(mCU1A);
                aWriter.WriteUInt16(0xFFFF);         // dummy
            }
            break;

            case OpFormat.CU1_CU1:
            {
                aWriter.WriteUInt8(mCU1A);
                aWriter.WriteUInt8(mCU1B);
                aWriter.WriteUInt8(0xFF);         // dummy
            }
            break;

            case OpFormat.FR1_SR1:
            {
                aWriter.WriteUInt8(mFR1);
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteUInt8(0xFF);         // dummy
            }
            break;

            case OpFormat.SR1:
            {
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteUInt16(0xFFFF);         // dummy
            }
            break;

            case OpFormat.SR1_CS2:
            {
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteSInt16(mCS2);
            }
            break;

            case OpFormat.SR1_CTI:
            {
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteUInt16((ushort)mConstantValue.Offset());
            }
            break;

            case OpFormat.SR1_SR2:
            {
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteUInt8(mSR2.Index());
                aWriter.WriteUInt8(0xFF);         // dummy
            }
            break;

            case OpFormat.SR1_SR2_SR3:
            {
                aWriter.WriteUInt8(mSR1.Index());
                aWriter.WriteUInt8(mSR2.Index());
                aWriter.WriteUInt8(mSR3.Index());
            }
            break;

            case OpFormat.STI:
            {
                aWriter.WriteUInt8(0xFF);         // dummy
                aWriter.WriteUInt16(mSymbolLink.Index);
            }
            break;

            default:
                Assert.NotReachHere();
                break;
            }
            aWriter.WriteLine();
        }